GameData.ts 44 KB

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