GameData.ts 46 KB

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