GameData.ts 45 KB

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