GameData.ts 47 KB

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