GameData.ts 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996
  1. import Util from "../../before/util/Util";
  2. import FunBtns from "../game/FunBtns";
  3. import Game from "../game/Game";
  4. import { StorageKey } from "./StorageData";
  5. /**
  6. * @description 游戏核心玩法数据
  7. * @author 邹勇
  8. */
  9. export class GameData {
  10. public dataFinish: boolean = false;
  11. public savePropFinish: boolean = false;
  12. public savePropsFinish: boolean = false;
  13. public getPropsFnish: boolean = false;
  14. //是否触摸屏幕
  15. public isTouchScreen: boolean = false;
  16. public configs: any = {};
  17. public adShowConfig: ADShowCfg;
  18. /** 功能开启 */
  19. public funOpenData: string[] = [];
  20. public playerProp: PlayerProp = null;
  21. /** 标志位:刷新主界面货币 */
  22. public init_coin: boolean = false;
  23. public addHb: number = 0;
  24. public updatePiggyBankValue: boolean = false;
  25. /** 标志位:刷新主界面头像 */
  26. public init_head: boolean = false;
  27. public init_add: boolean = false;
  28. /** 标志位:刷新主界面红点 */
  29. public init_red_point: boolean = true;
  30. //标志位,刷新提现界面的红包币
  31. public init_wallet_redMoney = false;
  32. /** 属性存储字典 */
  33. public props: Map<number, any> = new Map<number, any>();
  34. public pools = [
  35. { url: "game/prefab/tips", num: 20 },
  36. { url: "game/prefab/coin", num: 20 }
  37. ];
  38. /** 主页样式脚本 */
  39. public gameStyle: Game = null;
  40. /** 入口按钮 */
  41. public funBtns: FunBtns = null;
  42. /** 剩余可种植次数 */
  43. public leftTimes: number = -1;
  44. /** 最大可种植次数 */
  45. public maxTimes: number = -1;
  46. /** 恢复种植次数间隔 */
  47. public ProductionRecovery: number = 15;
  48. public init_leftTimes: boolean = false;
  49. /** 可生产商品配置 */
  50. public nextCanProduct = null;
  51. /** 按钮生产选中的农田、牧场或工厂 */
  52. public nextMake = null;
  53. /** 类型标识 */
  54. public nextType = 0;
  55. /** 刷新生产按钮信息 */
  56. public init_makeInfo = false;
  57. /** 正在生产 */
  58. public isProducting = false;
  59. /** 标志位 刷新任务描述 */
  60. public init_task = false;
  61. public init_expLevel = false;
  62. //标志位任务跟新
  63. public init_redBagTask = false;
  64. //标志位 生产奖励的任务ui刷新
  65. public init_productTask = false;
  66. public init_order = false;
  67. public init_speedup = false;
  68. 标志位
  69. public init_hideRedBag = false;
  70. public shareUrl = '';
  71. public shareTitle = '';
  72. public shareDes = '';
  73. public shareImgUrl = '';
  74. /** 生虫/生病/停电最多个数 */
  75. public RawInsectArr = [];
  76. /** 生虫/生病/停电当前个数 */
  77. public RawInsectCurArr = [0, 0, 0];
  78. //恢复生产次数
  79. public restoreProductTimes = 0;
  80. /** 最大可种植产品可更新到服务器标识 */
  81. public maxProductToServer = false;
  82. public authUIType = 0;
  83. public prohibiJBAd: string[] = [];
  84. public prohibitProductionAd: string[] = [];
  85. public productionAdMaxTimes = 20;
  86. public popTipCallBack: Function = null;
  87. /**
  88. * 初始化游戏数据:网络配置信息,用户信息
  89. * @returns
  90. */
  91. public async init() {
  92. let data: any = { "versionCode": gData.appData.version };
  93. let response = await mk.http.sendData('getAllConfigInfo', data);
  94. if (response.errcode != 0) {
  95. if (response.errcode == -10003 || response.errcode == -20003) {
  96. //清除缓存
  97. gData.loginData.reload();
  98. }
  99. return;
  100. }
  101. mk.console.logSingle("getAllConfigInfo", response.data);
  102. this.initConfigs(response.data);
  103. data = {};
  104. response = await mk.http.sendData('getInfoCrypt', data);
  105. if (response.errcode != 0) {
  106. return;
  107. }
  108. mk.console.logSingle("getInfoCrypt", response.data);
  109. this.initPlayerProp(response.data)
  110. this.initProps(response.data.gameUserData);
  111. if (gData.warnTipData.curSolution == 4) {
  112. if (response.data.isSystemRisk == 0) {
  113. //拉白后重置
  114. gData.warnTipData.setSolution(0);
  115. }
  116. }
  117. data = {};
  118. response = await mk.http.sendData('user/adShowConfig', data);
  119. if (response.errcode != 0) {
  120. return;
  121. }
  122. this.adShowConfig = response.data;
  123. mk.console.logSingle("user/adShowConfig", response.data);
  124. gData.adData.initEcpmData();
  125. // data = {};
  126. // response = await mk.http.sendData('noviceWeFare/getNoviceWeFareInfo', data);
  127. // if (response.errcode != 0) {
  128. // return;
  129. // }
  130. // this.playerProp.userTuCaoInfo = response.data.userWelFareTaskInfo;
  131. // mk.console.logSingle("welFare/getUserWelFareTaskInfo", response.data);
  132. gData.guideData.init();
  133. gData.guideWeakData.init();
  134. gData.moduleData.forEach(element => {
  135. element.init();
  136. });
  137. this.dataFinish = true;
  138. }
  139. private initConfigs(data) {
  140. // console.log('config ', data);
  141. this.configs = data;
  142. this.funOpenData = this.configs.ServerConfig.Functionswitch.split(",");
  143. //从服务器解析配置
  144. this.setProductMapFromJson();
  145. gData.loginData.popIdentifySwitch = this.configs.ServerConfig.popIdentifySwitch.split(";");
  146. this.prohibiJBAd = this.configs.ServerConfig.ProhibitJBAd.split(";");
  147. this.prohibitProductionAd = this.configs.ServerConfig.ProhibitProductionAd.split(";");
  148. this.productionAdMaxTimes = this.configs.ServerConfig.ProductionAdMax;
  149. console.log(`popIdentifySwitch=======${gData.loginData.popIdentifySwitch}`);
  150. console.log(`prohibiJBAd=======${this.prohibiJBAd}`);
  151. console.log(`prohibitProductionAd=======${this.prohibitProductionAd}`);
  152. console.log(`productionAdMaxTimes=======${this.productionAdMaxTimes}`);
  153. gData.gameData.shareUrl = this.configs.ServerConfig.shareUrl;
  154. gData.gameData.shareTitle = this.configs.ServerConfig.shareTitle;
  155. gData.gameData.shareDes = this.configs.ServerConfig.shareDes;
  156. gData.gameData.shareImgUrl = this.configs.ServerConfig.shareImgUrl;
  157. gData.gameData.RawInsectArr = this.configs.ServerConfig.RawInsect.split(',');
  158. }
  159. /**
  160. * 初始化玩家数据
  161. */
  162. private initPlayerProp(res_data) {
  163. this.playerProp = new PlayerProp();
  164. this.playerProp.cashIndex = res_data.cashIndex;
  165. this.playerProp.gameUserData = res_data.gameUserData;
  166. this.playerProp.isSignInToday = res_data.isSignInToday;
  167. this.playerProp.isWithdrawable = res_data.isWithdrawable;
  168. this.playerProp.lastTime = res_data.lastTime;
  169. this.playerProp.loginDays = res_data.loginDays;
  170. this.playerProp.newPlayer = res_data.newPlayer;
  171. this.playerProp.initPiggyBank(res_data.piggyBank);
  172. this.playerProp.piggyBankCashTimes = res_data.piggyBankCashTimes;
  173. this.playerProp.redMoney = res_data.redMoney == null ? 0 : res_data.redMoney;
  174. this.playerProp.signInDay = res_data.signInDay;
  175. this.playerProp.totalPiggyBankCashTimes = res_data.totalPiggyBankCashTimes;
  176. this.playerProp.turntableTimes = res_data.turntableTimes;
  177. this.playerProp.versioncfg = res_data.versioncfg;
  178. this.playerProp.isFirstRedMoney = res_data.isFirstRedMoney;
  179. gData.adData.watchNumToday = res_data.dayVideoTimesForRedMoney == null ? 0 : res_data.dayVideoTimesForRedMoney;
  180. this.playerProp.gradeLevel = res_data.farmLevel
  181. this.playerProp.userTuCaoInfo = res_data.userWelFareTaskInfo;
  182. this.playerProp.farmExpValue = res_data.userExp;
  183. this.playerProp.farmGradeData = res_data.userFarmGrageRewardInfo;
  184. this.playerProp.userNoviceWeFareInfo = res_data.userNoviceWeFareInfo;
  185. this.playerProp.redMoneyCashPayRecordList = res_data.redMoneyCashPayRecordList;
  186. mk.console.logSingle('userNoviceWeFareInfo==>', res_data.userNoviceWeFareInfo);
  187. //mk.console.logSingle('redMoneyCashPayRecordList==>', res_data.redMoneyCashPayRecordList);
  188. this.playerProp.userFarmTaskInfo = res_data.userFarmTaskInfo;
  189. this.playerProp.speedUpLeftTimes = res_data.speedUpLeftTimes;
  190. this.playerProp.completeFarmTaskTimes = res_data.completeFarmTaskTimes;
  191. this.playerProp.orderData = res_data.userOrderTaskInfo;
  192. this.playerProp.lineRedMoney = res_data.lineRedMoney;
  193. console.log("==============initPlayerProp");
  194. console.log(res_data.userOrderTaskInfo);
  195. mk.console.logSingle('userOrderTaskInfo', res_data.userOrderTaskInfo);
  196. //this.cloneOrderData();
  197. this.playerProp.curProductionAdTimes = res_data.dailyProductionTimes;
  198. console.log(`curProductionAdTimes=======${this.playerProp.curProductionAdTimes}`);
  199. mk.data.setTAUserID(gData.loginData.uin);
  200. mk.data.setTAEventUser(0, 'logindays_total', this.playerProp.loginDays);
  201. if (this.playerProp.completeFarmTaskTimes == 0) {
  202. mk.data.setTAEventUser(0, 'Cumulative_task', gData.gameData.playerProp.completeFarmTaskTimes);
  203. }
  204. if (gData.loginData.isFirstIn) {
  205. gData.loginData.isFirstIn = false;
  206. mk.data.setTAEventRegister();
  207. mk.data.sendDataEvent('ABTest', `触发${this.playerProp.groupCode}方案`);
  208. //注册时版本号
  209. mk.data.setTAEventUserStr(0, 'regtime_app_id', gData.appData.appVersion);
  210. //星云uid
  211. mk.data.setTAEventUserStr(0, 'xy_uid', gData.loginData.uin);
  212. mk.data.setTAEventUser(0, 'farm_lv', gData.gameData.playerProp.gradeLevel);
  213. }
  214. //当前版本号
  215. mk.data.setTAEventUserStr(0, 'now_app_id', gData.appData.appVersion);
  216. //渠道号
  217. mk.data.setTAEventUserStr(0, 'channel_id', gData.appData.umengChannel);
  218. // //test
  219. // this.playerProp.completeFarmTaskTimes = 3;
  220. }
  221. public cloneOrderData(isRefresh = false) {
  222. let value = mk.storage.getStorage(StorageKey.copyOrderData);
  223. if (value && !isRefresh) {
  224. this.playerProp.copyOrderData = [];
  225. let v = value.split(",");
  226. for (let i = 0; i != v.length; ++i) {
  227. this.playerProp.copyOrderData.push(parseInt(v[i]));
  228. }
  229. } else {
  230. let orderData = this.playerProp.orderData;
  231. if (orderData) {
  232. this.playerProp.copyOrderData = [];
  233. if (orderData && orderData.orderTaskList) {
  234. let len = orderData.orderTaskList.length;
  235. for (let i = 0; i != len; ++i) {
  236. this.playerProp.copyOrderData.push(this.playerProp.orderData.orderTaskList[i].completeCount);
  237. }
  238. mk.storage.setStorage(StorageKey.copyOrderData, this.playerProp.copyOrderData);
  239. }
  240. }
  241. }
  242. mk.console.logSingle('cloneOrderData', this.playerProp.copyOrderData);
  243. }
  244. public updateOrderTaskCopyData(id: number) {
  245. if (this.playerProp.orderData && this.playerProp.orderData.orderTaskList) {
  246. let productJson = this.configs.Product;
  247. let orderData = this.playerProp.orderData.orderTaskList;
  248. let len = orderData.length;
  249. for (let i = 0; i != len; ++i) {
  250. let dataE = orderData[i];
  251. if (dataE.Id <= productJson.length) {
  252. let productData = productJson[dataE.Id - 1];
  253. if (productData.picture == id) {
  254. this.playerProp.copyOrderData[i]++;
  255. mk.storage.setStorage(StorageKey.copyOrderData, this.playerProp.copyOrderData);
  256. break;
  257. }
  258. }
  259. }
  260. } else {
  261. this.playerProp.copyOrderData = [];
  262. cc.sys.localStorage.removeItem(StorageKey.copyOrderData);
  263. }
  264. }
  265. /**
  266. * 保存单个数据
  267. */
  268. public async setProp(key: GameProp, value: any) {
  269. let data = {
  270. key: key + '',
  271. value: value
  272. };
  273. this.props.set(key, value);
  274. await mk.http.sendData('savePlayerProp', data);
  275. this.savePropFinish = true;
  276. }
  277. /**
  278. * 保存多个数据
  279. */
  280. public async setProps(arr: { key: GameProp, value: any }[]) {
  281. let needProp = {};
  282. for (let i = 0; i < arr.length; i++) {
  283. needProp[arr[i].key + ''] = arr[i].value;
  284. }
  285. let data = {
  286. needProp: needProp
  287. };
  288. for (let i = 0; i < arr.length; i++) {
  289. this.props.set(arr[i].key, arr[i].value);
  290. }
  291. await mk.http.sendData('saveAllPlayerProp', data);
  292. this.savePropsFinish = true;
  293. }
  294. /** 获取属性 */
  295. public getProp(key: GameProp): any {
  296. if (this.props == null) {
  297. return 0;
  298. }
  299. let value = this.props.get(key);
  300. return value;
  301. }
  302. /**
  303. * 向服务器请求所有属性后更新
  304. */
  305. public async getAllProps() {
  306. let response = await mk.http.sendData('getAllPlayerProp', {});
  307. if (response.errcode != 0) {
  308. return;
  309. }
  310. this.initProps(response.data);
  311. this.getPropsFnish = true;
  312. }
  313. private initProps(data) {
  314. if (data == null) {
  315. return;
  316. }
  317. for (let key in data) {
  318. this.props.set(parseInt(key), data[key]);
  319. }
  320. this.setFramDataMapByServer();
  321. this.setPastureDataMapByServer();
  322. this.setFactoryDataMapByServer();
  323. this.initProductTimes();
  324. this.initLeftTimes();
  325. this.initFarmMapGetRewardData();
  326. this.initCashOutTimes();
  327. // let isNewTask = this.getProp(GameProp.redBagTaskRefresh);
  328. // if (isNewTask != undefined) {
  329. // this.init_redBagTask = isNewTask;
  330. // }
  331. }
  332. private initLeftTimes() {
  333. let lefttimes = this.getProp(GameProp.leftTimes);
  334. if (lefttimes == undefined) {
  335. this.leftTimes = parseInt(this.configs.ServerConfig.FreeProduction);
  336. this.setProp(GameProp.leftTimes, this.leftTimes);
  337. }
  338. else {
  339. this.leftTimes = lefttimes;
  340. }
  341. this.maxTimes = parseInt(this.configs.ServerConfig.ProductionMax);
  342. this.ProductionRecovery = parseInt(this.configs.ServerConfig.ProductionRecovery);
  343. // //test
  344. // this.leftTimes = 1;
  345. // this.maxTimes = 20;
  346. // this.ProductionRecovery = 1;
  347. }
  348. /** 增加减少生产次数
  349. * @param add 增减变量
  350. */
  351. public changeLeftTimes(add, isIgnoreMaxTimes = false, isRefresh = true) {
  352. gData.gameData.leftTimes += add;
  353. if (add > 0 && !isIgnoreMaxTimes) {
  354. gData.gameData.leftTimes = (gData.gameData.leftTimes > gData.gameData.maxTimes ? gData.gameData.maxTimes : gData.gameData.leftTimes);
  355. }
  356. if (gData.gameData.leftTimes < 0) {
  357. gData.gameData.leftTimes = 0;
  358. }
  359. gData.gameData.setProp(GameProp.leftTimes, gData.gameData.leftTimes);
  360. if (isRefresh) {
  361. gData.gameData.init_leftTimes = true;
  362. }
  363. }
  364. //图鉴领取数据
  365. private _farmMapRewardData = [];
  366. public getFarmMapRewardState(index) {
  367. if (index.i < this._farmMapRewardData.length) {
  368. if (index.j < this._farmMapRewardData[index.i].length) {
  369. return this._farmMapRewardData[index.i][index.j];
  370. }
  371. }
  372. return 1;
  373. }
  374. public setFarmMapRewardState(index, state) {
  375. if (index.i < this._farmMapRewardData.length) {
  376. if (index.j < this._farmMapRewardData[index.i].length) {
  377. this._farmMapRewardData[index.i][index.j] = state;
  378. this.setProp(GameProp.farmMapGetRewardData, this._farmMapRewardData);
  379. }
  380. }
  381. }
  382. private initFarmMapGetRewardData() {
  383. this._farmMapRewardData = this.getProp(GameProp.farmMapGetRewardData);
  384. if (!this._farmMapRewardData) {
  385. this._farmMapRewardData = [];
  386. }
  387. let needSync = false;
  388. let index = 0;
  389. this._productTypeMap.forEach((value, key) => {
  390. if (this._farmMapRewardData.length <= index) {
  391. let len = value.length;
  392. let arr = [];
  393. for (let i = 0; i != len; ++i) {
  394. arr.push(0);
  395. }
  396. this._farmMapRewardData.push(arr);
  397. needSync = true;
  398. console.log("-----add 数组数据")
  399. } else {
  400. let data = this._farmMapRewardData[index];
  401. let len = value.length;
  402. for (let i = 0; i != len; ++i) {
  403. if (i >= data.length) {
  404. data.push(0);
  405. needSync = true;
  406. console.log("-----add 单个数据")
  407. }
  408. }
  409. }
  410. ++index;
  411. });
  412. if (needSync) {
  413. this.setProp(GameProp.farmMapGetRewardData, this._farmMapRewardData);
  414. }
  415. }
  416. //提现次数
  417. public _cashOutTimes = 0;
  418. public initCashOutTimes() {
  419. let v = this.getProp(GameProp.cashOutTimes);
  420. if (v) {
  421. this._cashOutTimes = v;
  422. } else {
  423. this._cashOutTimes = 0;
  424. }
  425. console.log(`initCashOutTimes====>${this._cashOutTimes}`);
  426. }
  427. public addCashOutTimes() {
  428. this._cashOutTimes += 1;
  429. this.setProp(GameProp.cashOutTimes, this._cashOutTimes);
  430. console.log(`addCashOutTimes====>${this._cashOutTimes}`);
  431. }
  432. /** 是否是新用户 */
  433. public isNewPlayer(): boolean {
  434. let v = this.getProp(GameProp.newPlayer);
  435. return v == 0;
  436. }
  437. //*********** ================= 农场数据 ================== */
  438. /** 农田数据 服务器数据 */
  439. private _farmData = [];
  440. /** 农田字典 本地数据,方便操作*/
  441. private _farmDataMap: Map<number, any> = new Map();
  442. //刷新农田
  443. public needFreshArr = [];
  444. /** 随机获取可种植物品 */
  445. getRandomPlantConfig(out?: any) {
  446. let id = 0;
  447. let isNoHaveCurTab = true;
  448. let isNoAllComplete = false;
  449. let isOrderDataInvalid = false;
  450. let isMatchSuccess = false;
  451. let productType = [];
  452. let animalId = [];
  453. let data = this.playerProp.orderData;
  454. let orderData = data.orderTaskList;
  455. if (data && orderData) {
  456. let productJson = this.configs.Product;
  457. for (let i = 0; i != orderData.length; ++i) {
  458. let dataE = orderData[i];
  459. //console.log(`getRandomPlantConfig======= ${this.playerProp.copyOrderData[i]}`);
  460. if (dataE.completeCount < dataE.taskCount) {
  461. if (dataE.Id <= productJson.length) {
  462. isNoAllComplete = true;
  463. let productData = productJson[dataE.Id - 1];
  464. if (productData.tab == ProductType.nzw) {
  465. let max = this.getMaxProduct(ProductType.nzw);
  466. if (max && productData.picture <= max) {
  467. id = productData.picture;
  468. isNoHaveCurTab = false;
  469. isMatchSuccess = true;
  470. this.nextType = 1;
  471. mk.console.logSingle("getRandomPlantConfig=>", id);
  472. break;
  473. }
  474. } else if (productData.tab == ProductType.dw) {
  475. animalId.push(productData.picture);
  476. } else {
  477. productType.push(productData.tab);
  478. }
  479. } else {
  480. isOrderDataInvalid = true;
  481. console.log("订单数据有问题,随机id");
  482. break;
  483. }
  484. }
  485. }
  486. if (!isMatchSuccess) {
  487. let picId = this.doFarmMapDataCheck(0);
  488. if (picId) {
  489. id = picId;
  490. } else {
  491. id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
  492. this.nextType = 1
  493. }
  494. console.log("订单数据没有匹配成功====1");
  495. }
  496. } else {
  497. isOrderDataInvalid = true;
  498. let picId = this.doFarmMapDataCheck(0);
  499. if (picId) {
  500. id = picId;
  501. } else {
  502. id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
  503. this.nextType = 1
  504. }
  505. console.log("订单数据为null");
  506. }
  507. //选择逻辑处理
  508. if (isOrderDataInvalid) {
  509. return this.getProductMap(id);
  510. } else {
  511. if (isNoHaveCurTab) {
  512. if (isNoAllComplete) {
  513. let isHaveEmpty = false;
  514. for (let i = 0; i != productType.length; ++i) {
  515. let factoryIcon = gData.factorySystem.factoryIcons;
  516. let len = factoryIcon.length;
  517. for (var j = 0; j < len; j++) {
  518. let tab = this.getTabByConfigID(factoryIcon[j].configID);
  519. if (tab == productType[i] && factoryIcon[j].data.state == FactroyState.Empty) {
  520. isHaveEmpty = true;
  521. out.state = 1;
  522. break;
  523. }
  524. }
  525. }
  526. if (!isHaveEmpty) {
  527. for (let i = 0; i != animalId.length; ++i) {
  528. let pastureIcon = gData.pastureSystem.pastureIcons;
  529. let len = pastureIcon.length;
  530. for (var j = 0; j < len; j++) {
  531. if (pastureIcon[j].data.productID == animalId[i] && pastureIcon[j].data.state == PastureState.Empty) {
  532. isHaveEmpty = true;
  533. out.state = 2;
  534. break;
  535. }
  536. }
  537. }
  538. }
  539. if (isHaveEmpty) {
  540. console.log("getRandomPlantConfig====0");
  541. return null;
  542. } else {
  543. console.log("getRandomPlantConfig====1");
  544. return this.getProductMap(id);
  545. }
  546. } else {
  547. console.log("getRandomPlantConfig====2");
  548. return this.getProductMap(id);
  549. }
  550. } else {
  551. console.log("getRandomPlantConfig====3");
  552. return this.getProductMap(id);
  553. }
  554. }
  555. //id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
  556. //return this.getProductMap(id);
  557. }
  558. public doJudgeOrderLogic(out?: any) {
  559. let data = this.playerProp.orderData;
  560. let orderData = data.orderTaskList;
  561. if (data && orderData) {
  562. let productJson = this.configs.Product;
  563. for (let i = 0; i != orderData.length; ++i) {
  564. let dataE = orderData[i];
  565. if (dataE.completeCount < dataE.taskCount) {
  566. if (dataE.Id <= productJson.length) {
  567. let productData = productJson[dataE.Id - 1];
  568. if (productData.tab == ProductType.nzw) {
  569. continue;
  570. } else if (productData.tab == ProductType.dw) {
  571. console.log(`doJudgeOrderLogic=====${dataE.Id}`);
  572. let pastureIcon = gData.pastureSystem.pastureIcons;
  573. let len = pastureIcon.length;
  574. for (var j = 0; j < len; j++) {
  575. if (pastureIcon[j].data.productID == productData.picture && pastureIcon[j].data.state == PastureState.Empty) {
  576. out.state = 2;
  577. console.log("doJudgeOrderLogic====2");
  578. console.log("doJudgeOrderLogic====22");
  579. return;
  580. }
  581. }
  582. } else {
  583. let factoryIcon = gData.factorySystem.factoryIcons;
  584. let len = factoryIcon.length;
  585. for (var j = 0; j < len; j++) {
  586. let tab = this.getTabByConfigID(factoryIcon[j].configID);
  587. if (tab == productData.tab && factoryIcon[j].data.state == FactroyState.Empty) {
  588. out.state = 1;
  589. console.log("doJudgeOrderLogic====1");
  590. console.log("doJudgeOrderLogic====11");
  591. return;
  592. }
  593. }
  594. }
  595. }
  596. }
  597. }
  598. }
  599. }
  600. /** 随机获取可生产产品 */
  601. getRandomFactoryConfig(configID) {
  602. let tab = gData.gameData.getTabByConfigID(configID);
  603. let arr = this.getProductArrByType(tab);
  604. let max = this.getMaxProduct(tab);
  605. let canArr = [];
  606. let len = arr.length;
  607. for (var i = 0; i < len; i++) {
  608. if (arr[i].picture <= max) {
  609. canArr.push(arr[i].picture);
  610. if (arr[i].picture == max) {
  611. break;
  612. }
  613. }
  614. }
  615. let index = Util.rnd(0, canArr.length - 1);
  616. let id = canArr[index];
  617. return this.getProductMap(id);
  618. }
  619. public doFarmMapDataCheck(startIndex: number, isHaveEmpty?: any) {
  620. let value = 0;
  621. for (let key in ProductType) {
  622. if (startIndex <= value) {
  623. let max = this.getMaxProduct(ProductType[key]);
  624. if (max) {
  625. let list_data = this.getProductArrByType(ProductType[key]);
  626. for (let i = 0; i != list_data.length; ++i) {
  627. let picId = list_data[i].picture - 1;
  628. if (list_data[i].unlock == 1 && picId == max) {
  629. let state = this.getFarmMapRewardState(this.getIndex(list_data[i]));
  630. if (state == 0) {
  631. switch (ProductType[key]) {
  632. case ProductType.nzw:
  633. console.log("图鉴数据匹配成功=====1");
  634. this.nextType = 1
  635. return picId;
  636. case ProductType.dw:
  637. {
  638. let pastureIconsData = gData.pastureSystem.pastureIcons;
  639. let len = pastureIconsData.length;
  640. for (let index = 0; index < len; index++) {
  641. if (pastureIconsData[index].data.state == PastureState.Empty) {
  642. if (isHaveEmpty && startIndex == value) {
  643. isHaveEmpty.state = true;
  644. }
  645. if (picId == pastureIconsData[index].data.productID) {
  646. console.log("图鉴数据匹配成功====2");
  647. this.nextCanProduct = this.getProductMap(pastureIconsData[index].data.productID);
  648. this.nextMake = pastureIconsData[index];
  649. this.nextType = 2;
  650. return picId;
  651. }
  652. }
  653. }
  654. }
  655. break;
  656. default:
  657. {
  658. let factoryIconsData = gData.factorySystem.factoryIcons;
  659. let len = factoryIconsData.length;
  660. for (let index = 0; index < len; index++) {
  661. if (factoryIconsData[index].data.state == FactroyState.Empty) {
  662. if (isHaveEmpty) {
  663. isHaveEmpty.state = true;
  664. }
  665. let tab = this.getTabByConfigID(factoryIconsData[index].configID);
  666. if (tab == ProductType[key]) {
  667. console.log("图鉴数据匹配成功=====3");
  668. this.nextCanProduct = this.getProductMap(picId);
  669. this.nextMake = factoryIconsData[index];
  670. this.nextType = 3;
  671. return picId;
  672. }
  673. }
  674. }
  675. }
  676. break;
  677. }
  678. }
  679. }
  680. }
  681. }
  682. }
  683. ++value;
  684. }
  685. console.log("图鉴数据匹配不成功");
  686. return null;
  687. }
  688. /** 自动生产选中下一个 */
  689. setNextProduct(sel = true) {
  690. if (this.nextMake) {
  691. return;
  692. }
  693. //-1无效,0:有空地,1:工厂有空位,2:饲养厂有空位
  694. let haveEmpty = { state: -1 };
  695. let next = gData.farmSystem.selectNextFarm(haveEmpty, sel);
  696. if (!next) {
  697. if (haveEmpty.state == -1) {
  698. this.doJudgeOrderLogic(haveEmpty);
  699. }
  700. let next1 = gData.pastureSystem.nextPasture(haveEmpty);
  701. if (!next1) {
  702. let next2 = gData.factorySystem.nextFactory(haveEmpty);
  703. if (!next2) {
  704. this.nextType = 0;
  705. }
  706. else {
  707. //this.nextType = 3;
  708. }
  709. }
  710. else {
  711. //this.nextType = 2;
  712. }
  713. }
  714. else {
  715. //this.nextType = 1;
  716. }
  717. this.init_makeInfo = true;
  718. }
  719. hasFirstCheck = false;
  720. firstCheckNext() {
  721. if (!this.hasFirstCheck && gData.farmSystem.farms.length >= 18
  722. && gData.pastureSystem.pastureIcons.length >= 3 && gData.factorySystem.factoryIcons.length >= 6) {
  723. this.hasFirstCheck = true;
  724. Util.objSortByKey(gData.farmSystem.farms, 'sortID');
  725. Util.objSortByKey(gData.pastureSystem.pastureIcons, 'sortID');
  726. Util.objSortByKey(gData.factorySystem.factoryIcons, 'sortID');
  727. gData.gameData.setNextProduct(false);
  728. }
  729. }
  730. async makeProduct() {
  731. let flyRed = true;
  732. switch (this.nextType) {
  733. case 0:
  734. //mk.tip.pop('农场已满,无法继续生产');
  735. //弹出收获、生虫、加速
  736. if (!this.checkCanHarvest()) {
  737. if (!this.checkCanClearSick()) {
  738. this.checkCanSpeedUp(true);
  739. }
  740. }
  741. flyRed = false;
  742. break;
  743. case 1:
  744. flyRed = await gData.farmSystem.btnMake();
  745. gData.adData.checkPopRed();
  746. break;
  747. case 2:
  748. flyRed = await gData.pastureSystem.btnMake();
  749. gData.adData.checkPopRed();
  750. break;
  751. case 3:
  752. flyRed = await gData.factorySystem.btnMake();
  753. gData.adData.checkPopRed();
  754. break;
  755. }
  756. return flyRed;
  757. }
  758. public async updateNewTaskProgress(isNeedRefresh = false) {
  759. if (gData.gameData.funOpenData[4] == "0") {
  760. return false;
  761. }
  762. if (this.playerProp.userFarmTaskInfo) {
  763. let com = this.playerProp.userFarmTaskInfo.completeCount;
  764. let count = this.playerProp.userFarmTaskInfo.taskCount;
  765. if (com >= count) {
  766. if (!this.gameStyle.getIsCanGetOrderReward()) {
  767. mk.tip.pop('任务红包进度已满,快去提现');
  768. } else {
  769. mk.tip.pop("订单已完成,快领奖吧!");
  770. }
  771. return false;
  772. }
  773. }
  774. let data = {};
  775. let response = await mk.http.sendData('farmTask/updateUserFarmTaskInfo', data);
  776. mk.console.logSingle('refrehTask=>', response);
  777. if (response.errcode != 0) {
  778. return false;
  779. }
  780. gData.gameData.init_task = true;
  781. this.playerProp.userFarmTaskInfo = response.data.userFarmTaskInfo;
  782. if (this.playerProp.userFarmTaskInfo.completeCount >= this.playerProp.userFarmTaskInfo.taskCount) {
  783. //mk.ui.closeAllUI();
  784. //mk.guide.open(4);
  785. }
  786. // if (isNeedRefresh) {
  787. // gData.gameData.init_task = true;
  788. // }
  789. return true;
  790. }
  791. public setFarmDataMap(id, data, sendToServer = true) {
  792. this._farmDataMap.set(id, data);
  793. let len = this._farmData.length;
  794. for (var i = 0; i < len; i++) {
  795. if (this._farmData[i].id == id) {
  796. this._farmData[i].state = data.state;
  797. this._farmData[i].productID = data.productID;
  798. this._farmData[i].growSpan = data.growSpan;
  799. break;
  800. }
  801. }
  802. this.needFreshArr.push(id);
  803. //更新到服务器
  804. if (sendToServer) {
  805. this.freshSendToServer(1);
  806. }
  807. }
  808. public getFarmDataMap(id) {
  809. return this._farmDataMap.get(id);
  810. }
  811. /** 服务器数据设置到本地 */
  812. public setFramDataMapByServer() {
  813. this._farmData = this.getProp(GameProp.farmData);
  814. if (!this._farmData) {
  815. this._farmData = [];
  816. }
  817. let len = this._farmData.length;
  818. //新玩家初始化农田数据
  819. if (len < 18) {
  820. let id = 31000;
  821. let data = null;
  822. let unluckNum = parseInt(gData.gameData.configs.ServerConfig.unluckNum);
  823. for (var i = 0; i < 18; i++) {
  824. if (i < unluckNum) {
  825. data = { id: id, state: FarmState.Empty, productID: 0, growSpan: 0 };
  826. }
  827. else if (i == unluckNum) {
  828. data = { id: id, state: FarmState.CanUnlock, productID: 0, growSpan: 0 };
  829. }
  830. else {
  831. data = { id: id, state: FarmState.Lock, productID: 0, growSpan: 0 };
  832. }
  833. this._farmData.push(data);
  834. this._farmDataMap.set(id, data);
  835. id++;
  836. }
  837. //第一次初始数据
  838. // this.setMaxProduct(10003);
  839. //更新到服务器
  840. this.setProp(GameProp.farmData, this._farmData);
  841. }
  842. else {
  843. let sickTimes = 0;
  844. for (var i = 0; i < len; i++) {
  845. this._farmDataMap.set(this._farmData[i].id, this._farmData[i]);
  846. if (this._farmData[i].state == FarmState.Sick) {
  847. sickTimes++;
  848. }
  849. }
  850. this.RawInsectCurArr[0] = sickTimes;
  851. }
  852. this.setMaxProduct(10003, true);
  853. }
  854. /** puduct配置数据 <picture, config> */
  855. private _productMap: Map<number, any> = new Map();
  856. /** puduct类型配置数据 <tab, 类型数组> */
  857. private _productTypeMap: Map<string, any> = new Map();
  858. /** 设置puduct配置数据 */
  859. public setProductMapFromJson() {
  860. let productJson = this.configs.Product;
  861. // // 先用本地数据
  862. // let productJson = gData.configData.configMap.get('product');
  863. let len = productJson.length;
  864. let product = null;
  865. let tab = '';
  866. let arr = [];
  867. for (var i = 0; i < len; i++) {
  868. product = productJson[i];
  869. this._productMap.set(product.picture, product);
  870. if (tab != product.tab) {
  871. arr = [];
  872. this._productTypeMap.set(product.tab, arr);
  873. tab = product.tab;
  874. }
  875. arr.push(product);
  876. }
  877. }
  878. /** 根据id获取单个数据 */
  879. public getProductMap(id) {
  880. return this._productMap.get(id);
  881. }
  882. /** 根据tab获取数组 */
  883. public getProductArrByType(type: ProductType) {
  884. return this._productTypeMap.get(type);
  885. }
  886. /** 产品生产/种植次数 服务器数据 */
  887. private _productMakeTimesData = [];
  888. /** 产品生产/种植次数 */
  889. private _productMakeTimesMap: Map<number, number> = new Map();
  890. private initProductTimes() {
  891. this._productMakeTimesData = this.getProp(GameProp.productMakeTimes);
  892. if (!this._productMakeTimesData) {
  893. this._productMakeTimesData = [];
  894. }
  895. let len = this._productMakeTimesData.length;
  896. for (var i = 0; i < len; i++) {
  897. this._productMakeTimesMap.set(this._productMakeTimesData[i].id, this._productMakeTimesData[i].times);
  898. this.setMaxProduct(this._productMakeTimesData[i].id);
  899. }
  900. }
  901. addProductMakeTimesById(id: number) {
  902. let isAddMaxProduct = false;
  903. let times = this._productMakeTimesMap.get(id);
  904. if (!times) {
  905. times = 0;
  906. }
  907. times++;
  908. this._productMakeTimesMap.set(id, times);
  909. //更新到服务器
  910. let has = false;
  911. let len = this._productMakeTimesData.length;
  912. for (var i = 0; i < len; i++) {
  913. if (this._productMakeTimesData[i].id == id) {
  914. this._productMakeTimesData[i].times = times;
  915. has = true;
  916. break;
  917. }
  918. }
  919. if (!has) {
  920. let data = { 'id': id, 'times': times };
  921. this._productMakeTimesData.push(data);
  922. }
  923. //设置可种植/生产最大id
  924. let nextID = id + 1;
  925. let curConfig = this.getProductMap(id);
  926. let nextConfig = this.getProductMap(nextID);
  927. if (id == this.getMaxProduct(curConfig.tab)) {
  928. if (nextConfig) {
  929. gData.plantData.init_itemIndex = nextID;
  930. }
  931. }
  932. if (nextConfig) {
  933. if (nextConfig.tab == curConfig.tab && nextID > this.getMaxProduct(curConfig.tab)) {
  934. if (nextConfig.unlock == 1 && nextConfig.value <= times) {
  935. isAddMaxProduct = true;
  936. this._productMakeTimesMap.set(nextID, 0);
  937. let data = { 'id': nextID, 'times': 0 };
  938. this._productMakeTimesData.push(data);
  939. this.setMaxProduct(nextID);
  940. let nConfig = this.getProductMap(nextID + 1);
  941. if (nConfig) {
  942. gData.plantData.init_lock = nextID + 1;
  943. }
  944. }
  945. }
  946. }
  947. if (!isAddMaxProduct) {
  948. mk.event.emit("refreshFarmMapUI");
  949. }
  950. this.setProp(GameProp.productMakeTimes, this._productMakeTimesData);
  951. }
  952. getProductMakeTimesById(id: number) {
  953. let times = this._productMakeTimesMap.get(id);
  954. if (!times) {
  955. times = 0
  956. }
  957. return times;
  958. }
  959. //------------- 养殖场数据-----------
  960. /** 养殖场数据 服务器数据 */
  961. private _pastureData = [];
  962. /** 养殖场字典 本地数据,方便操作*/
  963. private _pastureDataMap: Map<number, any> = new Map();
  964. public setPastureDataMap(id, data, sendToServer = true) {
  965. this._pastureDataMap.set(id, data);
  966. let len = this._pastureData.length;
  967. for (var i = 0; i < len; i++) {
  968. if (this._pastureData[i].id == id) {
  969. this._pastureData[i].state = data.state;
  970. this._pastureData[i].productID = data.productID;
  971. this._pastureData[i].growSpan = data.growSpan;
  972. break;
  973. }
  974. }
  975. this.needFreshArr.push(id);
  976. //更新到服务器
  977. if (sendToServer) {
  978. this.freshSendToServer(2);
  979. }
  980. }
  981. public getPastureDataMap(id) {
  982. return this._pastureDataMap.get(id);
  983. }
  984. /** 服务器数据设置到本地 */
  985. public setPastureDataMapByServer() {
  986. this._pastureData = this.getProp(GameProp.pastureData);
  987. if (!this._pastureData) {
  988. this._pastureData = [];
  989. }
  990. let len = this._pastureData.length;
  991. //新玩家初始化养殖场数据
  992. if (len < 3) {
  993. let arr = this.getProductArrByType(ProductType.dw);
  994. let len1 = arr.length;
  995. let id = 30001;
  996. let data = null;
  997. for (var i = 0; i < len1; i++) {
  998. if (this.playerProp.orderData.overTimes < arr[i].value) {
  999. data = { id: id, state: PastureState.Lock, productID: arr[i].picture, growSpan: 0 };
  1000. }
  1001. else {
  1002. data = { id: id, state: PastureState.Empty, productID: arr[i].picture, growSpan: 0 };
  1003. }
  1004. this._pastureData.push(data);
  1005. this._pastureDataMap.set(id, data);
  1006. id++;
  1007. }
  1008. //更新到服务器
  1009. this.setProp(GameProp.pastureData, this._pastureData);
  1010. }
  1011. else {
  1012. let sickTimes = 0;
  1013. for (var i = 0; i < len; i++) {
  1014. this._pastureDataMap.set(this._pastureData[i].id, this._pastureData[i]);
  1015. if (this._pastureData[i].state == PastureState.Sick) {
  1016. sickTimes++;
  1017. }
  1018. }
  1019. this.RawInsectCurArr[1] = sickTimes;
  1020. }
  1021. }
  1022. //------------- 工厂数据-----------
  1023. /** 工厂数据 服务器数据 */
  1024. private _factoryData = [];
  1025. /** 工厂字典 本地数据,方便操作*/
  1026. private _factoryDataMap: Map<number, any> = new Map();
  1027. public setFactoryDataMap(id, data, sendToServer = true) {
  1028. this._factoryDataMap.set(id, data);
  1029. let len = this._factoryData.length;
  1030. for (var i = 0; i < len; i++) {
  1031. if (this._factoryData[i].id == id) {
  1032. this._factoryData[i].state = data.state;
  1033. this._factoryData[i].productID = data.productID;
  1034. this._factoryData[i].growSpan = data.growSpan;
  1035. break;
  1036. }
  1037. }
  1038. this.needFreshArr.push(id);
  1039. //更新到服务器
  1040. if (sendToServer) {
  1041. this.freshSendToServer(3);
  1042. }
  1043. }
  1044. public getFactoryDataMap(id) {
  1045. return this._factoryDataMap.get(id);
  1046. }
  1047. /** 服务器数据设置到本地 */
  1048. public setFactoryDataMapByServer() {
  1049. this._factoryData = this.getProp(GameProp.factoryData);
  1050. if (!this._factoryData) {
  1051. this._factoryData = [];
  1052. }
  1053. let len = this._factoryData.length;
  1054. //新玩家初始化工厂数据
  1055. if (len < 6) {
  1056. let id = 30004;
  1057. let data = null;
  1058. let tab = null;
  1059. for (var i = 0; i < 6; i++) {
  1060. tab = this.getTabByConfigID(id);
  1061. let arr = this.getProductArrByType(tab);
  1062. if (this.playerProp.orderData.overTimes < arr[0].value) {
  1063. data = { id: id, state: FactroyState.Lock, productID: 0, growSpan: 0 };
  1064. }
  1065. else {
  1066. data = { id: id, state: FactroyState.Empty, productID: 0, growSpan: 0 };
  1067. //更新最大可购买商品
  1068. this.setMaxProduct(arr[0].picture, true);
  1069. }
  1070. this._factoryData.push(data);
  1071. this._factoryDataMap.set(id, data);
  1072. id++;
  1073. }
  1074. //更新到服务器
  1075. this.setProp(GameProp.factoryData, this._factoryData);
  1076. }
  1077. else {
  1078. let sickTimes = 0;
  1079. let id = 30004;
  1080. let tab = null;
  1081. for (var i = 0; i < len; i++) {
  1082. tab = this.getTabByConfigID(id);
  1083. let arr = this.getProductArrByType(tab);
  1084. this._factoryDataMap.set(this._factoryData[i].id, this._factoryData[i]);
  1085. if (this._factoryData[i].state == FactroyState.Sick) {
  1086. sickTimes++;
  1087. }
  1088. if (this.playerProp.orderData.overTimes >= arr[0].value) {
  1089. //更新最大可购买商品
  1090. this.setMaxProduct(arr[0].picture, true);
  1091. }
  1092. id++;
  1093. }
  1094. this.RawInsectCurArr[2] = sickTimes;
  1095. }
  1096. }
  1097. /** 通过工厂建筑物ID获取标签 */
  1098. getTabByConfigID(configID: number): ProductType {
  1099. let tab = ProductType.bmhc;
  1100. switch (configID) {
  1101. case 30004:
  1102. tab = ProductType.bmhc;
  1103. break;
  1104. case 30005:
  1105. tab = ProductType.gdp;
  1106. break;
  1107. case 30006:
  1108. tab = ProductType.ztc;
  1109. break;
  1110. case 30007:
  1111. tab = ProductType.lrc;
  1112. break;
  1113. case 30008:
  1114. tab = ProductType.gfmg;
  1115. break;
  1116. case 30009:
  1117. tab = ProductType.kcd;
  1118. break;
  1119. }
  1120. return tab;
  1121. }
  1122. /** 通过标签获取工厂建筑物ID */
  1123. getConfigIDByTab(tab: ProductType): number {
  1124. let configID = 0;
  1125. switch (tab) {
  1126. case ProductType.bmhc:
  1127. configID = 30004;
  1128. break;
  1129. case ProductType.gdp:
  1130. configID = 30005;
  1131. break;
  1132. case ProductType.ztc:
  1133. configID = 30006;
  1134. break;
  1135. case ProductType.lrc:
  1136. configID = 30007;
  1137. break;
  1138. case ProductType.gfmg:
  1139. configID = 30008;
  1140. break;
  1141. case ProductType.kcd:
  1142. configID = 30009;
  1143. break;
  1144. }
  1145. return configID;
  1146. }
  1147. getIndex(data) {
  1148. let index: any = {};
  1149. index.i = 0;
  1150. index.j = 0;
  1151. switch (data.tab) {
  1152. case '农作物':
  1153. index.i = 0;
  1154. index.j = data.picture - 10001;
  1155. break;
  1156. case '动物':
  1157. index.i = 1;
  1158. index.j = data.picture - 20001;
  1159. break;
  1160. case '爆米花厂':
  1161. index.i = 2;
  1162. index.j = data.picture - 20004;
  1163. break;
  1164. case '糕点铺':
  1165. index.i = 3;
  1166. index.j = data.picture - 20013;
  1167. break;
  1168. case '制糖厂':
  1169. index.i = 4;
  1170. index.j = data.picture - 20010;
  1171. break;
  1172. case '炼乳厂':
  1173. index.i = 5;
  1174. index.j = data.picture - 20007;
  1175. break;
  1176. case '功夫面馆':
  1177. index.i = 6;
  1178. index.j = data.picture - 20025;
  1179. break;
  1180. case '快餐店':
  1181. index.i = 7;
  1182. index.j = data.picture - 20019;
  1183. break;
  1184. }
  1185. return index;
  1186. }
  1187. /** 发送数据到服务器 */
  1188. freshSendToServer(type) {
  1189. switch (type) {
  1190. case 1:
  1191. this.setProp(GameProp.farmData, this._farmData);
  1192. break;
  1193. case 2:
  1194. this.setProp(GameProp.pastureData, this._pastureData);
  1195. break;
  1196. case 3:
  1197. this.setProp(GameProp.factoryData, this._factoryData);
  1198. break;
  1199. }
  1200. }
  1201. /** 最大可种植/生产商品数组 */
  1202. private _maxProduct = [];
  1203. public getMaxProduct(tab) {
  1204. if (this._maxProduct) {
  1205. let len = this._maxProduct.length;
  1206. let data = null;
  1207. for (var i = 0; i < len; i++) {
  1208. data = this._maxProduct[i];
  1209. if (data.tab == tab) {
  1210. return data.productID;
  1211. }
  1212. }
  1213. }
  1214. return null;
  1215. }
  1216. /** 设置最大可生产商品
  1217. * @param id 产品id
  1218. * @param unlock 是否是解锁增加
  1219. */
  1220. public setMaxProduct(id, unlock = false) {
  1221. let config = this.getProductMap(id);
  1222. if (!this._maxProduct) {
  1223. this._maxProduct = [];
  1224. }
  1225. let len = this._maxProduct.length;
  1226. let data = null;
  1227. let has = false;
  1228. for (var i = 0; i < len; i++) {
  1229. data = this._maxProduct[i];
  1230. if (data.tab == config.tab) {
  1231. if (data.productID < id) {
  1232. data.productID = id;
  1233. data.id = config.id;
  1234. }
  1235. has = true;
  1236. break;
  1237. }
  1238. }
  1239. if (!has && unlock) {
  1240. data = { tab: config.tab, productID: id, id: config.id };
  1241. this._maxProduct.push(data);
  1242. }
  1243. gData.farmMapData.isStateChange = true;
  1244. this.updateMaxProduct();
  1245. }
  1246. /** 农场升级时解锁工厂,检查最大可种植/生产商品 */
  1247. public checkTaskFinishUnLock() {
  1248. for (var key in ProductType) {
  1249. let tab = ProductType[key];
  1250. let configArr = this.getProductArrByType(tab);
  1251. let len = configArr.length;
  1252. let data = null;
  1253. let needUpdate = false;
  1254. switch (tab) {
  1255. case ProductType.nzw:
  1256. break;
  1257. case ProductType.dw:
  1258. let id = 30001;
  1259. needUpdate = false;
  1260. let maxId = 0;
  1261. for (var i = 0; i < len; i++) {
  1262. data = this.getPastureDataMap(id);
  1263. if (this.playerProp.orderData.overTimes >= configArr[i].value) {
  1264. if (data.state == PastureState.Lock) {
  1265. data = { id: id, state: PastureState.Empty, productID: configArr[i].picture, growSpan: 0 };
  1266. this.setPastureDataMap(id, data, false);
  1267. needUpdate = true;
  1268. }
  1269. maxId = configArr[i].picture;
  1270. }
  1271. id++;
  1272. }
  1273. if (maxId != 0) {
  1274. //更新最大可购买商品
  1275. this.setMaxProduct(maxId, true);
  1276. }
  1277. //更新到服务器
  1278. if (needUpdate) {
  1279. this.setProp(GameProp.pastureData, this._pastureData);
  1280. this.setNextProduct();
  1281. }
  1282. break;
  1283. default:
  1284. //工厂解锁根据第一个商品
  1285. needUpdate = false;
  1286. let configID = this.getConfigIDByTab(tab);
  1287. data = this.getFactoryDataMap(configID);
  1288. if (this.playerProp.orderData.overTimes >= configArr[0].value) {
  1289. if (data.state == FactroyState.Lock) {
  1290. data = { id: id, state: FactroyState.Empty, productID: 0, growSpan: 0 };
  1291. this.setFactoryDataMap(configID, data, false);
  1292. needUpdate = true;
  1293. }
  1294. //更新最大可购买商品
  1295. this.setMaxProduct(configArr[0].picture, true);
  1296. }
  1297. if (needUpdate) {
  1298. this.setProp(GameProp.factoryData, this._factoryData);
  1299. this.setNextProduct();
  1300. }
  1301. break;
  1302. }
  1303. }
  1304. }
  1305. checkCanSpeedUp(pop = false) {
  1306. let can = false;
  1307. can = gData.farmSystem.canSpeedUp();
  1308. if (!can) {
  1309. can = gData.pastureSystem.canSpeedUp();
  1310. if (!can) {
  1311. can = gData.factorySystem.canSpeedUp();
  1312. }
  1313. }
  1314. if (can && pop) {
  1315. mk.ui.openPanel('module/speedUpUI/speedUp');
  1316. }
  1317. return can;
  1318. }
  1319. setHarvest() {
  1320. gData.farmSystem.setHarvest();
  1321. gData.pastureSystem.setHarvest();
  1322. gData.factorySystem.setHarvest();
  1323. }
  1324. checkCanHarvest() {
  1325. let can = false;
  1326. can = gData.farmSystem.canHarvest();
  1327. if (!can) {
  1328. can = gData.pastureSystem.canHarvest();
  1329. if (!can) {
  1330. can = gData.factorySystem.canHarvest();
  1331. }
  1332. }
  1333. return can;
  1334. }
  1335. checkCanClearSick() {
  1336. let can = false;
  1337. can = gData.farmSystem.canClearSick();
  1338. if (!can) {
  1339. can = gData.pastureSystem.canClearSick();
  1340. if (!can) {
  1341. can = gData.factorySystem.canClearSick();
  1342. }
  1343. }
  1344. return can;
  1345. }
  1346. doPointToXYLogic() {
  1347. let value = mk.storage.getStorage('cash_out');
  1348. if (!value) {
  1349. mk.storage.setStorage('cash_out', 1);
  1350. mk.data.sendXYEvent('cash_1', `第一次提现`);
  1351. } else {
  1352. if (value == 1) {
  1353. mk.storage.setStorage('cash_out', 2);
  1354. mk.data.sendXYEvent('cash_2', `第二次提现`);
  1355. } else if (value == 2) {
  1356. mk.storage.setStorage('cash_out', 3);
  1357. mk.data.sendXYEvent('cash_3', `第三次提现`);
  1358. }
  1359. }
  1360. }
  1361. /** 更新最大可种植产品到服务器 */
  1362. async updateMaxProduct() {
  1363. if (this.maxProductToServer) {
  1364. let data = { "unLockProductList": this._maxProduct };
  1365. // for (let i = 0; i != this._maxProduct.length; ++i) {
  1366. // let dataE = this._maxProduct[i];
  1367. // let d = { id: dataE.productID, tab: dataE.tab };
  1368. // data.unLockProductList.push(d);
  1369. // }
  1370. mk.console.logSingle("updateMaxProduct", data);
  1371. let respone = await mk.http.sendData('orderTask/updateUnlockProduct', data);
  1372. console.log("------");
  1373. }
  1374. }
  1375. }
  1376. /**
  1377. * 所有模块的非校验数据
  1378. */
  1379. export enum GameProp {
  1380. /** -------------------- 通用玩家数据 ------------------------- */
  1381. /** 是否新手 0新手 1老手 */
  1382. newPlayer = 1,
  1383. /** 当前新手引导步骤 */
  1384. guideID = 2,
  1385. /** 需要自动弹界面 每次登录都弹 除首次 表示今日是否要自动开 1自动开 2不自动开 其他不处理*/
  1386. isAutoOpenPanel = 3,
  1387. /** 关闭常规提现时需要自动开存钱罐 每天一次 表示今日有没有开过 */
  1388. isOpenBankOnCloseCash = 4,
  1389. //看视频次数
  1390. videoTimes = 5,
  1391. //提现次数
  1392. cashTimes = 6,
  1393. /** ------------------ 游戏核心数据 --------------------------- */
  1394. /** 农田数据 */
  1395. farmData = 11,
  1396. /** 产品生产次数 */
  1397. productMakeTimes = 12,
  1398. /** 养殖场数据 */
  1399. pastureData = 14,
  1400. /** 工厂数据 */
  1401. factoryData = 15,
  1402. /** 剩余可种植次数 */
  1403. leftTimes = 16,
  1404. /**
  1405. 图鉴领取数据*/
  1406. farmMapGetRewardData = 17,
  1407. //红包任务tag
  1408. redBagTaskRefresh = 18,
  1409. /** ------------------ 转盘数据 ------------------------------ */
  1410. turnable_leftTimes = 20,
  1411. //提现次数
  1412. cashOutTimes = 21,
  1413. }
  1414. /**
  1415. * 玩家数据
  1416. */
  1417. class PlayerProp {
  1418. /** 自定义不需要校验的数据 */
  1419. gameUserData = 0;
  1420. _isSignInToday = 0;
  1421. /**
  1422. * 今日是否有签到
  1423. * - 0 未签到,表示可以签到
  1424. * - 1 有签到,表示不可签到
  1425. */
  1426. set isSignInToday(value: number) {
  1427. this._isSignInToday = value;
  1428. gData.sign.init_data = true;
  1429. gData.gameData.init_red_point = true;
  1430. }
  1431. get isSignInToday(): number {
  1432. return this._isSignInToday;
  1433. }
  1434. private _piggyBank: number = 0;
  1435. /** 存钱罐存款 */
  1436. set piggyBank(value: number) {
  1437. if (this._piggyBank === value) return;
  1438. if (gData.gameData.playerProp.isWithdrawable && value > 0) return;// 存钱罐可提现状态,不能增加存钱罐金额
  1439. this._piggyBank = value;
  1440. gData.gameData.init_coin = true;
  1441. gData.gameData.init_red_point = true;
  1442. }
  1443. get piggyBank(): number {
  1444. return this._piggyBank;
  1445. }
  1446. /** 初始化 */
  1447. initPiggyBank(v) {
  1448. this._piggyBank = v;
  1449. }
  1450. _isWithdrawable = 0;
  1451. /**
  1452. * 存钱罐能否提现
  1453. * - 0 不能提现
  1454. * - 1 能提现
  1455. */
  1456. set isWithdrawable(value: number) {
  1457. if (this._isWithdrawable != value) {
  1458. this._isWithdrawable = value;
  1459. gData.gameData.init_red_point = true;
  1460. }
  1461. }
  1462. get isWithdrawable(): number {
  1463. return this._isWithdrawable;
  1464. }
  1465. /** 存钱罐每日提现次数 */
  1466. piggyBankCashTimes = 0;
  1467. /** 累计存钱罐每日提现次数 */
  1468. totalPiggyBankCashTimes = 0;
  1469. /** 提现进度 */
  1470. cashIndex = 0;
  1471. /** 上次登录时间 */
  1472. lastTime = 0;
  1473. /** 登录天数 */
  1474. loginDays = 0;
  1475. newPlayer = 0;
  1476. private _redMoney: number = 0;
  1477. /** 红包币数量 */
  1478. set redMoney(value: number) {
  1479. this._redMoney = value;
  1480. gData.gameData.init_coin = true;
  1481. //gData.gameData.init_red_point = true;
  1482. gData.gameData.init_wallet_redMoney = true;
  1483. mk.event.emit('refreshCoin');
  1484. mk.data.setTAEventUser(0, 'current_redmoney_stock', this._redMoney);
  1485. }
  1486. get redMoney(): number {
  1487. return this._redMoney;
  1488. }
  1489. _signInDay = 0;
  1490. /** 累计签到次数 客户端理解 上次签到天数 */
  1491. set signInDay(value: number) {
  1492. if (this._signInDay === value) return;
  1493. this._signInDay = value;
  1494. gData.sign.init_data = true;
  1495. }
  1496. get signInDay(): number {
  1497. return this._signInDay;
  1498. }
  1499. /** 转盘次数 */
  1500. turntableTimes = 0;
  1501. /** 版本号 */
  1502. versioncfg = 0;
  1503. /** 福袋数据 */
  1504. userTuCaoInfo = 0;
  1505. /** 能免费领红包 1 表示是新人第一次产出红包币,不用看视频*/
  1506. isFirstRedMoney = 0;
  1507. //农场等级
  1508. gradeLevel = 1;
  1509. //农场等级奖励数据
  1510. farmGradeData: any = {};
  1511. //农场等级名字
  1512. farmGradeName: number = 1;
  1513. //农场经验
  1514. private farmExp = 0;
  1515. set farmExpValue(value: number) {
  1516. this.farmExp = value;
  1517. gData.gameData.init_expLevel = true;
  1518. }
  1519. get farmExpValue(): number {
  1520. return this.farmExp;
  1521. }
  1522. //提现新手数据
  1523. userNoviceWeFareInfo: any = {};
  1524. //提现记录数据
  1525. redMoneyCashPayRecordList = null;
  1526. //任务红;
  1527. userFarmTaskInfo = null;
  1528. getRedMoneyCashOutTimesByIndex(index: number): number {
  1529. if (this.redMoneyCashPayRecordList) {
  1530. for (let i = 0; i != this.redMoneyCashPayRecordList.length; ++i) {
  1531. if (index === this.redMoneyCashPayRecordList[i].index) {
  1532. return this.redMoneyCashPayRecordList[i].frequency;
  1533. }
  1534. }
  1535. }
  1536. return 0;
  1537. }
  1538. /** ABTest分组id */
  1539. groupCode = 0;
  1540. //加速剩余次数
  1541. speedUpLeftTimes = 0;
  1542. /** 农场任务完成次数 */
  1543. completeFarmTaskTimes = 0;
  1544. /** 订单数据 */
  1545. orderData = null;
  1546. /** 临时订单数据, 只用于种植优先选择作用 */
  1547. copyOrderData = null;
  1548. //插队看视频次数限制
  1549. lineRedMoney = 0;
  1550. //当前生产次数
  1551. curProductionAdTimes = 0;
  1552. }
  1553. /**
  1554. * 奖励状态
  1555. */
  1556. export enum RewardState {
  1557. /** 已领取 */
  1558. none = 1,
  1559. /** 未解锁 */
  1560. lock = 2,
  1561. /** 可领取 */
  1562. unlock = 3
  1563. }
  1564. /**
  1565. * 奖励类型
  1566. */
  1567. export enum RewardType {
  1568. /** 红包币 */
  1569. redBag = 1,
  1570. /** 毛币 */
  1571. rmb = 2,
  1572. /** 金猪币 */
  1573. pigRmb = 3,
  1574. /** 生产次数 */
  1575. productTimes = 4,
  1576. }
  1577. /**
  1578. * 音频路径
  1579. */
  1580. export enum AUDIO_TYPE {
  1581. /**主界面背景音乐*/
  1582. bgm = 'bgm',
  1583. /**打开存钱罐界面播放一次*/
  1584. pigBank = 'pigBank',
  1585. /**关卡玩法背景音乐*/
  1586. missionBg = 'missionBg',
  1587. /**红包币领取界面关闭音效*/
  1588. rewardClose = 'rewardClose',
  1589. /**红包币领取界面开启音效*/
  1590. rewardOpen = 'rewardOpen',
  1591. /**红包界面打开音效*/
  1592. reward = 'reward',
  1593. /**提现到账界面打开播放一次*/
  1594. receiptNotice = 'receiptNotice',
  1595. /**通用按钮点击音效 */
  1596. button = 'button',
  1597. /**转盘转动音效*/
  1598. turnableplay = 'turnableplay',
  1599. /**转盘转动音效*/
  1600. turnplateDrawEnd = 'turnplateDrawEnd',
  1601. /**主页背景音乐 */
  1602. music_startBg = "music_startBg",
  1603. /**游戏背景音乐 */
  1604. music_gameBg = "music_gameBg",
  1605. /**按钮点击 */
  1606. ef_button_click = "ef_button_click",
  1607. /**红包打开 */
  1608. ef_redPacket_open = "ef_redPacket_open",
  1609. /**红包来了音效 */
  1610. ef_redPacket_come = "ef_redPacket_come",
  1611. /**消除4个 */
  1612. ef_bonus4 = "ef_bonus4",
  1613. /**消除5个 */
  1614. ef_bonus5 = "ef_bonus5",
  1615. /**消除6个 */
  1616. ef_bonus6 = "ef_bonus6",
  1617. /**消除7个 */
  1618. ef_bonus7 = "ef_bonus7",
  1619. /**消除8个 */
  1620. ef_bonus8 = "ef_bonus8",
  1621. /**普通消除音效 */
  1622. ef_eliminate = "ef_eliminate",
  1623. /**bouns消除音效 */
  1624. ef_eliminate_bonus = "ef_eliminate_bonus",
  1625. /**胜利音效 */
  1626. ef_win = "ef_win",
  1627. /**锤子 */
  1628. ef_change = "ef_change",
  1629. /**刷新 */
  1630. ef_refresh = "ef_refresh",
  1631. /**飞翔 */
  1632. ef_fly = "ef_fly",
  1633. /**关闭按钮音效*/
  1634. closeButton = "closeButton",
  1635. //红包界面打开
  1636. congratulations = 'congratulations',
  1637. //红包飞音效
  1638. redmoney = 'redmoney',
  1639. /**存入银行成功*/
  1640. saveSuccess = 'saveSuccess',
  1641. }
  1642. /** ECPM */
  1643. type ADShowCfg = {
  1644. average_ecpm: number,
  1645. insert_probability: number,
  1646. is_show_banner: number,
  1647. is_show_inter: number,
  1648. }
  1649. /**事件类型 */
  1650. export enum EVENT_TYPE {
  1651. BACK_WxAuth = "BACK_WxAuth",
  1652. UPDATE_CashNum = "UPDATE_CashNum",
  1653. }
  1654. /** 数据事件Id */
  1655. export enum DataEventId {
  1656. /** 点击 */
  1657. guide = "guide",
  1658. /** 点击跳过 */
  1659. guideSkip = "guideSkip",
  1660. /** 按钮点击 */
  1661. button_click = "button_click",
  1662. /** 看视频 */
  1663. video_init = "video_init",
  1664. /** 看视频完成 */
  1665. video_end = "video_end",
  1666. /** 成功拉取全屏视频 */
  1667. interstitial2_init = "interstitial2_init",
  1668. /** 广告点击 */
  1669. Ad_click = "Ad_click",
  1670. /** 全屏视频完成 */
  1671. interstitial2_end = "interstitial2_end",
  1672. /** 福袋功能 */
  1673. fudaiFunction = "fudaiFunction",
  1674. /** 互推功能 */
  1675. hutuiFunction = "hutuiFunction",
  1676. /** 激励视频ecpm */
  1677. ad_videoEcpm = 'ad_video',
  1678. /** 开屏ecpm */
  1679. ad_openEcpm = 'ad_open',
  1680. /** 提现 */
  1681. Sundry = 'Sundry',
  1682. /** 加载 */
  1683. loading = 'loading',
  1684. /** 排队 */
  1685. queue = 'queue',
  1686. //实名认证
  1687. realName = 'realName'
  1688. }
  1689. /** 视频广告类型 */
  1690. export enum VideoAdType {
  1691. video_init_1 = '农场加等级经验',
  1692. video_init_2 = '提现-加进度',
  1693. video_init_3 = '提现-加现金',
  1694. video_init_4 = '签到',
  1695. video_init_5 = '抽奖',
  1696. video_init_6 = '图鉴领奖',
  1697. video_init_7 = '消灭害虫',
  1698. video_init_8 = '恢复健康',
  1699. video_init_9 = '恢复供电',
  1700. video_init_10 = '山羊红包',
  1701. video_init_11 = '拓建',
  1702. video_init_12 = '收获',
  1703. video_init_13 = '飘浮红包',
  1704. video_init_14 = '全体加速',
  1705. video_init_15 = '福利加进度',
  1706. video_init_16 = '生产加次数',
  1707. video_init_17 = '点击生产按钮',
  1708. video_init_18 = '离开游戏领红包',
  1709. video_init_19 = '定时弹出红包',
  1710. video_init_20 = '插队',
  1711. video_init_21 = '恢复生产次数',
  1712. }
  1713. export enum InterFullAdType {
  1714. interstitial2_init_1 = '点击红包的关闭按钮',
  1715. interstitial2_init_2 = '普通收获',
  1716. interstitial2_init_3 = '点击鸟和狗'
  1717. }
  1718. export enum InterAdType {
  1719. interstitial1_click_1 = '恭喜发财红包弹出后',
  1720. interstitial1_click_2 = '恭喜获得弹窗弹出后',
  1721. interstitial1_click_3 = '生虫/生病/停电弹出后'
  1722. }
  1723. export enum BannerAdType {
  1724. banner_click_1 = '恭喜获得弹窗弹出后',
  1725. banner_click_2 = '任务红包',
  1726. banner_click_3 = '恭喜发财红包',
  1727. banner_click_4 = '图鉴',
  1728. banner_click_5 = '全体加速',
  1729. banner_click_6 = '收获弹窗',
  1730. banner_click_7 = '拓建弹窗',
  1731. banner_click_8 = '三个恢复弹窗',
  1732. banner_click_9 = '抽奖'
  1733. }
  1734. export enum ExpAddType {
  1735. EAT_video = 1,
  1736. EAT_harvest = 2,
  1737. EAT_others = 3,
  1738. }
  1739. export enum FarmState {
  1740. Lock,
  1741. CanUnlock,
  1742. Empty,
  1743. Growing,
  1744. Ripe,
  1745. Sick
  1746. }
  1747. export enum PastureState {
  1748. Lock,
  1749. Empty,
  1750. Growing,
  1751. Ripe,
  1752. Sick
  1753. }
  1754. export enum ProductType {
  1755. nzw = '农作物',
  1756. dw = '动物',
  1757. bmhc = '爆米花厂',
  1758. gdp = '糕点铺',
  1759. ztc = '制糖厂',
  1760. lrc = '炼乳厂',
  1761. gfmg = '功夫面馆',
  1762. kcd = '快餐店'
  1763. }
  1764. /** 动物状态 */
  1765. export enum AnimalState {
  1766. Hanger,
  1767. Eat,
  1768. Wait
  1769. }
  1770. export enum FactroyState {
  1771. Lock,
  1772. Empty,
  1773. Producting,
  1774. Ripe,
  1775. Sick
  1776. }