GameData.ts 48 KB

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