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