GameData.ts 47 KB

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