GameData.ts 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455
  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. /**
  65. * 初始化游戏数据:网络配置信息,用户信息
  66. * @returns
  67. */
  68. public async init() {
  69. let data: any = { "versionCode": gData.appData.version };
  70. let response = await mk.http.sendData('getAllConfigInfo', data);
  71. if (response.errcode != 0) {
  72. if (response.errcode == -10003 || response.errcode == -20003) {
  73. //清除缓存
  74. gData.loginData.reload();
  75. }
  76. return;
  77. }
  78. mk.console.logSingle("getAllConfigInfo", response.data);
  79. this.initConfigs(response.data);
  80. //初始化topon
  81. mk.ad.init();
  82. data = {};
  83. response = await mk.http.sendData('getInfoCrypt', data);
  84. if (response.errcode != 0) {
  85. return;
  86. }
  87. mk.console.logSingle("getInfoCrypt", response.data);
  88. this.initPlayerProp(response.data)
  89. this.initProps(response.data.gameUserData);
  90. data = {};
  91. response = await mk.http.sendData('user/adShowConfig', data);
  92. if (response.errcode != 0) {
  93. return;
  94. }
  95. this.adShowConfig = response.data;
  96. mk.console.logSingle("user/adShowConfig", response.data);
  97. gData.adData.initEcpmData();
  98. // data = {};
  99. // response = await mk.http.sendData('noviceWeFare/getNoviceWeFareInfo', data);
  100. // if (response.errcode != 0) {
  101. // return;
  102. // }
  103. // this.playerProp.userTuCaoInfo = response.data.userWelFareTaskInfo;
  104. // mk.console.logSingle("welFare/getUserWelFareTaskInfo", response.data);
  105. gData.guideData.init();
  106. gData.guideWeakData.init();
  107. gData.moduleData.forEach(element => {
  108. element.init();
  109. });
  110. this.dataFinish = true;
  111. }
  112. private initConfigs(data) {
  113. // console.log('config ', data);
  114. this.configs = data;
  115. this.funOpenData = this.configs.ServerConfig.Functionswitch.split(",");
  116. //从服务器解析配置
  117. this.setProductMapFromJson();
  118. }
  119. /**
  120. * 初始化玩家数据
  121. */
  122. private initPlayerProp(res_data) {
  123. this.playerProp = new PlayerProp();
  124. this.playerProp.cashIndex = res_data.cashIndex;
  125. this.playerProp.gameUserData = res_data.gameUserData;
  126. this.playerProp.isSignInToday = res_data.isSignInToday;
  127. this.playerProp.isWithdrawable = res_data.isWithdrawable;
  128. this.playerProp.lastTime = res_data.lastTime;
  129. this.playerProp.loginDays = res_data.loginDays;
  130. this.playerProp.newPlayer = res_data.newPlayer;
  131. this.playerProp.initPiggyBank(res_data.piggyBank);
  132. this.playerProp.piggyBankCashTimes = res_data.piggyBankCashTimes;
  133. this.playerProp.redMoney = res_data.redMoney == null ? 0 : res_data.redMoney;
  134. this.playerProp.signInDay = res_data.signInDay;
  135. this.playerProp.totalPiggyBankCashTimes = res_data.totalPiggyBankCashTimes;
  136. this.playerProp.turntableTimes = res_data.turntableTimes;
  137. this.playerProp.versioncfg = res_data.versioncfg;
  138. this.playerProp.isFirstRedMoney = res_data.isFirstRedMoney;
  139. gData.adData.watchNumToday = res_data.dayVideoTimesForRedMoney == null ? 0 : res_data.dayVideoTimesForRedMoney;
  140. this.playerProp.gradeLevel = res_data.farmLevel
  141. this.playerProp.userTuCaoInfo = res_data.userWelFareTaskInfo;
  142. this.playerProp.farmExpValue = res_data.userExp;
  143. this.playerProp.farmGradeData = res_data.userFarmGrageRewardInfo;
  144. this.playerProp.userNoviceWeFareInfo = res_data.userNoviceWeFareInfo;
  145. this.playerProp.redMoneyCashPayRecordList = res_data.redMoneyCashPayRecordList;
  146. mk.console.logSingle('userNoviceWeFareInfo==>', res_data.userNoviceWeFareInfo);
  147. //mk.console.logSingle('redMoneyCashPayRecordList==>', res_data.redMoneyCashPayRecordList);
  148. this.playerProp.userFarmTaskInfo = res_data.userFarmTaskInfo;
  149. this.playerProp.speedUpLeftTimes = res_data.speedUpLeftTimes;
  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. turnable_leftTimes = 20,
  903. }
  904. /**
  905. * 玩家数据
  906. */
  907. class PlayerProp {
  908. /** 自定义不需要校验的数据 */
  909. gameUserData = 0;
  910. _isSignInToday = 0;
  911. /**
  912. * 今日是否有签到
  913. * - 0 未签到,表示可以签到
  914. * - 1 有签到,表示不可签到
  915. */
  916. set isSignInToday(value: number) {
  917. this._isSignInToday = value;
  918. gData.sign.init_data = true;
  919. gData.gameData.init_red_point = true;
  920. }
  921. get isSignInToday(): number {
  922. return this._isSignInToday;
  923. }
  924. private _piggyBank: number = 0;
  925. /** 存钱罐存款 */
  926. set piggyBank(value: number) {
  927. if (this._piggyBank === value) return;
  928. if (gData.gameData.playerProp.isWithdrawable && value > 0) return;// 存钱罐可提现状态,不能增加存钱罐金额
  929. this._piggyBank = value;
  930. gData.gameData.init_coin = true;
  931. gData.pigbank.init_data = true;
  932. gData.gameData.init_red_point = true;
  933. }
  934. get piggyBank(): number {
  935. return this._piggyBank;
  936. }
  937. /** 初始化 */
  938. initPiggyBank(v) {
  939. this._piggyBank = v;
  940. }
  941. _isWithdrawable = 0;
  942. /**
  943. * 存钱罐能否提现
  944. * - 0 不能提现
  945. * - 1 能提现
  946. */
  947. set isWithdrawable(value: number) {
  948. if (this._isWithdrawable != value) {
  949. this._isWithdrawable = value;
  950. gData.pigbank.init_data = true;
  951. gData.gameData.init_red_point = true;
  952. }
  953. }
  954. get isWithdrawable(): number {
  955. return this._isWithdrawable;
  956. }
  957. /** 存钱罐每日提现次数 */
  958. piggyBankCashTimes = 0;
  959. /** 累计存钱罐每日提现次数 */
  960. totalPiggyBankCashTimes = 0;
  961. /** 提现进度 */
  962. cashIndex = 0;
  963. /** 上次登录时间 */
  964. lastTime = 0;
  965. /** 登录天数 */
  966. loginDays = 0;
  967. newPlayer = 0;
  968. private _redMoney: number = 0;
  969. /** 红包币数量 */
  970. set redMoney(value: number) {
  971. this._redMoney = value;
  972. gData.gameData.init_coin = true;
  973. //gData.gameData.init_red_point = true;
  974. gData.gameData.init_wallet_redMoney = true;
  975. }
  976. get redMoney(): number {
  977. return this._redMoney;
  978. }
  979. _signInDay = 0;
  980. /** 累计签到次数 客户端理解 上次签到天数 */
  981. set signInDay(value: number) {
  982. if (this._signInDay === value) return;
  983. this._signInDay = value;
  984. gData.sign.init_data = true;
  985. }
  986. get signInDay(): number {
  987. return this._signInDay;
  988. }
  989. /** 转盘次数 */
  990. turntableTimes = 0;
  991. /** 版本号 */
  992. versioncfg = 0;
  993. /** 福袋数据 */
  994. userTuCaoInfo = 0;
  995. /** 能免费领红包 1 表示是新人第一次产出红包币,不用看视频*/
  996. isFirstRedMoney = 0;
  997. //农场等级
  998. gradeLevel = 1;
  999. //农场等级奖励数据
  1000. farmGradeData: any = {};
  1001. //农场等级名字
  1002. farmGradeName: number = 1;
  1003. //农场经验
  1004. private farmExp = 0;
  1005. set farmExpValue(value: number) {
  1006. this.farmExp = value;
  1007. gData.gameData.init_expLevel = true;
  1008. }
  1009. get farmExpValue(): number {
  1010. return this.farmExp;
  1011. }
  1012. //提现新手数据
  1013. userNoviceWeFareInfo: any = {};
  1014. //提现记录数据
  1015. redMoneyCashPayRecordList = null;
  1016. //任务红;
  1017. userFarmTaskInfo = null;
  1018. getRedMoneyCashOutTimesByIndex(index: number): number {
  1019. if (this.redMoneyCashPayRecordList) {
  1020. for (let i = 0; i != this.redMoneyCashPayRecordList.length; ++i) {
  1021. if (index === this.redMoneyCashPayRecordList[i].index) {
  1022. return this.redMoneyCashPayRecordList[i].frequency;
  1023. }
  1024. }
  1025. }
  1026. return 0;
  1027. }
  1028. /** ABTest分组id */
  1029. groupCode = 0;
  1030. speedUpLeftTimes = 0;
  1031. }
  1032. /**
  1033. * 奖励状态
  1034. */
  1035. export enum RewardState {
  1036. /** 已领取 */
  1037. none = 1,
  1038. /** 未解锁 */
  1039. lock = 2,
  1040. /** 可领取 */
  1041. unlock = 3
  1042. }
  1043. /**
  1044. * 奖励类型
  1045. */
  1046. export enum RewardType {
  1047. /** 红包币 */
  1048. redBag = 1,
  1049. /** 毛币 */
  1050. rmb = 2,
  1051. /** 金猪币 */
  1052. pigRmb = 3,
  1053. /** 生产次数 */
  1054. productTimes = 4,
  1055. }
  1056. /**
  1057. * 音频路径
  1058. */
  1059. export enum AUDIO_TYPE {
  1060. /**主界面背景音乐*/
  1061. bgm = 'bgm',
  1062. /**打开存钱罐界面播放一次*/
  1063. pigBank = 'pigBank',
  1064. /**关卡玩法背景音乐*/
  1065. missionBg = 'missionBg',
  1066. /**红包币领取界面关闭音效*/
  1067. rewardClose = 'rewardClose',
  1068. /**红包币领取界面开启音效*/
  1069. rewardOpen = 'rewardOpen',
  1070. /**红包界面打开音效*/
  1071. reward = 'reward',
  1072. /**提现到账界面打开播放一次*/
  1073. receiptNotice = 'receiptNotice',
  1074. /**通用按钮点击音效 */
  1075. button = 'button',
  1076. /**转盘转动音效*/
  1077. turnableplay = 'turnableplay',
  1078. /**转盘转动音效*/
  1079. turnplateDrawEnd = 'turnplateDrawEnd',
  1080. /**主页背景音乐 */
  1081. music_startBg = "music_startBg",
  1082. /**游戏背景音乐 */
  1083. music_gameBg = "music_gameBg",
  1084. /**按钮点击 */
  1085. ef_button_click = "ef_button_click",
  1086. /**红包打开 */
  1087. ef_redPacket_open = "ef_redPacket_open",
  1088. /**红包来了音效 */
  1089. ef_redPacket_come = "ef_redPacket_come",
  1090. /**消除4个 */
  1091. ef_bonus4 = "ef_bonus4",
  1092. /**消除5个 */
  1093. ef_bonus5 = "ef_bonus5",
  1094. /**消除6个 */
  1095. ef_bonus6 = "ef_bonus6",
  1096. /**消除7个 */
  1097. ef_bonus7 = "ef_bonus7",
  1098. /**消除8个 */
  1099. ef_bonus8 = "ef_bonus8",
  1100. /**普通消除音效 */
  1101. ef_eliminate = "ef_eliminate",
  1102. /**bouns消除音效 */
  1103. ef_eliminate_bonus = "ef_eliminate_bonus",
  1104. /**胜利音效 */
  1105. ef_win = "ef_win",
  1106. /**锤子 */
  1107. ef_change = "ef_change",
  1108. /**刷新 */
  1109. ef_refresh = "ef_refresh",
  1110. /**飞翔 */
  1111. ef_fly = "ef_fly",
  1112. /**关闭按钮音效*/
  1113. closeButton = "closeButton",
  1114. //红包界面打开
  1115. openRedBag = 'congratulations',
  1116. //红包飞音效
  1117. redmoney = 'redmoney'
  1118. }
  1119. /** ECPM */
  1120. type ADShowCfg = {
  1121. average_ecpm: number,
  1122. insert_probability: number,
  1123. is_show_banner: number,
  1124. is_show_inter: number,
  1125. }
  1126. type PlayerInfoType = {
  1127. /** 自定义不需要校验的数据 */
  1128. gameUserData: object,
  1129. /** 今日是否有签到 */
  1130. isSignInToday: number,
  1131. /** 存钱罐存款 */
  1132. piggyBank: number,
  1133. /** 存钱罐能否提现 */
  1134. isWithdrawable: boolean,
  1135. /** 存钱罐每日提现次数 */
  1136. piggyBankCashTimes: number,
  1137. /** 累计存钱罐每日提现次数 */
  1138. totalPiggyBankCashTimes: number,
  1139. /** 提现进度 */
  1140. cashIndex: number,
  1141. /** 上次登录时间 */
  1142. lastTime: number,
  1143. /** 登录天数 */
  1144. loginDays: number,
  1145. newPlayer: Boolean,
  1146. /** 红包币数量 */
  1147. redMoney: number,
  1148. /** 累计签到次数 客户端理解 上次签到天数 */
  1149. signInDay: number,
  1150. /** 转盘次数 */
  1151. turntableTimes: number,
  1152. /** 版本号 */
  1153. versioncfg: string,
  1154. /** 福袋数据 */
  1155. userTuCaoInfo: object,
  1156. }
  1157. /**事件类型 */
  1158. export enum EVENT_TYPE {
  1159. BACK_WxAuth = "BACK_WxAuth",
  1160. UPDATE_CashNum = "UPDATE_CashNum",
  1161. }
  1162. /** 数据事件Id */
  1163. export enum DataEventId {
  1164. /** 点击 */
  1165. guide = "guide",
  1166. /** 按钮点击 */
  1167. button_click = "button_click",
  1168. /** 看视频 */
  1169. video_init = "video_init",
  1170. /** 点击视频 */
  1171. video_click = "video_click",
  1172. /** 看视频完成 */
  1173. video_end = "video_end",
  1174. /** 成功拉取全屏视频 */
  1175. interstitial2_init = "interstitial2_init",
  1176. /** 全屏视频点击 */
  1177. interstitial2_click = "interstitial2_click",
  1178. /** 全屏视频完成 */
  1179. interstitial2_end = "interstitial2_end",
  1180. /** 插屏广告内点击 */
  1181. interstitial1_click = "interstitial1_click",
  1182. /** banner点击 */
  1183. banner_click = "banner_click",
  1184. /** 开屏点击 */
  1185. splash_click = "splash_click",
  1186. /** 福袋功能 */
  1187. fudaiFunction = "fudaiFunction",
  1188. /** 互推功能 */
  1189. hutuiFunction = "hutuiFunction",
  1190. /** 激励视频ecpm */
  1191. ad_videoEcpm = 'ad_video',
  1192. /** 开屏ecpm */
  1193. ad_openEcpm = 'ad_open',
  1194. /** 提现 */
  1195. Sundry = 'Sundry'
  1196. }
  1197. /** 视频广告类型 */
  1198. export enum VideoAdType {
  1199. video_init_1 = '农场加等级经验',
  1200. video_init_2 = '提现-加进度',
  1201. video_init_3 = '提现-加现金',
  1202. video_init_4 = '签到',
  1203. video_init_5 = '抽奖',
  1204. video_init_6 = '图鉴领奖',
  1205. video_init_7 = '消灭害虫',
  1206. video_init_8 = '恢复健康',
  1207. video_init_9 = '恢复供电',
  1208. video_init_10 = '山羊红包',
  1209. video_init_11 = '拓建',
  1210. video_init_12 = '收获',
  1211. video_init_13 = '飘浮红包',
  1212. video_init_14 = '全体加速',
  1213. video_init_15 = '福利加进度',
  1214. video_init_16 = '生产加次数',
  1215. video_init_17 = '点击生产按钮',
  1216. video_init_18 = '离开游戏领红包',
  1217. video_init_19 = '定时弹出红包',
  1218. }
  1219. export enum InterFullAdType {
  1220. interstitial2_init_1 = '点击红包的关闭按钮',
  1221. interstitial2_init_2 = '普通收获',
  1222. interstitial2_init_3 = '点击鸟和狗'
  1223. }
  1224. export enum InterAdType {
  1225. interstitial1_click_1 = '恭喜发财红包弹出后',
  1226. interstitial1_click_2 = '恭喜获得弹窗弹出后',
  1227. interstitial1_click_3 = '生虫/生病/停电弹出后'
  1228. }
  1229. export enum BannerAdType {
  1230. banner_click_1 = '恭喜获得弹窗弹出后',
  1231. banner_click_2 = '任务红包',
  1232. banner_click_3 = '恭喜发财红包',
  1233. banner_click_4 = '图鉴',
  1234. banner_click_5 = '全体加速',
  1235. banner_click_6 = '收获弹窗',
  1236. banner_click_7 = '拓建弹窗',
  1237. banner_click_8 = '三个恢复弹窗',
  1238. banner_click_9 = '抽奖'
  1239. }
  1240. export enum ExpAddType {
  1241. EAT_video = 1,
  1242. EAT_harvest = 2,
  1243. }
  1244. export enum FarmState {
  1245. Lock,
  1246. CanUnlock,
  1247. Empty,
  1248. Growing,
  1249. Ripe,
  1250. Sick
  1251. }
  1252. export enum PastureState {
  1253. Lock,
  1254. Empty,
  1255. Growing,
  1256. Ripe,
  1257. Sick
  1258. }
  1259. export enum ProductType {
  1260. nzw = '农作物',
  1261. dw = '动物',
  1262. bmhc = '爆米花厂',
  1263. gdp = '糕点铺',
  1264. ztc = '制糖厂',
  1265. lrc = '炼乳厂',
  1266. gfmg = '功夫面馆',
  1267. kcd = '快餐店'
  1268. }
  1269. /** 动物状态 */
  1270. export enum AnimalState {
  1271. Hanger,
  1272. Eat,
  1273. Wait
  1274. }
  1275. export enum FactroyState {
  1276. Lock,
  1277. Empty,
  1278. Producting,
  1279. Ripe,
  1280. Sick
  1281. }