GameData.ts 45 KB

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