GameData.ts 47 KB

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