| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492 |
- import Util from "../../before/util/Util";
- import FunBtns from "../game/FunBtns";
- import Game from "../game/Game";
- import { RateConfig } from "./AdData";
- import { StorageKey } from "./StorageData";
- /**
- * @description 游戏核心玩法数据
- * @author 邹勇
- */
- export class GameData {
- public dataFinish: boolean = false;
- public savePropFinish: boolean = false;
- public savePropsFinish: boolean = false;
- public getPropsFnish: boolean = false;
- //是否触摸屏幕
- public isTouchScreen: boolean = false;
- public configs: any = {};
- public adShowConfig: ADShowCfg;
- /** 功能开启 */
- public funOpenData: string[] = [];
- public playerProp: PlayerProp = null;
- /** 标志位:刷新主界面货币 */
- public init_coin: boolean = false;
- public addHb: number = 0;
- public updatePiggyBankValue: boolean = false;
- /** 标志位:刷新主界面头像 */
- public init_head: boolean = false;
- public init_add: boolean = false;
- /** 标志位:刷新主界面红点 */
- public init_red_point: boolean = true;
- //标志位,刷新提现界面的红包币
- public init_wallet_redMoney = false;
- /** 属性存储字典 */
- public props: Map<number, any> = new Map<number, any>();
- public pools = [
- { url: "game/prefab/tips", num: 20 },
- { url: "game/prefab/coin", num: 20 }
- ];
- /** 主页样式脚本 */
- public gameStyle: Game = null;
- /** 入口按钮 */
- public funBtns: FunBtns = null;
- /** 剩余可种植次数 */
- public leftTimes: number = -1;
- /** 最大可种植次数 */
- public maxTimes: number = -1;
- /** 恢复种植次数间隔 */
- public ProductionRecovery: number = 15;
- public init_leftTimes: boolean = false;
- /** 可生产商品配置 */
- public nextCanProduct = null;
- /** 按钮生产选中的农田、牧场或工厂 */
- public nextMake = null;
- /** 类型标识 */
- public nextType = 0;
- /** 刷新生产按钮信息 */
- public init_makeInfo = false;
- /** 正在生产 */
- public isProducting = false;
- /** 标志位 刷新任务描述 */
- public init_task = false;
- public init_expLevel = false;
- //标志位任务跟新
- public init_redBagTask = false;
- //标志位 生产奖励的任务ui刷新
- public init_productTask = false;
- public init_order = false;
- public init_speedup = false;
- 标志位
- public init_hideRedBag = false;
- public shareUrl = '';
- public shareTitle = '';
- public shareDes = '';
- public shareImgUrl = '';
- /** 生虫/生病/停电最多个数 */
- public RawInsectArr = [];
- /** 生虫/生病/停电当前个数 */
- public RawInsectCurArr = [0, 0, 0];
- //恢复生产次数
- public restoreProductTimes = 0;
- /** 最大可种植产品可更新到服务器标识 */
- public maxProductToServer = false;
- public authUIType = 0;
- public prohibiJBAd: string[] = [];
- public prohibitProductionAd: string[] = [];
- public productionAdMaxTimes = 20;
- public popTipCallBack: Function = null;
- public orderAinFinishNum = 0;
- public welfareOpenLimit = 0;
- //订单奖励类型
- orderRewardType = 1;
- //提现X次后显示任务红包
- taskRedBagAutoShowLimit = 0;
- //提现x次后显示生虫
- insectAutoShowLimit = 2;
- //插屏每日限制
- public insertAdLimit = 0;
- //插屏展示开关
- public insertAdSwitch: string[] = [];
- //全屏插屏展示开关
- public fullScreenAdSwitch: string[] = [];
- //是否在做订单刷新动画
- public isDoOrderRefreshAni: boolean = false;
- /**
- * 初始化游戏数据:网络配置信息,用户信息
- * @returns
- */
- public async init() {
- let data: any = { "versionCode": gData.appData.version };
- let response = await mk.http.sendData('getAllConfigInfo', data);
- if (response.errcode != 0) {
- if (response.errcode == -10003 || response.errcode == -20003) {
- //清除缓存
- gData.loginData.reload();
- }
- return;
- }
- mk.console.logSingle("getAllConfigInfo", response.data);
- this.initConfigs(response.data);
- data = {};
- response = await mk.http.sendData('getInfoCrypt', data);
- if (response.errcode != 0) {
- return;
- }
- mk.console.logSingle("getInfoCrypt", response.data);
- this.initPlayerProp(response.data)
- this.initProps(response.data.gameUserData);
- if (gData.warnTipData.curSolution == 4) {
- if (response.data.isSystemRisk == 0) {
- //拉白后重置
- gData.warnTipData.setSolution(0);
- }
- }
- await this.uploadAverageEcpm();
- gData.adData.initEcpmData();
- // data = {};
- // response = await mk.http.sendData('noviceWeFare/getNoviceWeFareInfo', data);
- // if (response.errcode != 0) {
- // return;
- // }
- // this.playerProp.userTuCaoInfo = response.data.userWelFareTaskInfo;
- // mk.console.logSingle("welFare/getUserWelFareTaskInfo", response.data);
- gData.guideData.init();
- gData.guideWeakData.init();
- gData.moduleData.forEach(element => {
- element.init();
- });
- this.dataFinish = true;
- }
- public async uploadAverageEcpm(){
- let data = {};
- let response = await mk.http.sendData('user/adShowConfig', data);
- if (response.errcode != 0) {
- return;
- }
- this.adShowConfig = response.data;
- mk.data.setTAEventUser(0, "average_ecpm", this.adShowConfig.average_ecpm);
- mk.console.logSingle("user/adShowConfig", response.data);
- }
- private initConfigs(data) {
- // console.log('config ', data);
- this.configs = data;
- this.funOpenData = this.configs.ServerConfig.Functionswitch.split(",");
- //从服务器解析配置
- this.setProductMapFromJson();
- gData.loginData.popIdentifySwitch = this.configs.ServerConfig.popIdentifySwitch.split(";");
- this.prohibiJBAd = this.configs.ServerConfig.ProhibitJBAd.split(";");
- this.prohibitProductionAd = this.configs.ServerConfig.ProhibitProductionAd.split(";");
- this.productionAdMaxTimes = this.configs.ServerConfig.ProductionAdMax;
- gData.gameData.shareUrl = this.configs.ServerConfig.shareUrl;
- gData.gameData.shareTitle = this.configs.ServerConfig.shareTitle;
- gData.gameData.shareDes = this.configs.ServerConfig.shareDes;
- gData.gameData.shareImgUrl = this.configs.ServerConfig.shareImgUrl;
- gData.gameData.RawInsectArr = this.configs.ServerConfig.RawInsect.split(',');
- //富翁银行
- gData.safeDepositBoxData.richBankConfig = this.configs.BankTask;
- gData.gameData.welfareOpenLimit = parseInt(this.configs.ServerConfig.welfareOpen);
- gData.gameData.orderRewardType = parseInt(this.configs.ServerConfig.OrderReward);
- //gData.gameData.taskRedBagAutoShowLimit = parseInt(this.configs.ServerConfig.harvestSwitch);
- gData.gameData.insectAutoShowLimit = parseInt(this.configs.ServerConfig.StopProductionSwitch);
- gData.gameData.insertAdLimit = parseInt(this.configs.ServerConfig.InsertAdCash);
- gData.gameData.insertAdSwitch = this.configs.ServerConfig.InsertAdScene.split(",");
- //gData.gameData.fullScreenAdSwitch = this.configs.ServerConfig.FullScreenAdScene.split(",");
- }
- /**
- * 初始化玩家数据
- */
- private initPlayerProp(res_data) {
- this.playerProp = new PlayerProp();
- this.playerProp.cashIndex = res_data.cashIndex;
- this.playerProp.gameUserData = res_data.gameUserData;
- this.playerProp.isSignInToday = res_data.isSignInToday;
- this.playerProp.isWithdrawable = res_data.isWithdrawable;
- this.playerProp.lastTime = res_data.lastTime;
- this.playerProp.loginDays = res_data.loginDays;
- this.playerProp.newPlayer = res_data.newPlayer;
- this.playerProp.initPiggyBank(res_data.piggyBank);
- this.playerProp.piggyBankCashTimes = res_data.piggyBankCashTimes;
- this.playerProp.redMoney = res_data.redMoney == null ? 0 : res_data.redMoney;
- this.playerProp.signInDay = res_data.signInDay;
- this.playerProp.totalPiggyBankCashTimes = res_data.totalPiggyBankCashTimes;
- this.playerProp.turntableTimes = res_data.turntableTimes;
- this.playerProp.versioncfg = res_data.versioncfg;
- this.playerProp.isFirstRedMoney = res_data.isFirstRedMoney;
- gData.adData.watchNumToday = res_data.dayVideoTimesForRedMoney == null ? 0 : res_data.dayVideoTimesForRedMoney;
- this.playerProp.gradeLevel = res_data.farmLevel
- this.playerProp.userTuCaoInfo = res_data.userWelFareTaskInfo;
- this.playerProp.farmExpValue = res_data.userExp;
- this.playerProp.farmGradeData = res_data.userFarmGrageRewardInfo;
- this.playerProp.userNoviceWeFareInfo = res_data.userNoviceWeFareInfo;
- this.playerProp.redMoneyCashPayRecordList = res_data.redMoneyCashPayRecordList;
- this.playerProp.userFarmTaskInfo = res_data.userFarmTaskInfo;
- this.playerProp.speedUpLeftTimes = res_data.speedUpLeftTimes;
- this.playerProp.completeFarmTaskTimes = res_data.completeFarmTaskTimes;
- if (res_data.userOrderTaskInfo) {
- this.playerProp.orderData = res_data.userOrderTaskInfo;
- console.log("============userOrderTaskInfo123");
- }
- this.playerProp.lineRedMoney = res_data.lineRedMoney;
- this.playerProp.groupCode = parseInt(res_data.groupCode);
- //this.playerProp.orderData.overTimes = 3;
- //this.cloneOrderData();
- this.playerProp.curProductionAdTimes = res_data.dailyProductionTimes;
- mk.data.setTAUserID(gData.loginData.uin);
- mk.data.setTAEventUser(0, 'logindays_total', this.playerProp.loginDays);
- if (this.playerProp.completeFarmTaskTimes == 0) {
- mk.data.setTAEventUser(0, 'Cumulative_task', gData.gameData.playerProp.completeFarmTaskTimes);
- }
- if (gData.loginData.isFirstIn) {
- gData.loginData.isFirstIn = false;
- mk.data.setTAEventRegister();
- mk.data.sendDataEvent('ABTest', `触发${this.playerProp.groupCode}方案`);
- console.log(`ABTest=====${this.playerProp.groupCode}`);
- //注册时版本号
- mk.data.setTAEventUserStr(0, 'regtime_app_id', gData.appData.appVersion);
- //星云uid
- mk.data.setTAEventUserStr(0, 'xy_uid', gData.loginData.uin);
- mk.data.setTAEventUser(0, 'farm_lv', gData.gameData.playerProp.gradeLevel);
- }
- //当前版本号
- mk.data.setTAEventUserStr(0, 'now_app_id', gData.appData.appVersion);
- //渠道号
- mk.data.setTAEventUserStr(0, 'channel_id', gData.appData.umengChannel);
- //富翁银行
- gData.safeDepositBoxData.richBankCashAmount = res_data.richBankCashAmount;
- gData.safeDepositBoxData.currentRichBankCashTaskIndex = res_data.currentRichBankCashTaskIndex;
- //gData.safeDepositBoxData.addRichBankFinishIndex = res_data.addRichBankFinishIndex;
- // if (gData.safeDepositBoxData.currentRichBankCashTaskIndex > 0) {
- // gData.safeDepositBoxData.addRichBankFinishIndex = gData.safeDepositBoxData.currentRichBankCashTaskIndex;
- // }
- gData.safeDepositBoxData.isStartBankTask = res_data.isStartRichBankTask;
- gData.safeDepositBoxData.richBankDailyVideoTimes = res_data.richBankDailyVideoTimes;
- gData.safeDepositBoxData.richbankLoginDays = res_data.richbankLoginDays;
- gData.safeDepositBoxData.richBankDailyTotelVideoTimes = res_data.richBankDailyTotelVideoTimes;
- console.log(`richBankDailyTotelVideoTimes ======== ${res_data.richBankDailyTotelVideoTimes}`);
- // //test
- // this.playerProp.completeFarmTaskTimes = 3;
- }
- public cloneOrderData(isRefresh = false) {
- let value = mk.storage.getStorage(StorageKey.copyOrderData);
- if (value && !isRefresh) {
- this.playerProp.copyOrderData = [];
- let v = value.split(",");
- for (let i = 0; i != v.length; ++i) {
- this.playerProp.copyOrderData.push(parseInt(v[i]));
- }
- } else {
- let orderData = this.playerProp.orderData;
- if (orderData) {
- this.playerProp.copyOrderData = [];
- if (orderData && orderData.orderTaskList) {
- let len = orderData.orderTaskList.length;
- for (let i = 0; i != len; ++i) {
- this.playerProp.copyOrderData.push(this.playerProp.orderData.orderTaskList[i].completeCount);
- }
- mk.storage.setStorage(StorageKey.copyOrderData, this.playerProp.copyOrderData);
- }
- }
- }
- mk.console.logSingle('cloneOrderData', this.playerProp.copyOrderData);
- }
- public updateOrderTaskCopyData(id: number) {
- if (this.playerProp.orderData && this.playerProp.orderData.orderTaskList) {
- let productJson = this.configs.Product;
- let orderData = this.playerProp.orderData.orderTaskList;
- let len = orderData.length;
- for (let i = 0; i != len; ++i) {
- let dataE = orderData[i];
- if (dataE.Id <= productJson.length) {
- let productData = productJson[dataE.Id - 1];
- if (productData.picture == id) {
- this.playerProp.copyOrderData[i]++;
- mk.storage.setStorage(StorageKey.copyOrderData, this.playerProp.copyOrderData);
- break;
- }
- }
- }
- } else {
- this.playerProp.copyOrderData = [];
- cc.sys.localStorage.removeItem(StorageKey.copyOrderData);
- }
- }
- public setOrderAniFinishNum() {
- ++this.orderAinFinishNum;
- if (this.orderAinFinishNum >= 3) {
- this.orderAinFinishNum = 0;
- setTimeout(() => {
- mk.event.emit("flyOrderAni");
- }, 500)
- }
- }
- /**
- * 保存单个数据
- */
- public async setProp(key: GameProp, value: any) {
- let data = {
- key: key + '',
- value: value
- };
- this.props.set(key, value);
- await mk.http.sendData('savePlayerProp', data);
- this.savePropFinish = true;
- }
- /**
- * 保存多个数据
- */
- public async setProps(arr: { key: GameProp, value: any }[]) {
- let needProp = {};
- for (let i = 0; i < arr.length; i++) {
- needProp[arr[i].key + ''] = arr[i].value;
- }
- let data = {
- needProp: needProp
- };
- for (let i = 0; i < arr.length; i++) {
- this.props.set(arr[i].key, arr[i].value);
- }
- await mk.http.sendData('saveAllPlayerProp', data);
- this.savePropsFinish = true;
- }
- /** 获取属性 */
- public getProp(key: GameProp): any {
- if (this.props == null) {
- return 0;
- }
- let value = this.props.get(key);
- return value;
- }
- /**
- * 向服务器请求所有属性后更新
- */
- public async getAllProps() {
- let response = await mk.http.sendData('getAllPlayerProp', {});
- if (response.errcode != 0) {
- return;
- }
- this.initProps(response.data);
- this.getPropsFnish = true;
- }
- private initProps(data) {
- if (data == null) {
- return;
- }
- for (let key in data) {
- this.props.set(parseInt(key), data[key]);
- }
- this.setFramDataMapByServer();
- this.setPastureDataMapByServer();
- this.setFactoryDataMapByServer();
- this.initProductTimes();
- this.initLeftTimes();
- this.initFarmMapGetRewardData();
- //this.initCashOutTimes();
- // let isNewTask = this.getProp(GameProp.redBagTaskRefresh);
- // if (isNewTask != undefined) {
- // this.init_redBagTask = isNewTask;
- // }
- }
- private initLeftTimes() {
- let lefttimes = this.getProp(GameProp.leftTimes);
- if (lefttimes == undefined) {
- this.leftTimes = parseInt(this.configs.ServerConfig.FreeProduction);
- this.setProp(GameProp.leftTimes, this.leftTimes);
- }
- else {
- this.leftTimes = lefttimes;
- }
- this.maxTimes = parseInt(this.configs.ServerConfig.ProductionMax);
- this.ProductionRecovery = parseInt(this.configs.ServerConfig.ProductionRecovery);
- // //test
- // this.leftTimes = 1;
- // this.maxTimes = 20;
- // this.ProductionRecovery = 1;
- }
- /** 增加减少生产次数
- * @param add 增减变量
- */
- public async changeLeftTimes(add, isIgnoreMaxTimes = false, isRefresh = true) {
- gData.gameData.leftTimes += add;
- if (add > 0 && !isIgnoreMaxTimes) {
- gData.gameData.leftTimes = (gData.gameData.leftTimes > gData.gameData.maxTimes ? gData.gameData.maxTimes : gData.gameData.leftTimes);
- }
- if (gData.gameData.leftTimes < 0) {
- gData.gameData.leftTimes = 0;
- }
- await gData.gameData.setProp(GameProp.leftTimes, gData.gameData.leftTimes);
- if (isRefresh) {
- gData.gameData.init_leftTimes = true;
- }
- }
- //图鉴领取数据
- private _farmMapRewardData = [];
- public getFarmMapRewardState(index) {
- if (index.i < this._farmMapRewardData.length) {
- if (index.j < this._farmMapRewardData[index.i].length) {
- return this._farmMapRewardData[index.i][index.j];
- }
- }
- return 1;
- }
- public setFarmMapRewardState(index, state) {
- if (index.i < this._farmMapRewardData.length) {
- if (index.j < this._farmMapRewardData[index.i].length) {
- this._farmMapRewardData[index.i][index.j] = state;
- this.setProp(GameProp.farmMapGetRewardData, this._farmMapRewardData);
- }
- }
- }
- private initFarmMapGetRewardData() {
- this._farmMapRewardData = this.getProp(GameProp.farmMapGetRewardData);
- if (!this._farmMapRewardData) {
- this._farmMapRewardData = [];
- }
- let needSync = false;
- let index = 0;
- this._productTypeMap.forEach((value, key) => {
- if (this._farmMapRewardData.length <= index) {
- let len = value.length;
- let arr = [];
- for (let i = 0; i != len; ++i) {
- arr.push(0);
- }
- this._farmMapRewardData.push(arr);
- needSync = true;
- } else {
- let data = this._farmMapRewardData[index];
- let len = value.length;
- for (let i = 0; i != len; ++i) {
- if (i >= data.length) {
- data.push(0);
- needSync = true;
- }
- }
- }
- ++index;
- });
- if (needSync) {
- this.setProp(GameProp.farmMapGetRewardData, this._farmMapRewardData);
- }
- }
- //提现次数
- public _cashOutTimes = 0;
- public initCashOutTimes() {
- let v = this.getProp(GameProp.cashOutTimes);
- if (v) {
- this._cashOutTimes = v;
- } else {
- this._cashOutTimes = 0;
- }
- }
- public addCashOutTimes() {
- this._cashOutTimes += 1;
- console.log(`===========${this._cashOutTimes}`);
- this.setProp(GameProp.cashOutTimes, this._cashOutTimes);
- }
- /** 是否是新用户 */
- public isNewPlayer(): boolean {
- let v = this.getProp(GameProp.newPlayer);
- return v == 0;
- }
- //*********** ================= 农场数据 ================== */
- /** 农田数据 服务器数据 */
- private _farmData = [];
- /** 农田字典 本地数据,方便操作*/
- private _farmDataMap: Map<number, any> = new Map();
- //刷新农田
- public needFreshArr = [];
- /** 随机获取可种植物品 */
- getRandomPlantConfig(out?: any) {
- let id = 0;
- let isNoHaveCurTab = true;
- let isNoAllComplete = false;
- let isOrderDataInvalid = false;
- let isMatchSuccess = false;
- let productType = [];
- let animalId = [];
- let data = this.playerProp.orderData;
- if (data) {
- let orderData = data.orderTaskList;
- let productJson = this.configs.Product;
- for (let i = 0; i != orderData.length; ++i) {
- let dataE = orderData[i];
- if (dataE.completeCount < dataE.taskCount) {
- if (dataE.Id <= productJson.length) {
- isNoAllComplete = true;
- let productData = productJson[dataE.Id - 1];
- if (productData.tab == ProductType.nzw) {
- let max = this.getMaxProductExtra(ProductType.nzw);
- if (max && productData.picture <= max) {
- id = productData.picture;
- isNoHaveCurTab = false;
- isMatchSuccess = true;
- this.nextType = 1;
- mk.console.logSingle("getRandomPlantConfig=>", id);
- break;
- }
- } else if (productData.tab == ProductType.dw) {
- animalId.push(productData.picture);
- } else {
- productType.push(productData.tab);
- }
- } else {
- isOrderDataInvalid = true;
- break;
- }
- }
- }
- if (!isMatchSuccess) {
- // let picId = this.doFarmMapDataCheck(0);
- // if (picId) {
- // id = picId;
- // } else
- {
- id = Util.rnd(10001, this.getMaxProductExtra(ProductType.nzw));
- this.nextType = 1
- }
- }
- } else {
- isOrderDataInvalid = true;
- // let picId = this.doFarmMapDataCheck(0);
- // if (picId) {
- // id = picId;
- // } else
- {
- id = Util.rnd(10001, this.getMaxProductExtra(ProductType.nzw));
- this.nextType = 1
- }
- }
- //选择逻辑处理
- if (isOrderDataInvalid) {
- return this.getProductMap(id);
- } else {
- if (isNoHaveCurTab) {
- if (isNoAllComplete) {
- let isHaveEmpty = false;
- for (let i = 0; i != productType.length; ++i) {
- let factoryIcon = gData.factorySystem.factoryIcons;
- let len = factoryIcon.length;
- for (var j = 0; j < len; j++) {
- let tab = this.getTabByConfigID(factoryIcon[j].configID);
- if (tab == productType[i] && factoryIcon[j].data.state == FactroyState.Empty) {
- isHaveEmpty = true;
- out.state = 1;
- break;
- }
- }
- }
- if (!isHaveEmpty) {
- for (let i = 0; i != animalId.length; ++i) {
- let pastureIcon = gData.pastureSystem.pastureIcons;
- let len = pastureIcon.length;
- for (var j = 0; j < len; j++) {
- if (pastureIcon[j].data.productID == animalId[i] && pastureIcon[j].data.state == PastureState.Empty) {
- isHaveEmpty = true;
- out.state = 2;
- break;
- }
- }
- }
- }
- if (isHaveEmpty) {
- return null;
- } else {
- return this.getProductMap(id);
- }
- } else {
- return this.getProductMap(id);
- }
- } else {
- return this.getProductMap(id);
- }
- }
- //id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
- //return this.getProductMap(id);
- }
- getRandomPlantConfigExtra(out: any) {
- let id = 0;
- let cropArray = [];
- let factoryArray = [];
- let animalArray = [];
- let data = this.playerProp.orderData;
- if (data) {
- let orderData = data.orderTaskList;
- let productJson = this.configs.Product;
- for (let i = 0; i != orderData.length; ++i) {
- let dataE = orderData[i];
- if (dataE.completeCount < dataE.taskCount) {
- if (dataE.Id <= productJson.length) {
- let productData = productJson[dataE.Id - 1];
- if (productData.tab == ProductType.nzw) {
- let max = this.getMaxProductExtra(ProductType.nzw);
- if (max && productData.picture <= max) {
- cropArray.push(productData.picture);
- }
- } else if (productData.tab == ProductType.dw) {
- animalArray.push(productData.picture);
- } else {
- factoryArray.push(productData);
- }
- }
- }
- }
- //从三种类型随机选择逻辑
- let typeArr = [];
- let matchSuccessFactorys = null;
- let matchSuccessPastures = null;
- if (cropArray.length > 0) {
- typeArr.push(0);
- }
- if (factoryArray.length > 0) {
- matchSuccessFactorys = gData.factorySystem.isHaveEmptyFactory(factoryArray);
- if (matchSuccessFactorys.length > 0) {
- typeArr.push(1);
- }
- }
- if (animalArray.length > 0) {
- matchSuccessPastures = gData.pastureSystem.isHaveEmptyPasture(animalArray);
- if (matchSuccessPastures.length > 0) {
- typeArr.push(2);
- }
- }
- if (typeArr.length > 0) {
- let rand = mk.math.random(0, typeArr.length - 1);
- let type = typeArr[rand];
- if (type == 0) {
- let randCrop = mk.math.random(0, cropArray.length - 1);
- id = cropArray[randCrop];
- this.nextType = 1
- return this.getProductMap(id);
- } else if (type == 1) {
- let randFactory = mk.math.random(0, matchSuccessFactorys.length - 1);
- let factory = matchSuccessFactorys[randFactory];
- this.nextCanProduct = this.getProductMap(factory.picture);
- this.nextMake = factory.key;
- this.nextType = 3;
- return this.nextMake;
- } else if (type == 2) {
- let randPasture = mk.math.random(0, matchSuccessPastures.length - 1);
- let pasture = matchSuccessPastures[randPasture];
- this.nextCanProduct = this.getProductMap(pasture.data.productID);
- this.nextMake = pasture
- this.nextType = 2;
- return pasture;
- }
- } else {
- id = Util.rnd(10001, this.getMaxProductExtra(ProductType.nzw));
- this.nextType = 1
- return this.getProductMap(id);
- }
- } else {
- id = Util.rnd(10001, this.getMaxProductExtra(ProductType.nzw));
- this.nextType = 1
- return this.getProductMap(id);
- }
- }
- public doJudgeOrderLogic(out?: any) {
- let data = this.playerProp.orderData;
- if (data) {
- let orderData = data.orderTaskList;
- let productJson = this.configs.Product;
- for (let i = 0; i != orderData.length; ++i) {
- let dataE = orderData[i];
- if (dataE.completeCount < dataE.taskCount) {
- if (dataE.Id <= productJson.length) {
- let productData = productJson[dataE.Id - 1];
- if (productData.tab == ProductType.nzw) {
- continue;
- } else if (productData.tab == ProductType.dw) {
- let pastureIcon = gData.pastureSystem.pastureIcons;
- let len = pastureIcon.length;
- for (var j = 0; j < len; j++) {
- if (pastureIcon[j].data.productID == productData.picture && pastureIcon[j].data.state == PastureState.Empty) {
- out.state = 2;
- return;
- }
- }
- } else {
- let factoryIcon = gData.factorySystem.factoryIcons;
- let len = factoryIcon.length;
- for (var j = 0; j < len; j++) {
- let tab = this.getTabByConfigID(factoryIcon[j].configID);
- if (tab == productData.tab && factoryIcon[j].data.state == FactroyState.Empty) {
- out.state = 1;
- return;
- }
- }
- }
- }
- }
- }
- }
- }
- /** 随机获取可生产产品 */
- getRandomFactoryConfig(configID) {
- let tab = gData.gameData.getTabByConfigID(configID);
- let arr = this.getProductArrByType(tab);
- let max = this.getMaxProductExtra(tab);
- let canArr = [];
- let len = arr.length;
- for (var i = 0; i < len; i++) {
- if (arr[i].picture <= max) {
- canArr.push(arr[i].picture);
- if (arr[i].picture == max) {
- break;
- }
- }
- }
- let index = Util.rnd(0, canArr.length - 1);
- let id = canArr[index];
- return this.getProductMap(id);
- }
- public doFarmMapDataCheck(startIndex: number, isHaveEmpty?: any) {
- let value = 0;
- for (let key in ProductType) {
- if (startIndex <= value) {
- let max = this.getMaxProductExtra(ProductType[key]);
- if (max) {
- let list_data = this.getProductArrByType(ProductType[key]);
- for (let i = 0; i != list_data.length; ++i) {
- let picId = list_data[i].picture - 1;
- if (list_data[i].unlock == 1 && picId == max) {
- let state = this.getFarmMapRewardState(this.getIndex(list_data[i]));
- if (state == 0) {
- switch (ProductType[key]) {
- case ProductType.nzw:
- this.nextType = 1
- return picId;
- case ProductType.dw:
- {
- let pastureIconsData = gData.pastureSystem.pastureIcons;
- let len = pastureIconsData.length;
- for (let index = 0; index < len; index++) {
- if (pastureIconsData[index].data.state == PastureState.Empty) {
- if (isHaveEmpty && startIndex == value) {
- isHaveEmpty.state = true;
- }
- if (picId == pastureIconsData[index].data.productID) {
- this.nextCanProduct = this.getProductMap(pastureIconsData[index].data.productID);
- this.nextMake = pastureIconsData[index];
- this.nextType = 2;
- return picId;
- }
- }
- }
- }
- break;
- default:
- {
- let factoryIconsData = gData.factorySystem.factoryIcons;
- let len = factoryIconsData.length;
- for (let index = 0; index < len; index++) {
- if (factoryIconsData[index].data.state == FactroyState.Empty) {
- if (isHaveEmpty) {
- isHaveEmpty.state = true;
- }
- let tab = this.getTabByConfigID(factoryIconsData[index].configID);
- if (tab == ProductType[key]) {
- this.nextCanProduct = this.getProductMap(picId);
- this.nextMake = factoryIconsData[index];
- this.nextType = 3;
- return picId;
- }
- }
- }
- }
- break;
- }
- }
- }
- }
- }
- }
- ++value;
- }
- return null;
- }
- /** 自动生产选中下一个 */
- setNextProduct(sel = true) {
- if (this.nextMake) {
- return;
- }
- //-1无效,0:有空地,1:工厂有空位,2:饲养厂有空位
- let haveEmpty = { state: -1 };
- let next = gData.farmSystem.selectNextFarm(haveEmpty, sel);
- if (!next) {
- //订单随机种植此处可注释掉
- // if (haveEmpty.state == -1) {
- // this.doJudgeOrderLogic(haveEmpty);
- // }
- //let next1 = gData.pastureSystem.nextPasture(haveEmpty);
- // let next1 = gData.pastureSystem.nextPastureExtra();
- // if (!next1) {
- // //let next2 = gData.factorySystem.nextFactory(haveEmpty);
- // let next2 = gData.factorySystem.nextFactoryExtra();
- // if (!next2) {
- // this.nextType = 0;
- // }
- // else {
- // //this.nextType = 3;
- // }
- // }
- // else {
- // //this.nextType = 2;
- // }
- this.nextType = 0;
- }
- else {
- //this.nextType = 1;
- }
- this.init_makeInfo = true;
- }
- hasFirstCheck = false;
- firstCheckNext() {
- if (!this.hasFirstCheck && gData.farmSystem.farms.length >= 18
- && gData.pastureSystem.pastureIcons.length >= 3 && gData.factorySystem.factoryIcons.length >= 6) {
- this.hasFirstCheck = true;
- Util.objSortByKey(gData.farmSystem.farms, 'sortID');
- Util.objSortByKey(gData.pastureSystem.pastureIcons, 'sortID');
- Util.objSortByKey(gData.factorySystem.factoryIcons, 'sortID');
- gData.gameData.setNextProduct(false);
- }
- }
- async makeProduct() {
- let flyRed = true;
- switch (this.nextType) {
- case 0:
- //mk.tip.pop('农场已满,无法继续生产');
- //弹出收获、生虫、加速
- if (!this.checkCanHarvest()) {
- if (!this.checkCanClearSick()) {
- this.checkCanSpeedUp(true);
- }
- }
- flyRed = false;
- break;
- case 1:
- if (this.popSpeedUpByRate()) {
- flyRed = false;
- } else {
- flyRed = await gData.farmSystem.btnMake();
- gData.adData.checkPopRed();
- }
- break;
- case 2:
- if (this.popSpeedUpByRate()) {
- flyRed = false;
- } else {
- flyRed = await gData.pastureSystem.btnMake();
- gData.adData.checkPopRed();
- }
- break;
- case 3:
- if (this.popSpeedUpByRate()) {
- flyRed = false;
- } else {
- flyRed = await gData.factorySystem.btnMake();
- gData.adData.checkPopRed();
- }
- break;
- }
- return flyRed;
- }
- public async updateNewTaskProgress(isNeedRefresh = false) {
- if (gData.gameData.funOpenData[4] == "0") {
- return false;
- }
- if (this.playerProp.userFarmTaskInfo) {
- let com = this.playerProp.userFarmTaskInfo.completeCount;
- let count = this.playerProp.userFarmTaskInfo.taskCount;
- if (com >= count) {
- if (!this.gameStyle.getIsCanGetOrderReward()) {
- mk.tip.pop('任务红包进度已满,快去提现');
- } else {
- mk.tip.pop("订单已完成,快领奖吧!");
- }
- return false;
- }
- }
- let data = {};
- let response = await mk.http.sendData('farmTask/updateUserFarmTaskInfo', data);
- mk.console.logSingle('refrehTask=>', response);
- if (response.errcode != 0) {
- return false;
- }
- gData.gameData.init_task = true;
- this.playerProp.userFarmTaskInfo = response.data.userFarmTaskInfo;
- if (this.playerProp.userFarmTaskInfo.completeCount >= this.playerProp.userFarmTaskInfo.taskCount) {
- //mk.ui.closeAllUI();
- //mk.guide.open(4);
- }
- // if (isNeedRefresh) {
- // gData.gameData.init_task = true;
- // }
- return true;
- }
- public setFarmDataMap(id, data, sendToServer = true) {
- this._farmDataMap.set(id, data);
- let len = this._farmData.length;
- for (var i = 0; i < len; i++) {
- if (this._farmData[i].id == id) {
- this._farmData[i].state = data.state;
- this._farmData[i].productID = data.productID;
- this._farmData[i].growSpan = data.growSpan;
- break;
- }
- }
- this.needFreshArr.push(id);
- //更新到服务器
- if (sendToServer) {
- this.freshSendToServer(1);
- }
- }
- public getFarmDataMap(id) {
- return this._farmDataMap.get(id);
- }
- /** 服务器数据设置到本地 */
- public setFramDataMapByServer() {
- this._farmData = this.getProp(GameProp.farmData);
- if (!this._farmData) {
- this._farmData = [];
- }
- let len = this._farmData.length;
- //新玩家初始化农田数据
- if (len < 18) {
- let id = 31000;
- let data = null;
- let unluckNum = parseInt(gData.gameData.configs.ServerConfig.unluckNum);
- for (var i = 0; i < 18; i++) {
- if (i < unluckNum) {
- data = { id: id, state: FarmState.Empty, productID: 0, growSpan: 0 };
- }
- else if (i == unluckNum) {
- data = { id: id, state: FarmState.CanUnlock, productID: 0, growSpan: 0 };
- }
- else {
- data = { id: id, state: FarmState.Lock, productID: 0, growSpan: 0 };
- }
- this._farmData.push(data);
- this._farmDataMap.set(id, data);
- id++;
- }
- //第一次初始数据
- // this.setMaxProduct(10003);
- //更新到服务器
- this.setProp(GameProp.farmData, this._farmData);
- }
- else {
- let sickTimes = 0;
- for (var i = 0; i < len; i++) {
- this._farmDataMap.set(this._farmData[i].id, this._farmData[i]);
- if (this._farmData[i].state == FarmState.Sick) {
- sickTimes++;
- }
- }
- this.RawInsectCurArr[0] = sickTimes;
- }
- //this.setMaxProduct(10003, true);
- }
- /** puduct配置数据 <picture, config> */
- private _productMap: Map<number, any> = new Map();
- /** puduct类型配置数据 <tab, 类型数组> */
- private _productTypeMap: Map<string, any> = new Map();
- /** 设置puduct配置数据 */
- public setProductMapFromJson() {
- let productJson = this.configs.Product;
- // // 先用本地数据
- // let productJson = gData.configData.configMap.get('product');
- let len = productJson.length;
- let product = null;
- let tab = '';
- let arr = [];
- for (var i = 0; i < len; i++) {
- product = productJson[i];
- this._productMap.set(product.picture, product);
- if (tab != product.tab) {
- arr = [];
- this._productTypeMap.set(product.tab, arr);
- tab = product.tab;
- }
- arr.push(product);
- }
- }
- /** 根据id获取单个数据 */
- public getProductMap(id) {
- return this._productMap.get(id);
- }
- /** 根据tab获取数组 */
- public getProductArrByType(type: ProductType) {
- return this._productTypeMap.get(type);
- }
- //根据tab获取最大id的数据
- public getMaxProductDataByType(type: ProductType, id) {
- let arr = this._productTypeMap.get(type);
- let len = arr.length;
- if (arr[len - 1].picture >= id) {
- return this.getProductMap(id);
- } else {
- return null;
- }
- }
- /** 产品生产/种植次数 服务器数据 */
- private _productMakeTimesData: any = {};
- /** 产品生产/种植次数 */
- private _productMakeTimesMap: Map<number, number> = new Map();
- //产品解锁最大id
- private _productUnlockMaxId: Map<string, number> = new Map();
- private initProductTimes() {
- let needUpdate = false;
- let value = this.getProp(GameProp.productMakeTimes);
- if (!value) {
- this._productMakeTimesData.makeTimes = [];
- this._productMakeTimesData.productUnlockMaxId = new Map<string, number>();
- this._productMakeTimesData.productUnlockMaxId.set(ProductType.nzw, 10003);
- } else {
- if (value instanceof Array) {
- this._productMakeTimesData.makeTimes = value;
- this._productMakeTimesData.productUnlockMaxId = new Map<string, number>();
- this._productMakeTimesData.productUnlockMaxId.set(ProductType.nzw, 10003);
- let len = value.length;
- for (let i = 0; i != len; ++i) {
- let data = value[i];
- let config = this.getProductMap(data.id);
- let v = this._productMakeTimesData.productUnlockMaxId.get(config.tab);
- if (v) {
- if (v < data.id) {
- this._productMakeTimesData.productUnlockMaxId.set(config.tab, data.id);
- }
- } else {
- this._productMakeTimesData.productUnlockMaxId.set(config.tab, data.id);
- }
- }
- needUpdate = true;
- } else {
- this._productMakeTimesData.makeTimes = value.makeTimes;
- this._productMakeTimesData.productUnlockMaxId = this.objToMap(JSON.parse(value.productUnlockMaxId));
- }
- }
- let len = this._productMakeTimesData.makeTimes.length;
- for (var i = 0; i < len; i++) {
- this._productMakeTimesMap.set(this._productMakeTimesData.makeTimes[i].id, this._productMakeTimesData.makeTimes[i].times);
- //this.setMaxProduct(this._productMakeTimesData.makeTimes[i].id);
- }
- let isUpdate = this.judgeAddExtraUnlockMaxId();
- if (needUpdate || isUpdate) {
- this.updateDataToSever();
- }
- }
- async addProductMakeTimesById(id: number) {
- let isAddMaxProduct = false;
- let times = this._productMakeTimesMap.get(id);
- if (!times) {
- times = 0;
- }
- times++;
- this._productMakeTimesMap.set(id, times);
- //更新到服务器
- let has = false;
- let len = this._productMakeTimesData.makeTimes.length;
- for (var i = 0; i < len; i++) {
- if (this._productMakeTimesData.makeTimes[i].id == id) {
- this._productMakeTimesData.makeTimes[i].times = times;
- has = true;
- break;
- }
- }
- if (!has) {
- let data = { 'id': id, 'times': times };
- this._productMakeTimesData.makeTimes.push(data);
- }
- //设置可种植/生产最大id
- let nextID = id + 1;
- let curConfig = this.getProductMap(id);
- let nextConfig = this.getProductMap(nextID);
- if (id == this.getMaxProductExtra(curConfig.tab)) {
- if (nextConfig) {
- gData.plantData.init_itemIndex = nextID;
- }
- }
- if (nextConfig) {
- if (nextConfig.tab == curConfig.tab && nextID > this.getMaxProductExtra(curConfig.tab)) {
- if (nextConfig.unlock == 1 && nextConfig.value <= times) {
- isAddMaxProduct = true;
- this._productMakeTimesMap.set(nextID, 0);
- let data = { 'id': nextID, 'times': 0 };
- this._productMakeTimesData.makeTimes.push(data);
- this._productMakeTimesData.productUnlockMaxId.set(nextConfig.tab, nextID);
- //this.setMaxProduct(nextID);
- //需要更新最大生产id
- gData.farmMapData.isStateChange = true;
- this.updateMaxProduct();
- let nConfig = this.getProductMap(nextID + 1);
- if (nConfig) {
- gData.plantData.init_lock = nextID + 1;
- }
- }
- }
- }
- if (!isAddMaxProduct) {
- mk.event.emit("refreshFarmMapUI");
- }
- let sss: any = {};
- sss.makeTimes = this._productMakeTimesData.makeTimes;
- let json = this.mapToObj(this._productMakeTimesData.productUnlockMaxId);
- sss.productUnlockMaxId = JSON.stringify(json);
- await this.setProp(GameProp.productMakeTimes, sss);
- }
- mapToObj(mapData) {
- let obj = {};
- mapData.forEach(function (value, key) {
- obj[key] = value;
- });
- return obj;
- }
- objToMap(obj) {
- let map = new Map();
- for (let k in obj) {
- map.set(k, obj[k]);
- }
- return map;
- }
- //设置解锁的最大id
- addProductUnlockMaxId(tab, id) {
- if (this._productMakeTimesData.productUnlockMaxId) {
- let productId = this._productMakeTimesData.productUnlockMaxId.get(tab);
- if (productId) {
- if (id > productId) {
- this._productMakeTimesData.productUnlockMaxId.set(tab, id);
- console.log(`addProductUnlockMaxId====${tab}====${id}`);
- return true;
- }
- } else {
- console.log(`addProductUnlockMaxId22====${tab}====${id}`);
- this._productMakeTimesData.productUnlockMaxId.set(tab, id);
- return true;
- }
- return false;
- }
- return false;
- }
- //判断前面解锁需要数值大于后面解锁数值的情况
- public judgeAddExtraUnlockMaxId() {
- let isUpdateToSever = false;
- if (this._productMakeTimesData.productUnlockMaxId) {
- let data = this._productMakeTimesData.productUnlockMaxId;
- data.forEach((value, key) => {
- if (key != ProductType.dw) {
- let product = this.getMaxProductDataByType(key, value + 1);
- if (product && product.unlock == 1) {
- let makeTimes = this.getProductMakeTimesById(value);
- if (makeTimes >= product.value) {
- this.addProductUnlockMaxId(key, product.picture);
- isUpdateToSever = true;
- }
- }
- }
- });
- }
- return isUpdateToSever;
- }
- updateDataToSever() {
- let sss: any = {};
- sss.makeTimes = this._productMakeTimesData.makeTimes;
- let json = this.mapToObj(this._productMakeTimesData.productUnlockMaxId);
- sss.productUnlockMaxId = JSON.stringify(json);
- this.setProp(GameProp.productMakeTimes, sss);
- }
- getProductMakeTimesById(id: number) {
- let times = this._productMakeTimesMap.get(id);
- if (!times) {
- times = 0
- }
- return times;
- }
- getProductUnlockById(tab, id: number) {
- if (this._productMakeTimesData.productUnlockMaxId) {
- let productId = this._productMakeTimesData.productUnlockMaxId.get(tab);
- if (productId) {
- if (productId >= id) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
- return false;
- }
- //------------- 养殖场数据-----------
- /** 养殖场数据 服务器数据 */
- private _pastureData = [];
- /** 养殖场字典 本地数据,方便操作*/
- private _pastureDataMap: Map<number, any> = new Map();
- public setPastureDataMap(id, data, sendToServer = true) {
- this._pastureDataMap.set(id, data);
- let len = this._pastureData.length;
- for (var i = 0; i < len; i++) {
- if (this._pastureData[i].id == id) {
- this._pastureData[i].state = data.state;
- this._pastureData[i].productID = data.productID;
- this._pastureData[i].growSpan = data.growSpan;
- break;
- }
- }
- this.needFreshArr.push(id);
- //更新到服务器
- if (sendToServer) {
- this.freshSendToServer(2);
- }
- }
- public getPastureDataMap(id) {
- return this._pastureDataMap.get(id);
- }
- /** 服务器数据设置到本地 */
- public setPastureDataMapByServer() {
- this._pastureData = this.getProp(GameProp.pastureData);
- if (!this._pastureData) {
- this._pastureData = [];
- }
- let len = this._pastureData.length;
- //新玩家初始化养殖场数据
- if (len < 3) {
- let arr = this.getProductArrByType(ProductType.dw);
- let len1 = arr.length;
- let id = 30001;
- let data = null;
- for (var i = 0; i < len1; i++) {
- if (this.playerProp.orderData) {
- if (this.playerProp.orderData.overTimes < arr[i].value) {
- data = { id: id, state: PastureState.Lock, productID: arr[i].picture, growSpan: 0 };
- }
- else {
- data = { id: id, state: PastureState.Empty, productID: arr[i].picture, growSpan: 0 };
- }
- } else {
- data = { id: id, state: PastureState.Lock, productID: arr[i].picture, growSpan: 0 };
- }
- this._pastureData.push(data);
- this._pastureDataMap.set(id, data);
- id++;
- }
- //更新到服务器
- this.setProp(GameProp.pastureData, this._pastureData);
- }
- else {
- let sickTimes = 0;
- for (var i = 0; i < len; i++) {
- this._pastureDataMap.set(this._pastureData[i].id, this._pastureData[i]);
- if (this._pastureData[i].state == PastureState.Sick) {
- sickTimes++;
- }
- }
- this.RawInsectCurArr[1] = sickTimes;
- }
- }
- //------------- 工厂数据-----------
- /** 工厂数据 服务器数据 */
- private _factoryData = [];
- /** 工厂字典 本地数据,方便操作*/
- private _factoryDataMap: Map<number, any> = new Map();
- public setFactoryDataMap(id, data, sendToServer = true) {
- this._factoryDataMap.set(id, data);
- let len = this._factoryData.length;
- for (var i = 0; i < len; i++) {
- if (this._factoryData[i].id == id) {
- this._factoryData[i].state = data.state;
- this._factoryData[i].productID = data.productID;
- this._factoryData[i].growSpan = data.growSpan;
- break;
- }
- }
- this.needFreshArr.push(id);
- //更新到服务器
- if (sendToServer) {
- this.freshSendToServer(3);
- }
- }
- public getFactoryDataMap(id) {
- return this._factoryDataMap.get(id);
- }
- /** 服务器数据设置到本地 */
- public setFactoryDataMapByServer() {
- this._factoryData = this.getProp(GameProp.factoryData);
- if (!this._factoryData) {
- this._factoryData = [];
- }
- let isUpdate = false;
- let len = this._factoryData.length;
- //新玩家初始化工厂数据
- if (len < 6) {
- let id = 30004;
- let data = null;
- let tab = null;
- for (var i = 0; i < 6; i++) {
- tab = this.getTabByConfigID(id);
- let arr = this.getProductArrByType(tab);
- if (this.playerProp.orderData) {
- if (this.playerProp.orderData.overTimes < arr[0].value) {
- data = { id: id, state: FactroyState.Lock, productID: 0, growSpan: 0 };
- }
- else {
- data = { id: id, state: FactroyState.Empty, productID: 0, growSpan: 0 };
- //更新最大可购买商品
- //this.setMaxProduct(arr[0].picture, true);
- // let is = this.addProductUnlockMaxId(tab, arr[0].picture);
- // if(!isUpdate)
- // {
- // isUpdate = is;
- // }
- }
- } else {
- data = { id: id, state: FactroyState.Lock, productID: 0, growSpan: 0 };
- }
- this._factoryData.push(data);
- this._factoryDataMap.set(id, data);
- id++;
- }
- //更新到服务器
- this.setProp(GameProp.factoryData, this._factoryData);
- }
- else {
- let sickTimes = 0;
- let id = 30004;
- let tab = null;
- for (var i = 0; i < len; i++) {
- tab = this.getTabByConfigID(id);
- let arr = this.getProductArrByType(tab);
- this._factoryDataMap.set(this._factoryData[i].id, this._factoryData[i]);
- if (this._factoryData[i].state == FactroyState.Sick) {
- sickTimes++;
- }
- id++;
- }
- this.RawInsectCurArr[2] = sickTimes;
- }
- // if(isUpdate)
- // {
- // this.updateDataToSever();
- // }
- }
- /** 通过工厂建筑物ID获取标签 */
- getTabByConfigID(configID: number): ProductType {
- let tab = ProductType.bmhc;
- switch (configID) {
- case 30004:
- tab = ProductType.bmhc;
- break;
- case 30005:
- tab = ProductType.gdp;
- break;
- case 30006:
- tab = ProductType.ztc;
- break;
- case 30007:
- tab = ProductType.lrc;
- break;
- case 30008:
- tab = ProductType.gfmg;
- break;
- case 30009:
- tab = ProductType.kcd;
- break;
- }
- return tab;
- }
- /** 通过标签获取工厂建筑物ID */
- getConfigIDByTab(tab: ProductType): number {
- let configID = 0;
- switch (tab) {
- case ProductType.bmhc:
- configID = 30004;
- break;
- case ProductType.gdp:
- configID = 30005;
- break;
- case ProductType.ztc:
- configID = 30006;
- break;
- case ProductType.lrc:
- configID = 30007;
- break;
- case ProductType.gfmg:
- configID = 30008;
- break;
- case ProductType.kcd:
- configID = 30009;
- break;
- }
- return configID;
- }
- getIndex(data) {
- let index: any = {};
- index.i = 0;
- index.j = 0;
- switch (data.tab) {
- case '农作物':
- index.i = 0;
- index.j = data.picture - 10001;
- break;
- case '动物':
- index.i = 1;
- index.j = data.picture - 20001;
- break;
- case '爆米花厂':
- index.i = 2;
- index.j = data.picture - 20004;
- break;
- case '糕点铺':
- index.i = 3;
- index.j = data.picture - 20013;
- break;
- case '制糖厂':
- index.i = 4;
- index.j = data.picture - 20010;
- break;
- case '炼乳厂':
- index.i = 5;
- index.j = data.picture - 20007;
- break;
- case '功夫面馆':
- index.i = 6;
- index.j = data.picture - 20025;
- break;
- case '快餐店':
- index.i = 7;
- index.j = data.picture - 20019;
- break;
- }
- return index;
- }
- /** 发送数据到服务器 */
- freshSendToServer(type) {
- switch (type) {
- case 1:
- this.setProp(GameProp.farmData, this._farmData);
- break;
- case 2:
- this.setProp(GameProp.pastureData, this._pastureData);
- break;
- case 3:
- this.setProp(GameProp.factoryData, this._factoryData);
- break;
- }
- }
- /** 最大可种植/生产商品数组 */
- private _maxProduct = [];
- public getMaxProduct(tab) {
- if (this._maxProduct) {
- let len = this._maxProduct.length;
- let data = null;
- for (var i = 0; i < len; i++) {
- data = this._maxProduct[i];
- if (data.tab == tab) {
- return data.productID;
- }
- }
- }
- return null;
- }
- getMaxProductExtra(tab) {
- if (this._productMakeTimesData.productUnlockMaxId) {
- let productId = this._productMakeTimesData.productUnlockMaxId.get(tab);
- return productId;
- }
- return null;
- }
- /** 设置最大可生产商品
- * @param id 产品id
- * @param unlock 是否是解锁增加
- */
- public setMaxProduct(id, unlock = false) {
- let config = this.getProductMap(id);
- if (!this._maxProduct) {
- this._maxProduct = [];
- }
- let len = this._maxProduct.length;
- let data = null;
- let has = false;
- for (var i = 0; i < len; i++) {
- data = this._maxProduct[i];
- if (data.tab == config.tab) {
- if (data.productID < id) {
- data.productID = id;
- data.id = config.id;
- }
- has = true;
- break;
- }
- }
- if (!has && unlock) {
- data = { tab: config.tab, productID: id, id: config.id };
- this._maxProduct.push(data);
- }
- gData.farmMapData.isStateChange = true;
- this.updateMaxProduct();
- }
- /** 农场升级时解锁工厂,检查最大可种植/生产商品 */
- public checkTaskFinishUnLock() {
- let isUpdateToSever = false;
- for (var key in ProductType) {
- let tab = ProductType[key];
- let configArr = this.getProductArrByType(tab);
- let len = configArr.length;
- let data = null;
- let needUpdate = false;
- switch (tab) {
- case ProductType.nzw:
- break;
- case ProductType.dw:
- let id = 30001;
- needUpdate = false;
- let maxId = 0;
- for (var i = 0; i < len; i++) {
- data = this.getPastureDataMap(id);
- if (this.playerProp.orderData) {
- if (this.playerProp.orderData.overTimes >= configArr[i].value) {
- if (data.state == PastureState.Lock) {
- data = { id: id, state: PastureState.Empty, productID: configArr[i].picture, growSpan: 0 };
- this.setPastureDataMap(id, data, false);
- needUpdate = true;
- }
- maxId = configArr[i].picture;
- }
- }
- id++;
- }
- console.log(`checkTaskFinishUnLock11=====${maxId}`);
- if (maxId != 0) {
- //更新最大可购买商品
- //this.setMaxProduct(maxId, true);
- let is = this.addProductUnlockMaxId(tab, maxId);
- if (!isUpdateToSever) {
- isUpdateToSever = is;
- }
- }
- //更新到服务器
- if (needUpdate) {
- this.setProp(GameProp.pastureData, this._pastureData);
- this.setNextProduct();
- }
- break;
- default:
- //工厂解锁根据第一个商品
- needUpdate = false;
- let configID = this.getConfigIDByTab(tab);
- data = this.getFactoryDataMap(configID);
- if (this.playerProp.orderData) {
- if (this.playerProp.orderData.overTimes >= configArr[0].value) {
- if (data.state == FactroyState.Lock) {
- data = { id: id, state: FactroyState.Empty, productID: 0, growSpan: 0 };
- this.setFactoryDataMap(configID, data, false);
- needUpdate = true;
- }
- //更新最大可购买商品
- //this.setMaxProduct(configArr[0].picture, true);
- console.log(`checkTaskFinishUnLock222=====${maxId}`);
- let is = this.addProductUnlockMaxId(tab, configArr[0].picture);
- if (!isUpdateToSever) {
- isUpdateToSever = is;
- }
- }
- }
- if (needUpdate) {
- this.setProp(GameProp.factoryData, this._factoryData);
- this.setNextProduct();
- }
- break;
- }
- }
- if (isUpdateToSever) {
- console.log('===================isUpdateToSever222');
- this.updateDataToSever();
- //需要更新最大生产id
- gData.farmMapData.isStateChange = true;
- this.updateMaxProduct();
- }
- }
- checkCanSpeedUp(pop = false) {
- let can = false;
- can = gData.farmSystem.canSpeedUp();
- if (!can) {
- can = gData.pastureSystem.canSpeedUp();
- if (!can) {
- can = gData.factorySystem.canSpeedUp();
- }
- }
- if (can && pop) {
- mk.ui.openPanel('module/speedUpUI/speedUp');
- }
- return can;
- }
- popSpeedUpByRate() {
- let isPop = false;
- let rate = gData.adData.getPerByEcpm(RateConfig.RC_popSpeedUp);
- if (rate >= Math.random()) {
- isPop = gData.pastureSystem.canSpeedUp();
- if (!isPop) {
- isPop = gData.factorySystem.canSpeedUp();
- }
- }
- if (isPop) {
- mk.ui.openPanel('module/speedUpUI/speedUp');
- }
- return isPop;
- }
- setHarvest() {
- gData.farmSystem.setHarvest();
- gData.pastureSystem.setHarvest();
- gData.factorySystem.setHarvest();
- }
- checkCanHarvest() {
- let can = false;
- can = gData.farmSystem.canHarvest();
- if (!can) {
- can = gData.pastureSystem.canHarvest();
- if (!can) {
- can = gData.factorySystem.canHarvest();
- }
- }
- return can;
- }
- checkCanClearSick() {
- let can = false;
- can = gData.farmSystem.canClearSick();
- if (!can) {
- can = gData.pastureSystem.canClearSick();
- if (!can) {
- can = gData.factorySystem.canClearSick();
- }
- }
- return can;
- }
- doPointToXYLogic() {
- let value = mk.storage.getStorage('cash_out');
- if (!value) {
- mk.storage.setStorage('cash_out', 1);
- mk.data.sendXYEvent('cash_1', `第一次提现`);
- } else {
- if (value == 1) {
- mk.storage.setStorage('cash_out', 2);
- mk.data.sendXYEvent('cash_2', `第二次提现`);
- } else if (value == 2) {
- mk.storage.setStorage('cash_out', 3);
- mk.data.sendXYEvent('cash_3', `第三次提现`);
- }
- }
- }
- /** 更新最大可种植产品到服务器 */
- async updateMaxProduct() {
- if (this.maxProductToServer) {
- //let data = { "unLockProductList": this._maxProduct };
- let data = { "unLockProductList": [] };
- let maxProductData = this._productMakeTimesData.productUnlockMaxId;
- maxProductData.forEach((value, key) => {
- let config = this.getProductMap(value);
- let d = { tab: key, productID: value, id: config.id };
- data.unLockProductList.push(d);
- });
- mk.console.logSingle("updateMaxProduct", data);
- let respone = await mk.http.sendData('orderTask/updateUnlockProduct', data);
- console.log("------");
- }
- }
- popTableScreenADLogic(type: number) {
- let str = null;
- switch (type) {
- case 0:
- str = InterAdType.interstitial1_click_1;
- break;
- case 1:
- str = InterAdType.interstitial1_click_2;
- break;
- case 2:
- str = InterAdType.interstitial1_click_3;
- break;
- case 3:
- str = InterAdType.interstitial1_click_4;
- break;
- case 4:
- str = InterAdType.interstitial1_click_5;
- break;
- case 5:
- str = InterAdType.interstitial1_click_6;
- break;
- case 6:
- str = InterAdType.interstitial1_click_7;
- break;
- case 7:
- str = InterAdType.interstitial1_click_8;
- break;
- case 8:
- str = InterAdType.interstitial1_click_9;
- break;
- case 9:
- str = InterAdType.interstitial1_click_10;
- break;
- case 10:
- str = InterAdType.interstitial1_click_11;
- break;
- case 11:
- str = InterAdType.interstitial1_click_12;
- break;
- case 12:
- str = InterAdType.interstitial1_click_13;
- break;
- case 13:
- str = InterAdType.interstitial1_click_14;
- break;
- case 14:
- str = InterAdType.interstitial1_click_15;
- break;
- case 15:
- str = InterAdType.interstitial1_click_16;
- break;
- case 16:
- str = InterAdType.interstitial1_click_17;
- break;
- case 17:
- str = InterAdType.interstitial1_click_18;
- break;
- }
- let index = 0;
- let rateType = null;
- if(type <= 11){
- index = type;
- }else{
- index = 12;
- rateType = RateConfig.RC_afterVideo;
- }
- if(str != null){
- let cashTimes = gData.gameData.getProp(GameProp.cashTimes);
- console.log(`===========${cashTimes}`);
- let is = gData.gameData.insertAdSwitch[index];
- if(is == "1" && cashTimes >= gData.gameData.insertAdLimit){
- gData.adData.checkPopInter(str, rateType);
- }
- }
- }
- }
- /**
- * 所有模块的非校验数据
- */
- export enum GameProp {
- /** -------------------- 通用玩家数据 ------------------------- */
- /** 是否新手 0新手 1老手 */
- newPlayer = 1,
- /** 当前新手引导步骤 */
- guideID = 2,
- /** 需要自动弹界面 每次登录都弹 除首次 表示今日是否要自动开 1自动开 2不自动开 其他不处理*/
- isAutoOpenPanel = 3,
- /** 关闭常规提现时需要自动开存钱罐 每天一次 表示今日有没有开过 */
- isOpenBankOnCloseCash = 4,
- //看视频次数
- videoTimes = 5,
- //提现次数
- cashTimes = 6,
- /** ------------------ 游戏核心数据 --------------------------- */
- /** 农田数据 */
- farmData = 11,
- /** 产品生产次数 */
- productMakeTimes = 12,
- /** 养殖场数据 */
- pastureData = 14,
- /** 工厂数据 */
- factoryData = 15,
- /** 剩余可种植次数 */
- leftTimes = 16,
- /**
- 图鉴领取数据*/
- farmMapGetRewardData = 17,
- //红包任务tag
- redBagTaskRefresh = 18,
- /** ------------------ 转盘数据 ------------------------------ */
- turnable_leftTimes = 20,
- //提现次数
- cashOutTimes = 21,
- }
- /**
- * 玩家数据
- */
- class PlayerProp {
- /** 自定义不需要校验的数据 */
- gameUserData = 0;
- _isSignInToday = 0;
- /**
- * 今日是否有签到
- * - 0 未签到,表示可以签到
- * - 1 有签到,表示不可签到
- */
- set isSignInToday(value: number) {
- this._isSignInToday = value;
- gData.sign.init_data = true;
- gData.gameData.init_red_point = true;
- }
- get isSignInToday(): number {
- return this._isSignInToday;
- }
- private _piggyBank: number = 0;
- /** 存钱罐存款 */
- set piggyBank(value: number) {
- if (this._piggyBank === value) return;
- if (gData.gameData.playerProp.isWithdrawable && value > 0) return;// 存钱罐可提现状态,不能增加存钱罐金额
- this._piggyBank = value;
- gData.gameData.init_coin = true;
- gData.gameData.init_red_point = true;
- }
- get piggyBank(): number {
- return this._piggyBank;
- }
- /** 初始化 */
- initPiggyBank(v) {
- this._piggyBank = v;
- }
- _isWithdrawable = 0;
- /**
- * 存钱罐能否提现
- * - 0 不能提现
- * - 1 能提现
- */
- set isWithdrawable(value: number) {
- if (this._isWithdrawable != value) {
- this._isWithdrawable = value;
- gData.gameData.init_red_point = true;
- }
- }
- get isWithdrawable(): number {
- return this._isWithdrawable;
- }
- /** 存钱罐每日提现次数 */
- piggyBankCashTimes = 0;
- /** 累计存钱罐每日提现次数 */
- totalPiggyBankCashTimes = 0;
- /** 提现进度 */
- cashIndex = 0;
- /** 上次登录时间 */
- lastTime = 0;
- /** 登录天数 */
- loginDays = 0;
- newPlayer = 0;
- private _redMoney: number = 0;
- /** 红包币数量 */
- set redMoney(value: number) {
- this._redMoney = value;
- gData.gameData.init_coin = true;
- //gData.gameData.init_red_point = true;
- gData.gameData.init_wallet_redMoney = true;
- mk.event.emit('refreshCoin');
- if(!mk.guide.isGuideComplete() && this._redMoney >= 300000){
- let isHaveUI = mk.ui.isPopPanel();
- if(!isHaveUI && !gData.gameData.isDoOrderRefreshAni){
- mk.ui.closePanel("newOpenRedBag");
- mk.guide.open(13);
- }
- }
- mk.data.setTAEventUser(0, 'current_redmoney_stock', this._redMoney);
- }
- get redMoney(): number {
- return this._redMoney;
- }
- _signInDay = 0;
- /** 累计签到次数 客户端理解 上次签到天数 */
- set signInDay(value: number) {
- if (this._signInDay === value) return;
- this._signInDay = value;
- gData.sign.init_data = true;
- }
- get signInDay(): number {
- return this._signInDay;
- }
- /** 转盘次数 */
- turntableTimes = 0;
- /** 版本号 */
- versioncfg = 0;
- /** 福袋数据 */
- userTuCaoInfo = 0;
- /** 能免费领红包 1 表示是新人第一次产出红包币,不用看视频*/
- isFirstRedMoney = 0;
- //农场等级
- gradeLevel = 1;
- //农场等级奖励数据
- farmGradeData: any = {};
- //农场等级名字
- farmGradeName: number = 1;
- //农场经验
- private farmExp = 0;
- set farmExpValue(value: number) {
- this.farmExp = value;
- gData.gameData.init_expLevel = true;
- }
- get farmExpValue(): number {
- return this.farmExp;
- }
- //提现新手数据
- userNoviceWeFareInfo: any = {};
- //提现记录数据
- redMoneyCashPayRecordList = null;
- //任务红;
- userFarmTaskInfo = null;
- getRedMoneyCashOutTimesByIndex(index: number): number {
- if (this.redMoneyCashPayRecordList) {
- for (let i = 0; i != this.redMoneyCashPayRecordList.length; ++i) {
- if (index === this.redMoneyCashPayRecordList[i].index) {
- return this.redMoneyCashPayRecordList[i].frequency;
- }
- }
- }
- return 0;
- }
- /** ABTest分组id */
- groupCode = 0;
- //加速剩余次数
- speedUpLeftTimes = 0;
- /** 农场任务完成次数 */
- completeFarmTaskTimes = 0;
- /** 订单数据 */
- orderData = null;
- /** 临时订单数据, 只用于种植优先选择作用 */
- copyOrderData = null;
- //插队看视频次数限制
- lineRedMoney = 0;
- //当前生产次数
- curProductionAdTimes = 0;
- }
- /**
- * 奖励状态
- */
- export enum RewardState {
- /** 已领取 */
- none = 1,
- /** 未解锁 */
- lock = 2,
- /** 可领取 */
- unlock = 3
- }
- /**
- * 奖励类型
- */
- export enum RewardType {
- /** 红包币 */
- redBag = 1,
- /** 毛币 */
- rmb = 2,
- /** 金猪币 */
- pigRmb = 3,
- /** 生产次数 */
- productTimes = 4,
- }
- /**
- * 音频路径
- */
- export enum AUDIO_TYPE {
- /**主界面背景音乐*/
- bgm = 'bgm',
- /**打开存钱罐界面播放一次*/
- pigBank = 'pigBank',
- /**关卡玩法背景音乐*/
- missionBg = 'missionBg',
- /**红包币领取界面关闭音效*/
- rewardClose = 'rewardClose',
- /**红包币领取界面开启音效*/
- rewardOpen = 'rewardOpen',
- /**红包界面打开音效*/
- reward = 'reward',
- /**提现到账界面打开播放一次*/
- receiptNotice = 'receiptNotice',
- /**通用按钮点击音效 */
- button = 'button',
- /**转盘转动音效*/
- turnableplay = 'turnableplay',
- /**转盘转动音效*/
- turnplateDrawEnd = 'turnplateDrawEnd',
- /**主页背景音乐 */
- music_startBg = "music_startBg",
- /**游戏背景音乐 */
- music_gameBg = "music_gameBg",
- /**按钮点击 */
- ef_button_click = "ef_button_click",
- /**红包打开 */
- ef_redPacket_open = "ef_redPacket_open",
- /**红包来了音效 */
- ef_redPacket_come = "ef_redPacket_come",
- /**消除4个 */
- ef_bonus4 = "ef_bonus4",
- /**消除5个 */
- ef_bonus5 = "ef_bonus5",
- /**消除6个 */
- ef_bonus6 = "ef_bonus6",
- /**消除7个 */
- ef_bonus7 = "ef_bonus7",
- /**消除8个 */
- ef_bonus8 = "ef_bonus8",
- /**普通消除音效 */
- ef_eliminate = "ef_eliminate",
- /**bouns消除音效 */
- ef_eliminate_bonus = "ef_eliminate_bonus",
- /**胜利音效 */
- ef_win = "ef_win",
- /**锤子 */
- ef_change = "ef_change",
- /**刷新 */
- ef_refresh = "ef_refresh",
- /**飞翔 */
- ef_fly = "ef_fly",
- /**关闭按钮音效*/
- closeButton = "closeButton",
- //红包界面打开
- congratulations = 'congratulations',
- //红包飞音效
- redmoney = 'redmoney',
- /**存入银行成功*/
- saveSuccess = 'saveSuccess',
- }
- /** ECPM */
- type ADShowCfg = {
- average_ecpm: number,
- insert_probability: number,
- is_show_banner: number,
- is_show_inter: number,
- }
- /**事件类型 */
- export enum EVENT_TYPE {
- BACK_WxAuth = "BACK_WxAuth",
- UPDATE_CashNum = "UPDATE_CashNum",
- }
- /** 数据事件Id */
- export enum DataEventId {
- /** 点击 */
- guide = "guide",
- /** 点击跳过 */
- guideSkip = "guideSkip",
- /** 按钮点击 */
- button_click = "button_click",
- /** 看视频 */
- video_init = "video_init",
- /** 看视频完成 */
- video_end = "video_end",
- /** 成功拉取全屏视频 */
- interstitial2_init = "interstitial2_init",
- /** 广告点击 */
- Ad_click = "Ad_click",
- /** 全屏视频完成 */
- interstitial2_end = "interstitial2_end",
- /** 福袋功能 */
- fudaiFunction = "fudaiFunction",
- /** 互推功能 */
- hutuiFunction = "hutuiFunction",
- /** 激励视频ecpm */
- ad_videoEcpm = 'ad_video',
- /** 开屏ecpm */
- ad_openEcpm = 'ad_open',
- /** 提现 */
- Sundry = 'Sundry',
- /** 加载 */
- loading = 'loading',
- /** 排队 */
- queue = 'queue',
- /** 实名认证 */
- realName = 'realName',
- /** 离线生产次数弹出 */
- offlineProductTimes = "offlineProductTimes",
- /**触发提现到达上限 */
- cashLimit = "cashLimit",
- /**互推红包弹出位置 */
- htRedBag_scene = "htRedBag_scene",
- /**互推红包领取次数*/
- htRedBag_eject = "htRedBag_eject",
- /**插屏广告弹出*/
- interstita11_eject = "interstita11_eject"
- }
- /** 视频广告类型 */
- export enum VideoAdType {
- video_init_1 = '农场加等级经验',
- video_init_2 = '提现-加进度',
- video_init_3 = '提现-加现金',
- video_init_4 = '签到',
- video_init_5 = '抽奖',
- video_init_6 = '图鉴领奖',
- video_init_7 = '消灭害虫',
- video_init_8 = '恢复健康',
- video_init_9 = '恢复供电',
- video_init_10 = '山羊红包',
- video_init_11 = '拓建',
- video_init_12 = '收获',
- video_init_13 = '飘浮红包',
- video_init_14 = '全体加速',
- video_init_15 = '福利加进度',
- video_init_16 = '生产加次数',
- video_init_17 = '点击生产按钮',
- video_init_18 = '离开游戏领红包',
- video_init_19 = '定时弹出红包',
- video_init_20 = '插队',
- video_init_21 = '恢复生产次数',
- //video_init_22 = '长时间未操作弹出视频',
- }
- export enum InterFullAdType {
- interstitial2_init_1 = '点击红包的关闭按钮',
- interstitial2_init_2 = '普通收获',
- interstitial2_init_3 = '点击鸟和狗',
- interstitial2_init_4 = '长时间未操作弹出',
- // interstitial2_init_4 = '关闭个人资料页',
- // interstitial2_init_5 = '关闭农场等级奖励界面',
- // interstitial2_init_6 = '关闭红包币提现界面',
- // interstitial2_init_7 = '关闭抽奖界面',
- // interstitial2_init_8 = '关闭任务红包界面',
- // interstitial2_init_9 = '关闭更多游戏界面',
- // interstitial2_init_10 = '关闭图鉴界面',
- // interstitial2_init_11 = '关闭生虫、生病、停电弹窗',
- // interstitial2_init_12 = '关闭全体加速界面',
- // interstitial2_init_13 = '关闭收获弹窗',
- // interstitial2_init_14 = '关闭富翁银行',
- // interstitial2_init_15 = '关闭福利界面',
- // interstitial2_init_16 = '一键生产-关闭领取生产次数弹窗',
- // interstitial2_init_17 = '红包币提现界面,点击提现按钮',
- // interstitial2_init_18 = '福利-点击提现按钮',
- // interstitial2_init_19 = '订单-点击订单提现按钮',
- // interstitial2_init_20 = '任务红包-点击领取按钮',
- // interstitial2_init_21 = '富翁银行-点击开始任务按钮',
- // interstitial2_init_22 = '富翁银行-点击提现按钮',
- }
- export enum InterAdType {
- interstitial1_click_1 = '恭喜发财红包弹出后',
- interstitial1_click_2 = '恭喜获得弹窗弹出后',
- interstitial1_click_3 = '生虫/生病/停电弹出后',
- interstitial1_click_4 = '关闭抽奖界面后',
- interstitial1_click_5 = '关闭任务红包后',
- interstitial1_click_6 = '关闭富翁银行后',
- interstitial1_click_7 = '打开领取生产次数界面',
- interstitial1_click_8 = '农作物点击可收获',
- interstitial1_click_9 = '关闭全体加速后',
- interstitial1_click_10 = '关闭福利后',
- interstitial1_click_11 = '打开个人资料页',
- interstitial1_click_12 = '打开更多游戏页',
- interstitial1_click_13 = '全体加速激励视频播完后',
- interstitial1_click_14 = '离线奖励激励视频播完后',
- interstitial1_click_15 = '抽奖激励视频播完后',
- interstitial1_click_16 = '图鉴领奖激励视频播完后',
- interstitial1_click_17 = '拓建激励视频播完后',
- interstitial1_click_18 = '收获超级加倍激励视频播完后',
- //interstitial1_click_19 = '定时弹出插屏',
- }
- export enum BannerAdType {
- banner_click_1 = '恭喜获得弹窗弹出后',
- banner_click_2 = '任务红包',
- banner_click_3 = '恭喜发财红包',
- banner_click_4 = '图鉴',
- banner_click_5 = '全体加速',
- banner_click_6 = '收获弹窗',
- banner_click_7 = '拓建弹窗',
- banner_click_8 = '三个恢复弹窗',
- banner_click_9 = '抽奖'
- }
- export enum ExpAddType {
- EAT_video = 1,
- EAT_harvest = 2,
- EAT_others = 3,
- }
- export enum FarmState {
- Lock,
- CanUnlock,
- Empty,
- Growing,
- Ripe,
- Sick
- }
- export enum PastureState {
- Lock,
- Empty,
- Growing,
- Ripe,
- Sick
- }
- export enum ProductType {
- nzw = '农作物',
- dw = '动物',
- bmhc = '爆米花厂',
- gdp = '糕点铺',
- ztc = '制糖厂',
- lrc = '炼乳厂',
- gfmg = '功夫面馆',
- kcd = '快餐店'
- }
- /** 动物状态 */
- export enum AnimalState {
- Hanger,
- Eat,
- Wait
- }
- export enum FactroyState {
- Lock,
- Empty,
- Producting,
- Ripe,
- Sick
- }
- //功能开关含义
- export enum FunctionSwitch {
- FS_farmGrade = 0, //农场等级奖励
- FS_cashOutBtn = 1, //主界面提现按钮
- FS_sign = 2, //签到
- FS_turntable = 3, //抽奖转盘
- FS_redPacketTash = 4, //任务红包
- FS_welfareBtn = 5, //福利按钮
- FS_inviteBtn = 6, //邀请按钮
- FS_floatRedPacket = 7, //漂浮红包
- FS_electBtn = 8, //互推按钮
- FS_sheepRedPacket = 9, //山羊红包
- FS_addCashBtn = 10, //提现界面的加现金按钮
- FS_order = 11, //订单
- FS_floatFarmMap = 12, //图鉴浮窗
- FS_richManBank = 13 //富翁银行
- }
|