GameData.ts 47 KB

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