GameData.ts 47 KB

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