GameData.ts 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485
  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. mk.data.setTAUserID(gData.loginData.uin);
  161. if (gData.loginData.isFirstIn) {
  162. gData.loginData.isFirstIn = false;
  163. mk.data.setTAEventRegister();
  164. mk.data.sendDataEvent('ABTest', `触发${this.playerProp.groupCode}方案`);
  165. //注册时版本号
  166. mk.data.setTAEventUserStr(0, 'regtime_app_id', gData.appData.appVersion);
  167. }
  168. //当前版本号
  169. mk.data.setTAEventUserStr(0, 'now_app_id', gData.appData.appVersion);
  170. //渠道号
  171. mk.data.setTAEventUserStr(0, 'channel_id', gData.appData.umengChannel);
  172. //test
  173. }
  174. /**
  175. * 保存单个数据
  176. */
  177. public async setProp(key: GameProp, value: any) {
  178. let data = {
  179. key: key + '',
  180. value: value
  181. };
  182. this.props.set(key, value);
  183. await mk.http.sendData('savePlayerProp', data);
  184. this.savePropFinish = true;
  185. }
  186. /**
  187. * 保存多个数据
  188. */
  189. public async setProps(arr: { key: GameProp, value: any }[]) {
  190. let needProp = {};
  191. for (let i = 0; i < arr.length; i++) {
  192. needProp[arr[i].key + ''] = arr[i].value;
  193. }
  194. let data = {
  195. needProp: needProp
  196. };
  197. for (let i = 0; i < arr.length; i++) {
  198. this.props.set(arr[i].key, arr[i].value);
  199. }
  200. await mk.http.sendData('saveAllPlayerProp', data);
  201. this.savePropsFinish = true;
  202. }
  203. /** 获取属性 */
  204. public getProp(key: GameProp): any {
  205. if (this.props == null) {
  206. return 0;
  207. }
  208. let value = this.props.get(key);
  209. return value;
  210. }
  211. /**
  212. * 向服务器请求所有属性后更新
  213. */
  214. public async getAllProps() {
  215. let response = await mk.http.sendData('getAllPlayerProp', {});
  216. if (response.errcode != 0) {
  217. return;
  218. }
  219. this.initProps(response.data);
  220. this.getPropsFnish = true;
  221. }
  222. private initProps(data) {
  223. if (data == null) {
  224. return;
  225. }
  226. for (let key in data) {
  227. this.props.set(parseInt(key), data[key]);
  228. }
  229. this.setFramDataMapByServer();
  230. this.setPastureDataMapByServer();
  231. this.setFactoryDataMapByServer();
  232. this.initSetMaxProduct();
  233. this.initProductTimes();
  234. this.initLeftTimes();
  235. this.initFarmMapGetRewardData();
  236. // let isNewTask = this.getProp(GameProp.redBagTaskRefresh);
  237. // if (isNewTask != undefined) {
  238. // this.init_redBagTask = isNewTask;
  239. // }
  240. }
  241. private initLeftTimes() {
  242. let lefttimes = this.getProp(GameProp.leftTimes);
  243. if (lefttimes == undefined) {
  244. this.leftTimes = parseInt(this.configs.ServerConfig.FreeProduction);
  245. this.setProp(GameProp.leftTimes, this.leftTimes);
  246. }
  247. else {
  248. this.leftTimes = lefttimes;
  249. }
  250. this.maxTimes = parseInt(this.configs.ServerConfig.ProductionMax);
  251. this.ProductionRecovery = parseInt(this.configs.ServerConfig.ProductionRecovery);
  252. // //test
  253. // this.leftTimes = 1;
  254. // this.maxTimes = 20;
  255. // this.ProductionRecovery = 1;
  256. }
  257. /** 增加减少生产次数
  258. * @param add 增减变量
  259. */
  260. public changeLeftTimes(add) {
  261. gData.gameData.leftTimes += add;
  262. gData.gameData.leftTimes = (gData.gameData.leftTimes > gData.gameData.maxTimes ? gData.gameData.maxTimes : gData.gameData.leftTimes);
  263. if (gData.gameData.leftTimes < 0) {
  264. gData.gameData.leftTimes = 0;
  265. }
  266. gData.gameData.setProp(GameProp.leftTimes, gData.gameData.leftTimes);
  267. gData.gameData.init_leftTimes = true;
  268. }
  269. //图鉴领取数据
  270. private _farmMapRewardData = [];
  271. public getFarmMapRewardState(index) {
  272. if (index.i < this._farmMapRewardData.length) {
  273. if (index.j < this._farmMapRewardData[index.i].length) {
  274. return this._farmMapRewardData[index.i][index.j];
  275. }
  276. }
  277. return 1;
  278. }
  279. public setFarmMapRewardState(index, state) {
  280. if (index.i < this._farmMapRewardData.length) {
  281. if (index.j < this._farmMapRewardData[index.i].length) {
  282. this._farmMapRewardData[index.i][index.j] = state;
  283. this.setProp(GameProp.farmMapGetRewardData, this._farmMapRewardData);
  284. }
  285. }
  286. }
  287. private initFarmMapGetRewardData() {
  288. this._farmMapRewardData = this.getProp(GameProp.farmMapGetRewardData);
  289. if (!this._farmMapRewardData) {
  290. this._farmMapRewardData = [];
  291. }
  292. let needSync = false;
  293. let index = 0;
  294. this._productTypeMap.forEach((value, key) => {
  295. if (this._farmMapRewardData.length <= index) {
  296. let len = value.length;
  297. let arr = [];
  298. for (let i = 0; i != len; ++i) {
  299. arr.push(0);
  300. }
  301. this._farmMapRewardData.push(arr);
  302. needSync = true;
  303. console.log("-----add 数组数据")
  304. } else {
  305. let data = this._farmMapRewardData[index];
  306. let len = value.length;
  307. for (let i = 0; i != len; ++i) {
  308. if (i >= data.length) {
  309. data.push(0);
  310. needSync = true;
  311. console.log("-----add 单个数据")
  312. }
  313. }
  314. }
  315. ++index;
  316. });
  317. if (needSync) {
  318. this.setProp(GameProp.farmMapGetRewardData, this._farmMapRewardData);
  319. }
  320. }
  321. /** 是否是新用户 */
  322. public isNewPlayer(): boolean {
  323. let v = this.getProp(GameProp.newPlayer);
  324. return v == 0;
  325. }
  326. //*********** ================= 农场数据 ================== */
  327. /** 农田数据 服务器数据 */
  328. private _farmData = [];
  329. /** 农田字典 本地数据,方便操作*/
  330. private _farmDataMap: Map<number, any> = new Map();
  331. //刷新农田
  332. public needFreshArr = [];
  333. /** 随机获取可种植物品 */
  334. getRandomPlantConfig() {
  335. let id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
  336. return this.getProductMap(id);
  337. }
  338. /** 随机获取可生产产品 */
  339. getRandomFactoryConfig(configID) {
  340. let tab = gData.gameData.getTabByConfigID(configID);
  341. let arr = this.getProductArrByType(tab);
  342. let max = this.getMaxProduct(tab);
  343. let canArr = [];
  344. let len = arr.length;
  345. for (var i = 0; i < len; i++) {
  346. if (arr[i].picture <= max) {
  347. canArr.push(arr[i].picture);
  348. if (arr[i].picture == max) {
  349. break;
  350. }
  351. }
  352. }
  353. let index = Util.rnd(0, canArr.length - 1);
  354. let id = canArr[index];
  355. return this.getProductMap(id);
  356. }
  357. /** 自动生产选中下一个 */
  358. setNextProduct(sel = true) {
  359. if (this.nextMake) {
  360. return;
  361. }
  362. let next = gData.farmSystem.selectNextFarm(sel);
  363. if (!next) {
  364. let next1 = gData.pastureSystem.nextPasture();
  365. if (!next1) {
  366. let next2 = gData.factorySystem.nextFactory();
  367. if (!next2) {
  368. this.nextType = 0;
  369. }
  370. else {
  371. this.nextType = 3;
  372. }
  373. }
  374. else {
  375. this.nextType = 2;
  376. }
  377. }
  378. else {
  379. this.nextType = 1;
  380. }
  381. this.init_makeInfo = true;
  382. }
  383. hasFirstCheck = false;
  384. firstCheckNext() {
  385. if (!this.hasFirstCheck && gData.farmSystem.farms.length >= 18
  386. && gData.pastureSystem.pastureIcons.length >= 3 && gData.factorySystem.factoryIcons.length >= 6) {
  387. this.hasFirstCheck = true;
  388. Util.objSortByKey(gData.farmSystem.farms, 'sortID');
  389. Util.objSortByKey(gData.pastureSystem.pastureIcons, 'sortID');
  390. Util.objSortByKey(gData.factorySystem.factoryIcons, 'sortID');
  391. gData.gameData.setNextProduct(false);
  392. }
  393. }
  394. async makeProduct() {
  395. let flyRed = true;
  396. switch (this.nextType) {
  397. case 0:
  398. mk.tip.pop('农场已满,无法继续生产');
  399. flyRed = false;
  400. break;
  401. case 1:
  402. gData.farmSystem.btnMake();
  403. this.nextMake = null;
  404. this.setNextProduct(false);
  405. gData.adData.checkPopRed();
  406. await this.updateNewTaskProgress();
  407. break;
  408. case 2:
  409. gData.pastureSystem.btnMake();
  410. this.nextMake = null;
  411. this.setNextProduct(false);
  412. gData.adData.checkPopRed();
  413. await this.updateNewTaskProgress();
  414. break;
  415. case 3:
  416. gData.factorySystem.btnMake();
  417. this.nextMake = null;
  418. this.setNextProduct(false);
  419. gData.adData.checkPopRed();
  420. await this.updateNewTaskProgress();
  421. break;
  422. }
  423. return flyRed;
  424. }
  425. public async updateNewTaskProgress(isNeedRefresh = false) {
  426. // if (gData.gameData.init_redBagTask) {
  427. // return;
  428. // }
  429. if (this.playerProp.userFarmTaskInfo) {
  430. let com = this.playerProp.userFarmTaskInfo.completeCount;
  431. let count = this.playerProp.userFarmTaskInfo.taskCount;
  432. if (com >= count)
  433. return;
  434. }
  435. let data = {};
  436. let response = await mk.http.sendData('farmTask/updateUserFarmTaskInfo', data);
  437. mk.console.logSingle('refrehTask=>', response);
  438. if (response.errcode != 0) {
  439. return null;
  440. }
  441. this.playerProp.userFarmTaskInfo = response.data.userFarmTaskInfo;
  442. if (this.playerProp.userFarmTaskInfo.completeCount >= this.playerProp.userFarmTaskInfo.taskCount) {
  443. mk.guide.open(5);
  444. }
  445. if(isNeedRefresh)
  446. {
  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.gradeLevel >= 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.gradeLevel >= 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. /**
  1056. * 奖励状态
  1057. */
  1058. export enum RewardState {
  1059. /** 已领取 */
  1060. none = 1,
  1061. /** 未解锁 */
  1062. lock = 2,
  1063. /** 可领取 */
  1064. unlock = 3
  1065. }
  1066. /**
  1067. * 奖励类型
  1068. */
  1069. export enum RewardType {
  1070. /** 红包币 */
  1071. redBag = 1,
  1072. /** 毛币 */
  1073. rmb = 2,
  1074. /** 金猪币 */
  1075. pigRmb = 3,
  1076. /** 生产次数 */
  1077. productTimes = 4,
  1078. }
  1079. /**
  1080. * 音频路径
  1081. */
  1082. export enum AUDIO_TYPE {
  1083. /**主界面背景音乐*/
  1084. bgm = 'bgm',
  1085. /**打开存钱罐界面播放一次*/
  1086. pigBank = 'pigBank',
  1087. /**关卡玩法背景音乐*/
  1088. missionBg = 'missionBg',
  1089. /**红包币领取界面关闭音效*/
  1090. rewardClose = 'rewardClose',
  1091. /**红包币领取界面开启音效*/
  1092. rewardOpen = 'rewardOpen',
  1093. /**红包界面打开音效*/
  1094. reward = 'reward',
  1095. /**提现到账界面打开播放一次*/
  1096. receiptNotice = 'receiptNotice',
  1097. /**通用按钮点击音效 */
  1098. button = 'button',
  1099. /**转盘转动音效*/
  1100. turnableplay = 'turnableplay',
  1101. /**转盘转动音效*/
  1102. turnplateDrawEnd = 'turnplateDrawEnd',
  1103. /**主页背景音乐 */
  1104. music_startBg = "music_startBg",
  1105. /**游戏背景音乐 */
  1106. music_gameBg = "music_gameBg",
  1107. /**按钮点击 */
  1108. ef_button_click = "ef_button_click",
  1109. /**红包打开 */
  1110. ef_redPacket_open = "ef_redPacket_open",
  1111. /**红包来了音效 */
  1112. ef_redPacket_come = "ef_redPacket_come",
  1113. /**消除4个 */
  1114. ef_bonus4 = "ef_bonus4",
  1115. /**消除5个 */
  1116. ef_bonus5 = "ef_bonus5",
  1117. /**消除6个 */
  1118. ef_bonus6 = "ef_bonus6",
  1119. /**消除7个 */
  1120. ef_bonus7 = "ef_bonus7",
  1121. /**消除8个 */
  1122. ef_bonus8 = "ef_bonus8",
  1123. /**普通消除音效 */
  1124. ef_eliminate = "ef_eliminate",
  1125. /**bouns消除音效 */
  1126. ef_eliminate_bonus = "ef_eliminate_bonus",
  1127. /**胜利音效 */
  1128. ef_win = "ef_win",
  1129. /**锤子 */
  1130. ef_change = "ef_change",
  1131. /**刷新 */
  1132. ef_refresh = "ef_refresh",
  1133. /**飞翔 */
  1134. ef_fly = "ef_fly",
  1135. /**关闭按钮音效*/
  1136. closeButton = "closeButton",
  1137. //红包界面打开
  1138. congratulations = 'congratulations',
  1139. //红包飞音效
  1140. redmoney = 'redmoney'
  1141. }
  1142. /** ECPM */
  1143. type ADShowCfg = {
  1144. average_ecpm: number,
  1145. insert_probability: number,
  1146. is_show_banner: number,
  1147. is_show_inter: number,
  1148. }
  1149. type PlayerInfoType = {
  1150. /** 自定义不需要校验的数据 */
  1151. gameUserData: object,
  1152. /** 今日是否有签到 */
  1153. isSignInToday: number,
  1154. /** 存钱罐存款 */
  1155. piggyBank: number,
  1156. /** 存钱罐能否提现 */
  1157. isWithdrawable: boolean,
  1158. /** 存钱罐每日提现次数 */
  1159. piggyBankCashTimes: number,
  1160. /** 累计存钱罐每日提现次数 */
  1161. totalPiggyBankCashTimes: number,
  1162. /** 提现进度 */
  1163. cashIndex: number,
  1164. /** 上次登录时间 */
  1165. lastTime: number,
  1166. /** 登录天数 */
  1167. loginDays: number,
  1168. newPlayer: Boolean,
  1169. /** 红包币数量 */
  1170. redMoney: number,
  1171. /** 累计签到次数 客户端理解 上次签到天数 */
  1172. signInDay: number,
  1173. /** 转盘次数 */
  1174. turntableTimes: number,
  1175. /** 版本号 */
  1176. versioncfg: string,
  1177. /** 福袋数据 */
  1178. userTuCaoInfo: object,
  1179. }
  1180. /**事件类型 */
  1181. export enum EVENT_TYPE {
  1182. BACK_WxAuth = "BACK_WxAuth",
  1183. UPDATE_CashNum = "UPDATE_CashNum",
  1184. }
  1185. /** 数据事件Id */
  1186. export enum DataEventId {
  1187. /** 点击 */
  1188. guide = "guide",
  1189. /** 按钮点击 */
  1190. button_click = "button_click",
  1191. /** 看视频 */
  1192. video_init = "video_init",
  1193. /** 点击视频 */
  1194. video_click = "video_click",
  1195. /** 看视频完成 */
  1196. video_end = "video_end",
  1197. /** 成功拉取全屏视频 */
  1198. interstitial2_init = "interstitial2_init",
  1199. /** 全屏视频点击 */
  1200. interstitial2_click = "interstitial2_click",
  1201. /** 全屏视频完成 */
  1202. interstitial2_end = "interstitial2_end",
  1203. /** 插屏广告内点击 */
  1204. interstitial1_click = "interstitial1_click",
  1205. /** banner点击 */
  1206. banner_click = "banner_click",
  1207. /** 开屏点击 */
  1208. splash_click = "splash_click",
  1209. /** 福袋功能 */
  1210. fudaiFunction = "fudaiFunction",
  1211. /** 互推功能 */
  1212. hutuiFunction = "hutuiFunction",
  1213. /** 激励视频ecpm */
  1214. ad_videoEcpm = 'ad_video',
  1215. /** 开屏ecpm */
  1216. ad_openEcpm = 'ad_open',
  1217. /** 提现 */
  1218. Sundry = 'Sundry'
  1219. }
  1220. /** 视频广告类型 */
  1221. export enum VideoAdType {
  1222. video_init_1 = '农场加等级经验',
  1223. video_init_2 = '提现-加进度',
  1224. video_init_3 = '提现-加现金',
  1225. video_init_4 = '签到',
  1226. video_init_5 = '抽奖',
  1227. video_init_6 = '图鉴领奖',
  1228. video_init_7 = '消灭害虫',
  1229. video_init_8 = '恢复健康',
  1230. video_init_9 = '恢复供电',
  1231. video_init_10 = '山羊红包',
  1232. video_init_11 = '拓建',
  1233. video_init_12 = '收获',
  1234. video_init_13 = '飘浮红包',
  1235. video_init_14 = '全体加速',
  1236. video_init_15 = '福利加进度',
  1237. video_init_16 = '生产加次数',
  1238. video_init_17 = '点击生产按钮',
  1239. video_init_18 = '离开游戏领红包',
  1240. video_init_19 = '定时弹出红包',
  1241. }
  1242. export enum InterFullAdType {
  1243. interstitial2_init_1 = '点击红包的关闭按钮',
  1244. interstitial2_init_2 = '普通收获',
  1245. interstitial2_init_3 = '点击鸟和狗'
  1246. }
  1247. export enum InterAdType {
  1248. interstitial1_click_1 = '恭喜发财红包弹出后',
  1249. interstitial1_click_2 = '恭喜获得弹窗弹出后',
  1250. interstitial1_click_3 = '生虫/生病/停电弹出后'
  1251. }
  1252. export enum BannerAdType {
  1253. banner_click_1 = '恭喜获得弹窗弹出后',
  1254. banner_click_2 = '任务红包',
  1255. banner_click_3 = '恭喜发财红包',
  1256. banner_click_4 = '图鉴',
  1257. banner_click_5 = '全体加速',
  1258. banner_click_6 = '收获弹窗',
  1259. banner_click_7 = '拓建弹窗',
  1260. banner_click_8 = '三个恢复弹窗',
  1261. banner_click_9 = '抽奖'
  1262. }
  1263. export enum ExpAddType {
  1264. EAT_video = 1,
  1265. EAT_harvest = 2,
  1266. }
  1267. export enum FarmState {
  1268. Lock,
  1269. CanUnlock,
  1270. Empty,
  1271. Growing,
  1272. Ripe,
  1273. Sick
  1274. }
  1275. export enum PastureState {
  1276. Lock,
  1277. Empty,
  1278. Growing,
  1279. Ripe,
  1280. Sick
  1281. }
  1282. export enum ProductType {
  1283. nzw = '农作物',
  1284. dw = '动物',
  1285. bmhc = '爆米花厂',
  1286. gdp = '糕点铺',
  1287. ztc = '制糖厂',
  1288. lrc = '炼乳厂',
  1289. gfmg = '功夫面馆',
  1290. kcd = '快餐店'
  1291. }
  1292. /** 动物状态 */
  1293. export enum AnimalState {
  1294. Hanger,
  1295. Eat,
  1296. Wait
  1297. }
  1298. export enum FactroyState {
  1299. Lock,
  1300. Empty,
  1301. Producting,
  1302. Ripe,
  1303. Sick
  1304. }