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