GameData.ts 45 KB

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