GameData.ts 48 KB

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