GameData.ts 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568
  1. import Util from "../../before/util/Util";
  2. import FunBtns from "../game/FunBtns";
  3. import Game from "../game/Game";
  4. /**
  5. * @description 游戏核心玩法数据
  6. * @author 邹勇
  7. */
  8. export class GameData {
  9. public dataFinish: boolean = false;
  10. public savePropFinish: boolean = false;
  11. public savePropsFinish: boolean = false;
  12. public getPropsFnish: boolean = false;
  13. //是否触摸屏幕
  14. public isTouchScreen: boolean = false;
  15. public configs: any = {};
  16. public adShowConfig: ADShowCfg;
  17. /** 功能开启 */
  18. public funOpenData: string[] = [];
  19. public playerProp: PlayerProp = null;
  20. /** 标志位:刷新主界面货币 */
  21. public init_coin: boolean = false;
  22. public updatePiggyBankValue: boolean = false;
  23. /** 标志位:刷新主界面头像 */
  24. public init_head: boolean = false;
  25. public init_add: boolean = false;
  26. /** 标志位:刷新主界面红点 */
  27. public init_red_point: boolean = true;
  28. //标志位,刷新提现界面的红包币
  29. public init_wallet_redMoney = false;
  30. /** 属性存储字典 */
  31. public props: Map<number, any> = new Map<number, any>();
  32. public pools = [
  33. { url: "game/prefab/tips", num: 20 },
  34. { url: "game/prefab/coin", num: 20 }
  35. ];
  36. /** 主页样式脚本 */
  37. public gameStyle: Game = null;
  38. /** 入口按钮 */
  39. public funBtns: FunBtns = null;
  40. /** 剩余可种植次数 */
  41. public leftTimes: number = -1;
  42. /** 最大可种植次数 */
  43. public maxTimes: number = -1;
  44. /** 恢复种植次数间隔 */
  45. public ProductionRecovery: number = 15;
  46. public init_leftTimes: boolean = false;
  47. /** 可生产商品配置 */
  48. public nextCanProduct = null;
  49. /** 按钮生产选中的农田、牧场或工厂 */
  50. public nextMake = null;
  51. /** 类型标识 */
  52. private nextType = 0;
  53. /** 刷新生产按钮信息 */
  54. public init_makeInfo = false;
  55. /** 正在生产 */
  56. public isProducting = false;
  57. /** 标志位 刷新任务描述 */
  58. public init_task = false;
  59. public init_expLevel = false;
  60. //标志位任务跟新
  61. public init_redBagTask = false;
  62. //标志位 生产奖励的任务ui刷新
  63. public init_productTask = false;
  64. public init_speedup = false;
  65. 标志位
  66. public init_hideRedBag = false;
  67. public shareUrl = '';
  68. public shareTitle = '';
  69. public shareDes = '';
  70. public shareImgUrl = '';
  71. /** 生虫/生病/停电最多个数 */
  72. public RawInsectArr = [];
  73. /** 生虫/生病/停电当前个数 */
  74. public RawInsectCurArr = [0, 0, 0];
  75. /**
  76. * 初始化游戏数据:网络配置信息,用户信息
  77. * @returns
  78. */
  79. public async init() {
  80. let data: any = { "versionCode": gData.appData.version };
  81. let response = await mk.http.sendData('getAllConfigInfo', data);
  82. if (response.errcode != 0) {
  83. if (response.errcode == -10003 || response.errcode == -20003) {
  84. //清除缓存
  85. gData.loginData.reload();
  86. }
  87. return;
  88. }
  89. mk.console.logSingle("getAllConfigInfo", response.data);
  90. this.initConfigs(response.data);
  91. //初始化topon
  92. mk.ad.init();
  93. data = {};
  94. response = await mk.http.sendData('getInfoCrypt', data);
  95. if (response.errcode != 0) {
  96. return;
  97. }
  98. mk.console.logSingle("getInfoCrypt", response.data);
  99. this.initPlayerProp(response.data)
  100. this.initProps(response.data.gameUserData);
  101. data = {};
  102. response = await mk.http.sendData('user/adShowConfig', data);
  103. if (response.errcode != 0) {
  104. return;
  105. }
  106. this.adShowConfig = response.data;
  107. mk.console.logSingle("user/adShowConfig", response.data);
  108. gData.adData.initEcpmData();
  109. // data = {};
  110. // response = await mk.http.sendData('noviceWeFare/getNoviceWeFareInfo', data);
  111. // if (response.errcode != 0) {
  112. // return;
  113. // }
  114. // this.playerProp.userTuCaoInfo = response.data.userWelFareTaskInfo;
  115. // mk.console.logSingle("welFare/getUserWelFareTaskInfo", response.data);
  116. gData.guideData.init();
  117. gData.guideWeakData.init();
  118. gData.moduleData.forEach(element => {
  119. element.init();
  120. });
  121. this.dataFinish = true;
  122. }
  123. private initConfigs(data) {
  124. // console.log('config ', data);
  125. this.configs = data;
  126. this.funOpenData = this.configs.ServerConfig.Functionswitch.split(",");
  127. //从服务器解析配置
  128. this.setProductMapFromJson();
  129. gData.loginData.popIdentifySwitch = this.configs.ServerConfig.popIdentifySwitch == '1';
  130. gData.gameData.shareUrl = this.configs.ServerConfig.shareUrl;
  131. gData.gameData.shareTitle = this.configs.ServerConfig.shareTitle;
  132. gData.gameData.shareDes = this.configs.ServerConfig.shareDes;
  133. gData.gameData.shareImgUrl = this.configs.ServerConfig.shareImgUrl;
  134. gData.gameData.RawInsectArr = this.configs.ServerConfig.RawInsect.split(',');
  135. }
  136. /**
  137. * 初始化玩家数据
  138. */
  139. private initPlayerProp(res_data) {
  140. this.playerProp = new PlayerProp();
  141. this.playerProp.cashIndex = res_data.cashIndex;
  142. this.playerProp.gameUserData = res_data.gameUserData;
  143. this.playerProp.isSignInToday = res_data.isSignInToday;
  144. this.playerProp.isWithdrawable = res_data.isWithdrawable;
  145. this.playerProp.lastTime = res_data.lastTime;
  146. this.playerProp.loginDays = res_data.loginDays;
  147. this.playerProp.newPlayer = res_data.newPlayer;
  148. this.playerProp.initPiggyBank(res_data.piggyBank);
  149. this.playerProp.piggyBankCashTimes = res_data.piggyBankCashTimes;
  150. this.playerProp.redMoney = res_data.redMoney == null ? 0 : res_data.redMoney;
  151. this.playerProp.signInDay = res_data.signInDay;
  152. this.playerProp.totalPiggyBankCashTimes = res_data.totalPiggyBankCashTimes;
  153. this.playerProp.turntableTimes = res_data.turntableTimes;
  154. this.playerProp.versioncfg = res_data.versioncfg;
  155. this.playerProp.isFirstRedMoney = res_data.isFirstRedMoney;
  156. gData.adData.watchNumToday = res_data.dayVideoTimesForRedMoney == null ? 0 : res_data.dayVideoTimesForRedMoney;
  157. this.playerProp.gradeLevel = res_data.farmLevel
  158. this.playerProp.userTuCaoInfo = res_data.userWelFareTaskInfo;
  159. this.playerProp.farmExpValue = res_data.userExp;
  160. this.playerProp.farmGradeData = res_data.userFarmGrageRewardInfo;
  161. this.playerProp.userNoviceWeFareInfo = res_data.userNoviceWeFareInfo;
  162. this.playerProp.redMoneyCashPayRecordList = res_data.redMoneyCashPayRecordList;
  163. mk.console.logSingle('userNoviceWeFareInfo==>', res_data.userNoviceWeFareInfo);
  164. //mk.console.logSingle('redMoneyCashPayRecordList==>', res_data.redMoneyCashPayRecordList);
  165. this.playerProp.userFarmTaskInfo = res_data.userFarmTaskInfo;
  166. this.playerProp.speedUpLeftTimes = res_data.speedUpLeftTimes;
  167. this.playerProp.completeFarmTaskTimes = res_data.completeFarmTaskTimes;
  168. mk.data.setTAUserID(gData.loginData.uin);
  169. mk.data.setTAEventUser(0, 'logindays_total', this.playerProp.loginDays);
  170. if (this.playerProp.completeFarmTaskTimes == 0) {
  171. mk.data.setTAEventUser(0, 'Cumulative_task', gData.gameData.playerProp.completeFarmTaskTimes);
  172. }
  173. if (gData.loginData.isFirstIn) {
  174. gData.loginData.isFirstIn = false;
  175. mk.data.setTAEventRegister();
  176. mk.data.sendDataEvent('ABTest', `触发${this.playerProp.groupCode}方案`);
  177. //注册时版本号
  178. mk.data.setTAEventUserStr(0, 'regtime_app_id', gData.appData.appVersion);
  179. //星云uid
  180. mk.data.setTAEventUserStr(0, 'xy_uid', gData.loginData.uin);
  181. mk.data.setTAEventUser(0, 'farm_lv', gData.gameData.playerProp.gradeLevel);
  182. }
  183. //当前版本号
  184. mk.data.setTAEventUserStr(0, 'now_app_id', gData.appData.appVersion);
  185. //渠道号
  186. mk.data.setTAEventUserStr(0, 'channel_id', gData.appData.umengChannel);
  187. // //test
  188. // this.playerProp.completeFarmTaskTimes = 3;
  189. }
  190. /**
  191. * 保存单个数据
  192. */
  193. public async setProp(key: GameProp, value: any) {
  194. let data = {
  195. key: key + '',
  196. value: value
  197. };
  198. this.props.set(key, value);
  199. await mk.http.sendData('savePlayerProp', data);
  200. this.savePropFinish = true;
  201. }
  202. /**
  203. * 保存多个数据
  204. */
  205. public async setProps(arr: { key: GameProp, value: any }[]) {
  206. let needProp = {};
  207. for (let i = 0; i < arr.length; i++) {
  208. needProp[arr[i].key + ''] = arr[i].value;
  209. }
  210. let data = {
  211. needProp: needProp
  212. };
  213. for (let i = 0; i < arr.length; i++) {
  214. this.props.set(arr[i].key, arr[i].value);
  215. }
  216. await mk.http.sendData('saveAllPlayerProp', data);
  217. this.savePropsFinish = true;
  218. }
  219. /** 获取属性 */
  220. public getProp(key: GameProp): any {
  221. if (this.props == null) {
  222. return 0;
  223. }
  224. let value = this.props.get(key);
  225. return value;
  226. }
  227. /**
  228. * 向服务器请求所有属性后更新
  229. */
  230. public async getAllProps() {
  231. let response = await mk.http.sendData('getAllPlayerProp', {});
  232. if (response.errcode != 0) {
  233. return;
  234. }
  235. this.initProps(response.data);
  236. this.getPropsFnish = true;
  237. }
  238. private initProps(data) {
  239. if (data == null) {
  240. return;
  241. }
  242. for (let key in data) {
  243. this.props.set(parseInt(key), data[key]);
  244. }
  245. this.setFramDataMapByServer();
  246. this.setPastureDataMapByServer();
  247. this.setFactoryDataMapByServer();
  248. this.initProductTimes();
  249. this.initLeftTimes();
  250. this.initFarmMapGetRewardData();
  251. // let isNewTask = this.getProp(GameProp.redBagTaskRefresh);
  252. // if (isNewTask != undefined) {
  253. // this.init_redBagTask = isNewTask;
  254. // }
  255. }
  256. private initLeftTimes() {
  257. let lefttimes = this.getProp(GameProp.leftTimes);
  258. if (lefttimes == undefined) {
  259. this.leftTimes = parseInt(this.configs.ServerConfig.FreeProduction);
  260. this.setProp(GameProp.leftTimes, this.leftTimes);
  261. }
  262. else {
  263. this.leftTimes = lefttimes;
  264. }
  265. this.maxTimes = parseInt(this.configs.ServerConfig.ProductionMax);
  266. this.ProductionRecovery = parseInt(this.configs.ServerConfig.ProductionRecovery);
  267. // //test
  268. // this.leftTimes = 1;
  269. // this.maxTimes = 20;
  270. // this.ProductionRecovery = 1;
  271. }
  272. /** 增加减少生产次数
  273. * @param add 增减变量
  274. */
  275. public changeLeftTimes(add, isIgnoreMaxTimes = false) {
  276. gData.gameData.leftTimes += add;
  277. if (add > 0 && !isIgnoreMaxTimes) {
  278. gData.gameData.leftTimes = (gData.gameData.leftTimes > gData.gameData.maxTimes ? gData.gameData.maxTimes : gData.gameData.leftTimes);
  279. }
  280. if (gData.gameData.leftTimes < 0) {
  281. gData.gameData.leftTimes = 0;
  282. }
  283. gData.gameData.setProp(GameProp.leftTimes, gData.gameData.leftTimes);
  284. gData.gameData.init_leftTimes = true;
  285. }
  286. //图鉴领取数据
  287. private _farmMapRewardData = [];
  288. public getFarmMapRewardState(index) {
  289. if (index.i < this._farmMapRewardData.length) {
  290. if (index.j < this._farmMapRewardData[index.i].length) {
  291. return this._farmMapRewardData[index.i][index.j];
  292. }
  293. }
  294. return 1;
  295. }
  296. public setFarmMapRewardState(index, state) {
  297. if (index.i < this._farmMapRewardData.length) {
  298. if (index.j < this._farmMapRewardData[index.i].length) {
  299. this._farmMapRewardData[index.i][index.j] = state;
  300. this.setProp(GameProp.farmMapGetRewardData, this._farmMapRewardData);
  301. }
  302. }
  303. }
  304. private initFarmMapGetRewardData() {
  305. this._farmMapRewardData = this.getProp(GameProp.farmMapGetRewardData);
  306. if (!this._farmMapRewardData) {
  307. this._farmMapRewardData = [];
  308. }
  309. let needSync = false;
  310. let index = 0;
  311. this._productTypeMap.forEach((value, key) => {
  312. if (this._farmMapRewardData.length <= index) {
  313. let len = value.length;
  314. let arr = [];
  315. for (let i = 0; i != len; ++i) {
  316. arr.push(0);
  317. }
  318. this._farmMapRewardData.push(arr);
  319. needSync = true;
  320. console.log("-----add 数组数据")
  321. } else {
  322. let data = this._farmMapRewardData[index];
  323. let len = value.length;
  324. for (let i = 0; i != len; ++i) {
  325. if (i >= data.length) {
  326. data.push(0);
  327. needSync = true;
  328. console.log("-----add 单个数据")
  329. }
  330. }
  331. }
  332. ++index;
  333. });
  334. if (needSync) {
  335. this.setProp(GameProp.farmMapGetRewardData, this._farmMapRewardData);
  336. }
  337. }
  338. /** 是否是新用户 */
  339. public isNewPlayer(): boolean {
  340. let v = this.getProp(GameProp.newPlayer);
  341. return v == 0;
  342. }
  343. //*********** ================= 农场数据 ================== */
  344. /** 农田数据 服务器数据 */
  345. private _farmData = [];
  346. /** 农田字典 本地数据,方便操作*/
  347. private _farmDataMap: Map<number, any> = new Map();
  348. //刷新农田
  349. public needFreshArr = [];
  350. /** 随机获取可种植物品 */
  351. getRandomPlantConfig() {
  352. let id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
  353. return this.getProductMap(id);
  354. }
  355. /** 随机获取可生产产品 */
  356. getRandomFactoryConfig(configID) {
  357. let tab = gData.gameData.getTabByConfigID(configID);
  358. let arr = this.getProductArrByType(tab);
  359. let max = this.getMaxProduct(tab);
  360. let canArr = [];
  361. let len = arr.length;
  362. for (var i = 0; i < len; i++) {
  363. if (arr[i].picture <= max) {
  364. canArr.push(arr[i].picture);
  365. if (arr[i].picture == max) {
  366. break;
  367. }
  368. }
  369. }
  370. let index = Util.rnd(0, canArr.length - 1);
  371. let id = canArr[index];
  372. return this.getProductMap(id);
  373. }
  374. /** 自动生产选中下一个 */
  375. setNextProduct(sel = true) {
  376. if (this.nextMake) {
  377. return;
  378. }
  379. let next = gData.farmSystem.selectNextFarm(sel);
  380. if (!next) {
  381. let next1 = gData.pastureSystem.nextPasture();
  382. if (!next1) {
  383. let next2 = gData.factorySystem.nextFactory();
  384. if (!next2) {
  385. this.nextType = 0;
  386. }
  387. else {
  388. this.nextType = 3;
  389. }
  390. }
  391. else {
  392. this.nextType = 2;
  393. }
  394. }
  395. else {
  396. this.nextType = 1;
  397. }
  398. this.init_makeInfo = true;
  399. }
  400. hasFirstCheck = false;
  401. firstCheckNext() {
  402. if (!this.hasFirstCheck && gData.farmSystem.farms.length >= 18
  403. && gData.pastureSystem.pastureIcons.length >= 3 && gData.factorySystem.factoryIcons.length >= 6) {
  404. this.hasFirstCheck = true;
  405. Util.objSortByKey(gData.farmSystem.farms, 'sortID');
  406. Util.objSortByKey(gData.pastureSystem.pastureIcons, 'sortID');
  407. Util.objSortByKey(gData.factorySystem.factoryIcons, 'sortID');
  408. gData.gameData.setNextProduct(false);
  409. }
  410. }
  411. async makeProduct() {
  412. let flyRed = true;
  413. switch (this.nextType) {
  414. case 0:
  415. mk.tip.pop('农场已满,无法继续生产');
  416. //弹出收获、生虫、加速
  417. if (!this.checkCanHarvest()) {
  418. if (!this.checkCanClearSick()) {
  419. this.checkCanSpeedUp(true);
  420. }
  421. }
  422. flyRed = false;
  423. break;
  424. case 1:
  425. flyRed = await gData.farmSystem.btnMake();
  426. gData.adData.checkPopRed();
  427. break;
  428. case 2:
  429. flyRed = await gData.pastureSystem.btnMake();
  430. gData.adData.checkPopRed();
  431. break;
  432. case 3:
  433. flyRed = await gData.factorySystem.btnMake();
  434. gData.adData.checkPopRed();
  435. break;
  436. }
  437. return flyRed;
  438. }
  439. public async updateNewTaskProgress(isNeedRefresh = false) {
  440. // if (gData.gameData.init_redBagTask) {
  441. // return;
  442. // }
  443. if (this.playerProp.userFarmTaskInfo) {
  444. let com = this.playerProp.userFarmTaskInfo.completeCount;
  445. let count = this.playerProp.userFarmTaskInfo.taskCount;
  446. if (com >= count) {
  447. mk.tip.pop('任务红包进度已满,快去提现');
  448. return false;
  449. }
  450. }
  451. let data = {};
  452. let response = await mk.http.sendData('farmTask/updateUserFarmTaskInfo', data);
  453. mk.console.logSingle('refrehTask=>', response);
  454. if (response.errcode != 0) {
  455. return false;
  456. }
  457. gData.gameData.init_task = true;
  458. this.playerProp.userFarmTaskInfo = response.data.userFarmTaskInfo;
  459. if (this.playerProp.userFarmTaskInfo.completeCount >= this.playerProp.userFarmTaskInfo.taskCount) {
  460. mk.ui.closeAllUI();
  461. mk.guide.curDes = '';
  462. mk.guide.open(3);
  463. }
  464. // if (isNeedRefresh) {
  465. // gData.gameData.init_task = true;
  466. // }
  467. return true;
  468. }
  469. public setFarmDataMap(id, data, sendToServer = true) {
  470. this._farmDataMap.set(id, data);
  471. let len = this._farmData.length;
  472. for (var i = 0; i < len; i++) {
  473. if (this._farmData[i].id == id) {
  474. this._farmData[i].state = data.state;
  475. this._farmData[i].productID = data.productID;
  476. this._farmData[i].growSpan = data.growSpan;
  477. break;
  478. }
  479. }
  480. this.needFreshArr.push(id);
  481. //更新到服务器
  482. if (sendToServer) {
  483. this.freshSendToServer(1);
  484. }
  485. }
  486. public getFarmDataMap(id) {
  487. return this._farmDataMap.get(id);
  488. }
  489. /** 服务器数据设置到本地 */
  490. public setFramDataMapByServer() {
  491. this._farmData = this.getProp(GameProp.farmData);
  492. if (!this._farmData) {
  493. this._farmData = [];
  494. }
  495. let len = this._farmData.length;
  496. //新玩家初始化农田数据
  497. if (len < 18) {
  498. let id = 31000;
  499. let data = null;
  500. let unluckNum = parseInt(gData.gameData.configs.ServerConfig.unluckNum);
  501. for (var i = 0; i < 18; i++) {
  502. if (i < unluckNum) {
  503. data = { id: id, state: FarmState.Empty, productID: 0, growSpan: 0 };
  504. }
  505. else if (i == unluckNum) {
  506. data = { id: id, state: FarmState.CanUnlock, productID: 0, growSpan: 0 };
  507. }
  508. else {
  509. data = { id: id, state: FarmState.Lock, productID: 0, growSpan: 0 };
  510. }
  511. this._farmData.push(data);
  512. this._farmDataMap.set(id, data);
  513. id++;
  514. }
  515. //第一次初始数据
  516. // this.setMaxProduct(10003);
  517. //更新到服务器
  518. this.setProp(GameProp.farmData, this._farmData);
  519. }
  520. else {
  521. let sickTimes = 0;
  522. for (var i = 0; i < len; i++) {
  523. this._farmDataMap.set(this._farmData[i].id, this._farmData[i]);
  524. if (this._farmData[i].state == FarmState.Sick) {
  525. sickTimes++;
  526. }
  527. }
  528. this.RawInsectCurArr[0] = sickTimes;
  529. }
  530. this.setMaxProduct(10003, true);
  531. }
  532. /** puduct配置数据 <picture, config> */
  533. private _productMap: Map<number, any> = new Map();
  534. /** puduct类型配置数据 <tab, 类型数组> */
  535. private _productTypeMap: Map<string, any> = new Map();
  536. /** 设置puduct配置数据 */
  537. public setProductMapFromJson() {
  538. let productJson = this.configs.Product;
  539. // // 先用本地数据
  540. // let productJson = gData.configData.configMap.get('product');
  541. let len = productJson.length;
  542. let product = null;
  543. let tab = '';
  544. let arr = [];
  545. for (var i = 0; i < len; i++) {
  546. product = productJson[i];
  547. this._productMap.set(product.picture, product);
  548. if (tab != product.tab) {
  549. arr = [];
  550. this._productTypeMap.set(product.tab, arr);
  551. tab = product.tab;
  552. }
  553. arr.push(product);
  554. }
  555. }
  556. /** 根据id获取单个数据 */
  557. public getProductMap(id) {
  558. return this._productMap.get(id);
  559. }
  560. /** 根据tab获取数组 */
  561. public getProductArrByType(type: ProductType) {
  562. return this._productTypeMap.get(type);
  563. }
  564. /** 产品生产/种植次数 服务器数据 */
  565. private _productMakeTimesData = [];
  566. /** 产品生产/种植次数 */
  567. private _productMakeTimesMap: Map<number, number> = new Map();
  568. private initProductTimes() {
  569. this._productMakeTimesData = this.getProp(GameProp.productMakeTimes);
  570. if (!this._productMakeTimesData) {
  571. this._productMakeTimesData = [];
  572. }
  573. let len = this._productMakeTimesData.length;
  574. for (var i = 0; i < len; i++) {
  575. this._productMakeTimesMap.set(this._productMakeTimesData[i].id, this._productMakeTimesData[i].times);
  576. this.setMaxProduct(this._productMakeTimesData[i].id);
  577. }
  578. }
  579. addProductMakeTimesById(id: number) {
  580. let times = this._productMakeTimesMap.get(id);
  581. if (!times) {
  582. times = 0;
  583. }
  584. times++;
  585. this._productMakeTimesMap.set(id, times);
  586. //更新到服务器
  587. let has = false;
  588. let len = this._productMakeTimesData.length;
  589. for (var i = 0; i < len; i++) {
  590. if (this._productMakeTimesData[i].id == id) {
  591. this._productMakeTimesData[i].times = times;
  592. has = true;
  593. break;
  594. }
  595. }
  596. if (!has) {
  597. let data = { 'id': id, 'times': times };
  598. this._productMakeTimesData.push(data);
  599. }
  600. //设置可种植/生产最大id
  601. let nextID = id + 1;
  602. let curConfig = this.getProductMap(id);
  603. let nextConfig = this.getProductMap(nextID);
  604. if (id == this.getMaxProduct(curConfig.tab)) {
  605. if (nextConfig) {
  606. gData.plantData.init_itemIndex = nextID;
  607. }
  608. }
  609. if (nextConfig) {
  610. if (nextConfig.tab == curConfig.tab && nextID > this.getMaxProduct(curConfig.tab)) {
  611. if (nextConfig.unlock == 1 && nextConfig.value <= times) {
  612. this._productMakeTimesMap.set(nextID, 0);
  613. let data = { 'id': nextID, 'times': 0 };
  614. this._productMakeTimesData.push(data);
  615. this.setMaxProduct(nextID);
  616. let nConfig = this.getProductMap(nextID + 1);
  617. if (nConfig) {
  618. gData.plantData.init_lock = nextID + 1;
  619. }
  620. }
  621. }
  622. }
  623. this.setProp(GameProp.productMakeTimes, this._productMakeTimesData);
  624. }
  625. getProductMakeTimesById(id: number) {
  626. let times = this._productMakeTimesMap.get(id);
  627. if (!times) {
  628. times = 0
  629. }
  630. return times;
  631. }
  632. //------------- 养殖场数据-----------
  633. /** 养殖场数据 服务器数据 */
  634. private _pastureData = [];
  635. /** 养殖场字典 本地数据,方便操作*/
  636. private _pastureDataMap: Map<number, any> = new Map();
  637. public setPastureDataMap(id, data, sendToServer = true) {
  638. this._pastureDataMap.set(id, data);
  639. let len = this._pastureData.length;
  640. for (var i = 0; i < len; i++) {
  641. if (this._pastureData[i].id == id) {
  642. this._pastureData[i].state = data.state;
  643. this._pastureData[i].productID = data.productID;
  644. this._pastureData[i].growSpan = data.growSpan;
  645. break;
  646. }
  647. }
  648. this.needFreshArr.push(id);
  649. //更新到服务器
  650. if (sendToServer) {
  651. this.freshSendToServer(2);
  652. }
  653. }
  654. public getPastureDataMap(id) {
  655. return this._pastureDataMap.get(id);
  656. }
  657. /** 服务器数据设置到本地 */
  658. public setPastureDataMapByServer() {
  659. this._pastureData = this.getProp(GameProp.pastureData);
  660. if (!this._pastureData) {
  661. this._pastureData = [];
  662. }
  663. let len = this._pastureData.length;
  664. //新玩家初始化养殖场数据
  665. if (len < 3) {
  666. let arr = this.getProductArrByType(ProductType.dw);
  667. let len1 = arr.length;
  668. let id = 30001;
  669. let data = null;
  670. for (var i = 0; i < len1; i++) {
  671. if (this.playerProp.completeFarmTaskTimes < arr[i].value) {
  672. data = { id: id, state: PastureState.Lock, productID: arr[i].picture, growSpan: 0 };
  673. }
  674. else {
  675. data = { id: id, state: PastureState.Empty, productID: arr[i].picture, growSpan: 0 };
  676. }
  677. this._pastureData.push(data);
  678. this._pastureDataMap.set(id, data);
  679. id++;
  680. }
  681. //更新到服务器
  682. this.setProp(GameProp.pastureData, this._pastureData);
  683. }
  684. else {
  685. let sickTimes = 0;
  686. for (var i = 0; i < len; i++) {
  687. this._pastureDataMap.set(this._pastureData[i].id, this._pastureData[i]);
  688. if (this._pastureData[i].state == PastureState.Sick) {
  689. sickTimes++;
  690. }
  691. }
  692. this.RawInsectCurArr[1] = sickTimes;
  693. }
  694. }
  695. //------------- 工厂数据-----------
  696. /** 工厂数据 服务器数据 */
  697. private _factoryData = [];
  698. /** 工厂字典 本地数据,方便操作*/
  699. private _factoryDataMap: Map<number, any> = new Map();
  700. public setFactoryDataMap(id, data, sendToServer = true) {
  701. this._factoryDataMap.set(id, data);
  702. let len = this._factoryData.length;
  703. for (var i = 0; i < len; i++) {
  704. if (this._factoryData[i].id == id) {
  705. this._factoryData[i].state = data.state;
  706. this._factoryData[i].productID = data.productID;
  707. this._factoryData[i].growSpan = data.growSpan;
  708. break;
  709. }
  710. }
  711. this.needFreshArr.push(id);
  712. //更新到服务器
  713. if (sendToServer) {
  714. this.freshSendToServer(3);
  715. }
  716. }
  717. public getFactoryDataMap(id) {
  718. return this._factoryDataMap.get(id);
  719. }
  720. /** 服务器数据设置到本地 */
  721. public setFactoryDataMapByServer() {
  722. this._factoryData = this.getProp(GameProp.factoryData);
  723. if (!this._factoryData) {
  724. this._factoryData = [];
  725. }
  726. let len = this._factoryData.length;
  727. //新玩家初始化工厂数据
  728. if (len < 6) {
  729. let id = 30004;
  730. let data = null;
  731. let tab = null;
  732. for (var i = 0; i < 6; i++) {
  733. tab = this.getTabByConfigID(id);
  734. let arr = this.getProductArrByType(tab);
  735. if (this.playerProp.completeFarmTaskTimes < arr[0].value) {
  736. data = { id: id, state: FactroyState.Lock, productID: 0, growSpan: 0 };
  737. }
  738. else {
  739. data = { id: id, state: FactroyState.Empty, productID: 0, growSpan: 0 };
  740. //更新最大可购买商品
  741. this.setMaxProduct(arr[0].picture, true);
  742. }
  743. this._factoryData.push(data);
  744. this._factoryDataMap.set(id, data);
  745. id++;
  746. }
  747. //更新到服务器
  748. this.setProp(GameProp.factoryData, this._factoryData);
  749. }
  750. else {
  751. let sickTimes = 0;
  752. let id = 30004;
  753. let tab = null;
  754. for (var i = 0; i < len; i++) {
  755. tab = this.getTabByConfigID(id);
  756. let arr = this.getProductArrByType(tab);
  757. this._factoryDataMap.set(this._factoryData[i].id, this._factoryData[i]);
  758. if (this._factoryData[i].state == FactroyState.Sick) {
  759. sickTimes++;
  760. }
  761. if (this.playerProp.completeFarmTaskTimes >= arr[0].value) {
  762. //更新最大可购买商品
  763. this.setMaxProduct(arr[0].picture, true);
  764. }
  765. id++;
  766. }
  767. this.RawInsectCurArr[2] = sickTimes;
  768. }
  769. }
  770. /** 通过工厂建筑物ID获取标签 */
  771. getTabByConfigID(configID: number): ProductType {
  772. let tab = ProductType.bmhc;
  773. switch (configID) {
  774. case 30004:
  775. tab = ProductType.bmhc;
  776. break;
  777. case 30005:
  778. tab = ProductType.gdp;
  779. break;
  780. case 30006:
  781. tab = ProductType.ztc;
  782. break;
  783. case 30007:
  784. tab = ProductType.lrc;
  785. break;
  786. case 30008:
  787. tab = ProductType.gfmg;
  788. break;
  789. case 30009:
  790. tab = ProductType.kcd;
  791. break;
  792. }
  793. return tab;
  794. }
  795. /** 通过标签获取工厂建筑物ID */
  796. getConfigIDByTab(tab: ProductType): number {
  797. let configID = 0;
  798. switch (tab) {
  799. case ProductType.bmhc:
  800. configID = 30004;
  801. break;
  802. case ProductType.gdp:
  803. configID = 30005;
  804. break;
  805. case ProductType.ztc:
  806. configID = 30006;
  807. break;
  808. case ProductType.lrc:
  809. configID = 30007;
  810. break;
  811. case ProductType.gfmg:
  812. configID = 30008;
  813. break;
  814. case ProductType.kcd:
  815. configID = 30009;
  816. break;
  817. }
  818. return configID;
  819. }
  820. /** 发送数据到服务器 */
  821. freshSendToServer(type) {
  822. switch (type) {
  823. case 1:
  824. this.setProp(GameProp.farmData, this._farmData);
  825. break;
  826. case 2:
  827. this.setProp(GameProp.pastureData, this._pastureData);
  828. break;
  829. case 3:
  830. this.setProp(GameProp.factoryData, this._factoryData);
  831. break;
  832. }
  833. }
  834. /** 最大可种植/生产商品数组 */
  835. private _maxProduct = [];
  836. public getMaxProduct(tab) {
  837. if (this._maxProduct) {
  838. let len = this._maxProduct.length;
  839. let data = null;
  840. for (var i = 0; i < len; i++) {
  841. data = this._maxProduct[i];
  842. if (data.tab == tab) {
  843. return data.productID;
  844. }
  845. }
  846. }
  847. return null;
  848. }
  849. /** 设置最大可生产商品
  850. * @param id 产品id
  851. * @param unlock 是否是解锁增加
  852. */
  853. public setMaxProduct(id, unlock = false) {
  854. let config = this.getProductMap(id);
  855. if (!this._maxProduct) {
  856. this._maxProduct = [];
  857. }
  858. let len = this._maxProduct.length;
  859. let data = null;
  860. let has = false;
  861. for (var i = 0; i < len; i++) {
  862. data = this._maxProduct[i];
  863. if (data.tab == config.tab) {
  864. if (data.productID < id) {
  865. data.productID = id;
  866. }
  867. has = true;
  868. break;
  869. }
  870. }
  871. if (!has && unlock) {
  872. data = { tab: config.tab, productID: id };
  873. this._maxProduct.push(data);
  874. }
  875. gData.farmMapData.isStateChange = true;
  876. }
  877. /** 农场升级时解锁工厂,检查最大可种植/生产商品 */
  878. public checkTaskFinishUnLock() {
  879. for (var key in ProductType) {
  880. let tab = ProductType[key];
  881. let configArr = this.getProductArrByType(tab);
  882. let len = configArr.length;
  883. let data = null;
  884. let needUpdate = false;
  885. switch (tab) {
  886. case ProductType.nzw:
  887. break;
  888. case ProductType.dw:
  889. let id = 30001;
  890. needUpdate = false;
  891. let maxId = 0;
  892. for (var i = 0; i < len; i++) {
  893. data = this.getPastureDataMap(id);
  894. if (this.playerProp.completeFarmTaskTimes >= configArr[i].value) {
  895. if (data.state == PastureState.Lock) {
  896. data = { id: id, state: PastureState.Empty, productID: configArr[i].picture, growSpan: 0 };
  897. this.setPastureDataMap(id, data, false);
  898. needUpdate = true;
  899. }
  900. maxId = configArr[i].picture;
  901. }
  902. id++;
  903. }
  904. if (maxId != 0) {
  905. //更新最大可购买商品
  906. this.setMaxProduct(maxId, true);
  907. }
  908. //更新到服务器
  909. if (needUpdate) {
  910. this.setProp(GameProp.pastureData, this._pastureData);
  911. this.setNextProduct();
  912. }
  913. break;
  914. default:
  915. //工厂解锁根据第一个商品
  916. needUpdate = false;
  917. let configID = this.getConfigIDByTab(tab);
  918. data = this.getFactoryDataMap(configID);
  919. if (this.playerProp.completeFarmTaskTimes >= configArr[0].value) {
  920. if (data.state == FactroyState.Lock) {
  921. data = { id: id, state: FactroyState.Empty, productID: 0, growSpan: 0 };
  922. this.setFactoryDataMap(configID, data, false);
  923. needUpdate = true;
  924. }
  925. //更新最大可购买商品
  926. this.setMaxProduct(configArr[0].picture, true);
  927. }
  928. if (needUpdate) {
  929. this.setProp(GameProp.factoryData, this._factoryData);
  930. this.setNextProduct();
  931. }
  932. break;
  933. }
  934. }
  935. }
  936. checkCanSpeedUp(pop = false) {
  937. let can = false;
  938. can = gData.farmSystem.canSpeedUp();
  939. if (!can) {
  940. can = gData.pastureSystem.canSpeedUp();
  941. if (!can) {
  942. can = gData.factorySystem.canSpeedUp();
  943. }
  944. }
  945. if (can && pop) {
  946. mk.ui.openPanel('module/speedUpUI/speedUp');
  947. }
  948. return can;
  949. }
  950. setHarvest() {
  951. gData.farmSystem.setHarvest();
  952. gData.pastureSystem.setHarvest();
  953. gData.factorySystem.setHarvest();
  954. }
  955. checkCanHarvest() {
  956. let can = false;
  957. can = gData.farmSystem.canHarvest();
  958. if (!can) {
  959. can = gData.pastureSystem.canHarvest();
  960. if (!can) {
  961. can = gData.factorySystem.canHarvest();
  962. }
  963. }
  964. return can;
  965. }
  966. checkCanClearSick() {
  967. let can = false;
  968. can = gData.farmSystem.canClearSick();
  969. if (!can) {
  970. can = gData.pastureSystem.canClearSick();
  971. if (!can) {
  972. can = gData.factorySystem.canClearSick();
  973. }
  974. }
  975. return can;
  976. }
  977. doPointToXYLogic() {
  978. let value = mk.storage.getStorage('cash_out');
  979. if (!value) {
  980. mk.storage.setStorage('cash_out', 1);
  981. mk.data.sendXYEvent('cash_1', `第一次提现`);
  982. } else {
  983. if (value == 1) {
  984. mk.storage.setStorage('cash_out', 2);
  985. mk.data.sendXYEvent('cash_2', `第二次提现`);
  986. } else if (value == 2) {
  987. mk.storage.setStorage('cash_out', 3);
  988. mk.data.sendXYEvent('cash_3', `第三次提现`);
  989. }
  990. }
  991. }
  992. }
  993. /**
  994. * 所有模块的非校验数据
  995. */
  996. export enum GameProp {
  997. /** -------------------- 通用玩家数据 ------------------------- */
  998. /** 是否新手 0新手 1老手 */
  999. newPlayer = 1,
  1000. /** 当前新手引导步骤 */
  1001. guideID = 2,
  1002. /** 需要自动弹界面 每次登录都弹 除首次 表示今日是否要自动开 1自动开 2不自动开 其他不处理*/
  1003. isAutoOpenPanel = 3,
  1004. /** 关闭常规提现时需要自动开存钱罐 每天一次 表示今日有没有开过 */
  1005. isOpenBankOnCloseCash = 4,
  1006. //看视频次数
  1007. videoTimes = 5,
  1008. //提现次数
  1009. cashTimes = 6,
  1010. /** ------------------ 游戏核心数据 --------------------------- */
  1011. /** 农田数据 */
  1012. farmData = 11,
  1013. /** 产品生产次数 */
  1014. productMakeTimes = 12,
  1015. /** 养殖场数据 */
  1016. pastureData = 14,
  1017. /** 工厂数据 */
  1018. factoryData = 15,
  1019. /** 剩余可种植次数 */
  1020. leftTimes = 16,
  1021. /**
  1022. 图鉴领取数据*/
  1023. farmMapGetRewardData = 17,
  1024. //红包任务tag
  1025. redBagTaskRefresh = 18,
  1026. /** ------------------ 转盘数据 ------------------------------ */
  1027. turnable_leftTimes = 20,
  1028. }
  1029. /**
  1030. * 玩家数据
  1031. */
  1032. class PlayerProp {
  1033. /** 自定义不需要校验的数据 */
  1034. gameUserData = 0;
  1035. _isSignInToday = 0;
  1036. /**
  1037. * 今日是否有签到
  1038. * - 0 未签到,表示可以签到
  1039. * - 1 有签到,表示不可签到
  1040. */
  1041. set isSignInToday(value: number) {
  1042. this._isSignInToday = value;
  1043. gData.sign.init_data = true;
  1044. gData.gameData.init_red_point = true;
  1045. }
  1046. get isSignInToday(): number {
  1047. return this._isSignInToday;
  1048. }
  1049. private _piggyBank: number = 0;
  1050. /** 存钱罐存款 */
  1051. set piggyBank(value: number) {
  1052. if (this._piggyBank === value) return;
  1053. if (gData.gameData.playerProp.isWithdrawable && value > 0) return;// 存钱罐可提现状态,不能增加存钱罐金额
  1054. this._piggyBank = value;
  1055. gData.gameData.init_coin = true;
  1056. gData.gameData.init_red_point = true;
  1057. }
  1058. get piggyBank(): number {
  1059. return this._piggyBank;
  1060. }
  1061. /** 初始化 */
  1062. initPiggyBank(v) {
  1063. this._piggyBank = v;
  1064. }
  1065. _isWithdrawable = 0;
  1066. /**
  1067. * 存钱罐能否提现
  1068. * - 0 不能提现
  1069. * - 1 能提现
  1070. */
  1071. set isWithdrawable(value: number) {
  1072. if (this._isWithdrawable != value) {
  1073. this._isWithdrawable = value;
  1074. gData.gameData.init_red_point = true;
  1075. }
  1076. }
  1077. get isWithdrawable(): number {
  1078. return this._isWithdrawable;
  1079. }
  1080. /** 存钱罐每日提现次数 */
  1081. piggyBankCashTimes = 0;
  1082. /** 累计存钱罐每日提现次数 */
  1083. totalPiggyBankCashTimes = 0;
  1084. /** 提现进度 */
  1085. cashIndex = 0;
  1086. /** 上次登录时间 */
  1087. lastTime = 0;
  1088. /** 登录天数 */
  1089. loginDays = 0;
  1090. newPlayer = 0;
  1091. private _redMoney: number = 0;
  1092. /** 红包币数量 */
  1093. set redMoney(value: number) {
  1094. this._redMoney = value;
  1095. gData.gameData.init_coin = true;
  1096. //gData.gameData.init_red_point = true;
  1097. gData.gameData.init_wallet_redMoney = true;
  1098. mk.event.emit('refreshCoin');
  1099. mk.data.setTAEventUser(0, 'current_redmoney_stock', this._redMoney);
  1100. }
  1101. get redMoney(): number {
  1102. return this._redMoney;
  1103. }
  1104. _signInDay = 0;
  1105. /** 累计签到次数 客户端理解 上次签到天数 */
  1106. set signInDay(value: number) {
  1107. if (this._signInDay === value) return;
  1108. this._signInDay = value;
  1109. gData.sign.init_data = true;
  1110. }
  1111. get signInDay(): number {
  1112. return this._signInDay;
  1113. }
  1114. /** 转盘次数 */
  1115. turntableTimes = 0;
  1116. /** 版本号 */
  1117. versioncfg = 0;
  1118. /** 福袋数据 */
  1119. userTuCaoInfo = 0;
  1120. /** 能免费领红包 1 表示是新人第一次产出红包币,不用看视频*/
  1121. isFirstRedMoney = 0;
  1122. //农场等级
  1123. gradeLevel = 1;
  1124. //农场等级奖励数据
  1125. farmGradeData: any = {};
  1126. //农场等级名字
  1127. farmGradeName: number = 1;
  1128. //农场经验
  1129. private farmExp = 0;
  1130. set farmExpValue(value: number) {
  1131. this.farmExp = value;
  1132. gData.gameData.init_expLevel = true;
  1133. }
  1134. get farmExpValue(): number {
  1135. return this.farmExp;
  1136. }
  1137. //提现新手数据
  1138. userNoviceWeFareInfo: any = {};
  1139. //提现记录数据
  1140. redMoneyCashPayRecordList = null;
  1141. //任务红;
  1142. userFarmTaskInfo = null;
  1143. getRedMoneyCashOutTimesByIndex(index: number): number {
  1144. if (this.redMoneyCashPayRecordList) {
  1145. for (let i = 0; i != this.redMoneyCashPayRecordList.length; ++i) {
  1146. if (index === this.redMoneyCashPayRecordList[i].index) {
  1147. return this.redMoneyCashPayRecordList[i].frequency;
  1148. }
  1149. }
  1150. }
  1151. return 0;
  1152. }
  1153. /** ABTest分组id */
  1154. groupCode = 0;
  1155. //加速剩余次数
  1156. speedUpLeftTimes = 0;
  1157. /** 农场任务完成次数 */
  1158. completeFarmTaskTimes = 0;
  1159. }
  1160. /**
  1161. * 奖励状态
  1162. */
  1163. export enum RewardState {
  1164. /** 已领取 */
  1165. none = 1,
  1166. /** 未解锁 */
  1167. lock = 2,
  1168. /** 可领取 */
  1169. unlock = 3
  1170. }
  1171. /**
  1172. * 奖励类型
  1173. */
  1174. export enum RewardType {
  1175. /** 红包币 */
  1176. redBag = 1,
  1177. /** 毛币 */
  1178. rmb = 2,
  1179. /** 金猪币 */
  1180. pigRmb = 3,
  1181. /** 生产次数 */
  1182. productTimes = 4,
  1183. }
  1184. /**
  1185. * 音频路径
  1186. */
  1187. export enum AUDIO_TYPE {
  1188. /**主界面背景音乐*/
  1189. bgm = 'bgm',
  1190. /**打开存钱罐界面播放一次*/
  1191. pigBank = 'pigBank',
  1192. /**关卡玩法背景音乐*/
  1193. missionBg = 'missionBg',
  1194. /**红包币领取界面关闭音效*/
  1195. rewardClose = 'rewardClose',
  1196. /**红包币领取界面开启音效*/
  1197. rewardOpen = 'rewardOpen',
  1198. /**红包界面打开音效*/
  1199. reward = 'reward',
  1200. /**提现到账界面打开播放一次*/
  1201. receiptNotice = 'receiptNotice',
  1202. /**通用按钮点击音效 */
  1203. button = 'button',
  1204. /**转盘转动音效*/
  1205. turnableplay = 'turnableplay',
  1206. /**转盘转动音效*/
  1207. turnplateDrawEnd = 'turnplateDrawEnd',
  1208. /**主页背景音乐 */
  1209. music_startBg = "music_startBg",
  1210. /**游戏背景音乐 */
  1211. music_gameBg = "music_gameBg",
  1212. /**按钮点击 */
  1213. ef_button_click = "ef_button_click",
  1214. /**红包打开 */
  1215. ef_redPacket_open = "ef_redPacket_open",
  1216. /**红包来了音效 */
  1217. ef_redPacket_come = "ef_redPacket_come",
  1218. /**消除4个 */
  1219. ef_bonus4 = "ef_bonus4",
  1220. /**消除5个 */
  1221. ef_bonus5 = "ef_bonus5",
  1222. /**消除6个 */
  1223. ef_bonus6 = "ef_bonus6",
  1224. /**消除7个 */
  1225. ef_bonus7 = "ef_bonus7",
  1226. /**消除8个 */
  1227. ef_bonus8 = "ef_bonus8",
  1228. /**普通消除音效 */
  1229. ef_eliminate = "ef_eliminate",
  1230. /**bouns消除音效 */
  1231. ef_eliminate_bonus = "ef_eliminate_bonus",
  1232. /**胜利音效 */
  1233. ef_win = "ef_win",
  1234. /**锤子 */
  1235. ef_change = "ef_change",
  1236. /**刷新 */
  1237. ef_refresh = "ef_refresh",
  1238. /**飞翔 */
  1239. ef_fly = "ef_fly",
  1240. /**关闭按钮音效*/
  1241. closeButton = "closeButton",
  1242. //红包界面打开
  1243. congratulations = 'congratulations',
  1244. //红包飞音效
  1245. redmoney = 'redmoney'
  1246. }
  1247. /** ECPM */
  1248. type ADShowCfg = {
  1249. average_ecpm: number,
  1250. insert_probability: number,
  1251. is_show_banner: number,
  1252. is_show_inter: number,
  1253. }
  1254. /**事件类型 */
  1255. export enum EVENT_TYPE {
  1256. BACK_WxAuth = "BACK_WxAuth",
  1257. UPDATE_CashNum = "UPDATE_CashNum",
  1258. }
  1259. /** 数据事件Id */
  1260. export enum DataEventId {
  1261. /** 点击 */
  1262. guide = "guide",
  1263. /** 点击跳过 */
  1264. guideSkip = "guideSkip",
  1265. /** 按钮点击 */
  1266. button_click = "button_click",
  1267. /** 看视频 */
  1268. video_init = "video_init",
  1269. /** 看视频完成 */
  1270. video_end = "video_end",
  1271. /** 成功拉取全屏视频 */
  1272. interstitial2_init = "interstitial2_init",
  1273. /** 广告点击 */
  1274. Ad_click = "Ad_click",
  1275. /** 全屏视频完成 */
  1276. interstitial2_end = "interstitial2_end",
  1277. /** 福袋功能 */
  1278. fudaiFunction = "fudaiFunction",
  1279. /** 互推功能 */
  1280. hutuiFunction = "hutuiFunction",
  1281. /** 激励视频ecpm */
  1282. ad_videoEcpm = 'ad_video',
  1283. /** 开屏ecpm */
  1284. ad_openEcpm = 'ad_open',
  1285. /** 提现 */
  1286. Sundry = 'Sundry',
  1287. /** 加载 */
  1288. loading = 'loading'
  1289. }
  1290. /** 视频广告类型 */
  1291. export enum VideoAdType {
  1292. video_init_1 = '农场加等级经验',
  1293. video_init_2 = '提现-加进度',
  1294. video_init_3 = '提现-加现金',
  1295. video_init_4 = '签到',
  1296. video_init_5 = '抽奖',
  1297. video_init_6 = '图鉴领奖',
  1298. video_init_7 = '消灭害虫',
  1299. video_init_8 = '恢复健康',
  1300. video_init_9 = '恢复供电',
  1301. video_init_10 = '山羊红包',
  1302. video_init_11 = '拓建',
  1303. video_init_12 = '收获',
  1304. video_init_13 = '飘浮红包',
  1305. video_init_14 = '全体加速',
  1306. video_init_15 = '福利加进度',
  1307. video_init_16 = '生产加次数',
  1308. video_init_17 = '点击生产按钮',
  1309. video_init_18 = '离开游戏领红包',
  1310. video_init_19 = '定时弹出红包',
  1311. video_init_20 = '插队',
  1312. }
  1313. export enum InterFullAdType {
  1314. interstitial2_init_1 = '点击红包的关闭按钮',
  1315. interstitial2_init_2 = '普通收获',
  1316. interstitial2_init_3 = '点击鸟和狗'
  1317. }
  1318. export enum InterAdType {
  1319. interstitial1_click_1 = '恭喜发财红包弹出后',
  1320. interstitial1_click_2 = '恭喜获得弹窗弹出后',
  1321. interstitial1_click_3 = '生虫/生病/停电弹出后'
  1322. }
  1323. export enum BannerAdType {
  1324. banner_click_1 = '恭喜获得弹窗弹出后',
  1325. banner_click_2 = '任务红包',
  1326. banner_click_3 = '恭喜发财红包',
  1327. banner_click_4 = '图鉴',
  1328. banner_click_5 = '全体加速',
  1329. banner_click_6 = '收获弹窗',
  1330. banner_click_7 = '拓建弹窗',
  1331. banner_click_8 = '三个恢复弹窗',
  1332. banner_click_9 = '抽奖'
  1333. }
  1334. export enum ExpAddType {
  1335. EAT_video = 1,
  1336. EAT_harvest = 2,
  1337. EAT_others = 3,
  1338. }
  1339. export enum FarmState {
  1340. Lock,
  1341. CanUnlock,
  1342. Empty,
  1343. Growing,
  1344. Ripe,
  1345. Sick
  1346. }
  1347. export enum PastureState {
  1348. Lock,
  1349. Empty,
  1350. Growing,
  1351. Ripe,
  1352. Sick
  1353. }
  1354. export enum ProductType {
  1355. nzw = '农作物',
  1356. dw = '动物',
  1357. bmhc = '爆米花厂',
  1358. gdp = '糕点铺',
  1359. ztc = '制糖厂',
  1360. lrc = '炼乳厂',
  1361. gfmg = '功夫面馆',
  1362. kcd = '快餐店'
  1363. }
  1364. /** 动物状态 */
  1365. export enum AnimalState {
  1366. Hanger,
  1367. Eat,
  1368. Wait
  1369. }
  1370. export enum FactroyState {
  1371. Lock,
  1372. Empty,
  1373. Producting,
  1374. Ripe,
  1375. Sick
  1376. }