| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601 |
- import Util from "../../before/util/Util";
- import JsbSystem from "../../mk/system/JsbSystem";
- import TimeUtil from "../../mk/utils/TimeUtil";
- import SetGray from "../component/SetGray";
- import { AdFun, RateConfig } from "../data/AdData";
- import { DataEventId, FarmState, GameProp, ProductType, VideoAdType } from "../data/GameData";
- import FunBtns from "./FunBtns";
- const { ccclass, property } = cc._decorator;
- @ccclass("RedPoinNode")
- export class RedPoinNode {
- @property({ type: cc.Node, displayName: "等级奖励" })
- node_gradeReward: cc.Node = null;
- @property({ type: cc.Node, displayName: "签到" })
- node_sign: cc.Node = null;
- @property({ type: cc.Node, displayName: '轮盘' })
- node_turnable: cc.Node = null;
- }
- @ccclass
- export default class Game extends cc.Component {
- @property({ type: cc.Node, displayName: "功能按钮" })
- node_btn: cc.Node = null;
- @property({ type: cc.Label, displayName: "红包币" })
- lbl_redMoney: cc.Label = null;
- @property({ type: cc.Sprite, displayName: "红包提现" })
- btn_cashOutNormal: cc.Sprite = null;
- @property({ type: cc.Sprite, displayName: "金猪提现" })
- btn_cashOutGold: cc.Sprite = null;
- @property({ type: cc.Node, displayName: "红包币图标" })
- icon_hb: cc.Node = null;
- @property({ type: cc.Node, displayName: "金猪币图标" })
- icon_zb: cc.Node = null;
- @property({ type: cc.Node, displayName: "顶部ui组" })
- node_top_ui: cc.Node = null;
- @property({ type: RedPoinNode, displayName: "红点组" })
- nodeRedPoint: RedPoinNode = null;
- @property({ type: cc.Sprite, displayName: "要种植植物图片" })
- icon_plant: cc.Sprite = null;
- @property({ type: cc.Sprite, displayName: "要种植植物名称" })
- icon_plantName: cc.Sprite = null;
- @property({ type: cc.Label, displayName: "种植次数文本" })
- lbl_leftTimes: cc.Label = null;
- @property({ type: cc.RichText, displayName: '任务文本' })
- lbl_task: cc.RichText = null;
- @property({ type: cc.Node, displayName: '任务红包节点' })
- node_taskHb: cc.Node = null;
- @property({ type: cc.Node, displayName: '生产按钮节点' })
- btn_product: cc.Node = null;
- @property({ type: cc.Label, displayName: '等级文本' })
- lbl_farmLevel: cc.Label = null;
- @property({ type: cc.Sprite, displayName: '等级进度' })
- sp_levelPer: cc.Sprite = null;
- @property({ type: cc.Animation, displayName: '增加效果文本' })
- ani_add: cc.Animation = null;
- @property({ type: cc.Node, displayName: '任务红包手' })
- node_hand: cc.Node = null;
- @property({ type: cc.Sprite, displayName: '等级名字' })
- sp_gradeName: cc.Sprite = null;
- @property({ type: cc.Node, displayName: '增加效果文本2' })
- ani_add2: cc.Node = null;
- @property({ type: cc.Node, displayName: '增加效果文本3' })
- ani_add3: cc.Node = null;
- @property({ type: cc.Node, displayName: '加经验效果' })
- node_addExp: cc.Node = null;
- @property({ type: cc.Label, displayName: '加经验文本' })
- lbl_addExp: cc.Label = null;
- @property({ type: cc.Node, displayName: '加红包币效果' })
- node_addHb: cc.Node = null;
- @property({ type: cc.Label, displayName: '加红包币文本' })
- lbl_addHb: cc.Label = null;
- //图鉴部分
- @property({ type: cc.Node, displayName: '图鉴ui总节点' })
- node_farmMapUI: cc.Node = null;
- @property({ type: cc.Node, displayName: '图鉴领奖节点' })
- node_farmMapGetReward: cc.Node = null;
- @property({ type: cc.Node, displayName: '图鉴种植节点' })
- node_farmMapProduct: cc.Node = null;
- @property({ type: cc.RichText, displayName: '描述' })
- lbl_farmMapDes: cc.RichText = null;
- @property({ displayName: '数字组', type: cc.Label })
- lbl_value: cc.Label[] = [];
- //订单部分
- @property({ displayName: '农作物图标', type: cc.Sprite })
- sp_cropIcon: cc.Sprite[] = [];
- @property({ displayName: '农作物名字', type: cc.Label })
- lbl_cropName: cc.Label[] = [];
- @property({ displayName: '农作物进度', type: cc.Label })
- lbl_progress: cc.Label[] = [];
- @property({ displayName: '进度完成对勾', type: cc.Sprite })
- sp_mark: cc.Sprite[] = [];
- @property({ displayName: '订单红包币数字组', type: cc.Label })
- lbl_redMoneyValue: cc.Label[] = [];
- @property({ displayName: '领奖按钮', type: SetGray })
- node_getOrderReward: SetGray = null;
- @property({ displayName: '手指', type: cc.Node })
- node_orderHand: cc.Node = null;
- @property({ type: cc.Node, displayName: '增加效果文本2' })
- ani_add4: cc.Node = null;
- @property({ displayName: '现金', type: cc.Label })
- lbl_addCash: cc.Label = null;
- @property({ displayName: '红包币图标', type: cc.Node })
- node_orderHb: cc.Node = null;
- @property({ displayName: '额外订单ui节点', type: cc.Node })
- node_extraOrderUi: cc.Node = null;
- @property({ displayName: '额外订单背景节点', type: cc.Node })
- node_bgUi: cc.Node = null;
- @property({ displayName: '订单显示', type: cc.Node })
- node_crop: cc.Node[] = [];
- @property({ displayName: '订单红包', type: cc.Node })
- node_orderHbIcon: cc.Node = null;
- @property({ displayName: '显示现金', type: cc.Node })
- node_showCash: cc.Node = null;
- @property({ displayName: '显示红包币', type: cc.Node })
- node_showRedMoney: cc.Node = null;
- @property({ displayName: '订单红包币', type: cc.Label })
- lbl_orderRedMoney: cc.Label = null;
- @property({ displayName: '提现进度', type: cc.Sprite })
- pro_tixian: cc.Sprite = null;
- @property({ displayName: '提现进度文本', type: cc.Label })
- lbl_cashPro: cc.Label = null;
- @property({ displayName: '富翁银行进度', type: cc.Sprite })
- pro_bank: cc.Sprite = null;
- @property({ displayName: '富翁银行文本', type: cc.Label })
- lbl_bankPro: cc.Label = null;
- @property({ displayName: '富翁银行按钮', type: cc.Node })
- btn_safebox: cc.Node = null;
- posY = 0;
- /** 是否开始增加次数倒计时 */
- private lastTimeSpan = 0;
- private span = 0;
- private autoPopSign = true;
- private isShowAddProductTimesUI = false;
- private is
- onLoad() {
- this.posY = this.ani_add2.y;
- this.ani_add.node.active = false;
- gData.gameData.gameStyle = this;
- this.span = gData.gameData.ProductionRecovery * 60 * 1000;
- gData.gameData.checkTaskFinishUnLock();
- gData.gameData.maxProductToServer = true;
- gData.gameData.updateMaxProduct();
- this.registerCallBack();
- console.log("===[Jsbsystem 显示开屏广告================================")
- if (mk.ad.ifShowAd) {
- let rand = Math.random();
- let rate = gData.adData.getPerByEcpm(RateConfig.RC_splash);
- if (rand <= rate) {
- JsbSystem.showSplash();
- }
- }
- this.initRefreshEvent();
- if (gData.gameData.orderRewardType == 1) {
- this.node_showCash.active = false;
- this.node_showRedMoney.active = true;
- }
- if (gData.gameData.playerProp.orderData) {
- this.initOrderUI();
- } else {
- mk.event.register("initOrderUi", this.initOrderUI.bind(this), this);
- }
- let times = gData.gameData.getProp(GameProp.plantTimes);
- console.log(`cashTimes======${times}`);
- if (times == undefined) {
- times = 0;
- }
- if (times < gData.gameData.showRichBankIconLimit) {
- this.btn_safebox.active = false;
- mk.event.register("showRichBankIcon", this.showRichBankIcon.bind(this), this);
- }
- }
- async showRichBankIcon() {
- this.btn_safebox.active = true;
- mk.event.remove("showRichBankIcon", this);
- if (!gData.safeDepositBoxData.currentRichBankCashTaskIndex) {
- let response = await mk.http.sendData('newrichbank/getRichBankInfo', {});
- if (response && response.errcode == 0) {
- let res_data = response.data;
- //gData.safeDepositBoxData.richBankCashAmount = res_data.richBankCashAmount;
- gData.safeDepositBoxData.currentRichBankCashTaskIndex = res_data.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;
- //gData.safeDepositBoxData.richBankTotelLoginDays = res_data.richBankTotelLoginDays;
- console.log(`currentRichBankCashTaskIndex 11======== ${res_data.currentRichBankCashTaskIndex}`);
- console.log(`richBankDailyTotelVideoTimes 11======== ${res_data.richBankDailyTotelVideoTimes}`);
- }
- }
- }
- start() {
- this.initMusic();
- this.initBtns();
- this.initInfo();
- //this.autoOpenPanel();
- this.runGuideWeak();
- this.initLeftTimes();
- this.initFarmExpUI();
- this.initCashProBar();
- this.initBankProBar();
- // if(gData.sign.redPoint() && this.autoPopSign)
- // {
- // let id = gData.gameData.getProp(GameProp.guideID);
- // if(id >= 1)
- // {
- // mk.ui.openPanel('module/sign/sign');
- // }
- // this.autoPopSign = false;
- // }
- // //test
- // gData.gameData.setProp(GameProp.guideID, 0);
- // mk.guide.open(10);
- if (gData.gameData.funOpenData[11] == "1") {
- let isPopUi = mk.ui.isPopPanel();
- if (!isPopUi) {
- let isTeach = mk.guide.open(10);
- if (isTeach) {
- mk.event.register("event_guide", this.initGuideEvent.bind(this), this);
- //mk.guide.continueCallBack = this.judgeContinueTeach;
- }
- }
- }
- let value = mk.storage.getStorage('loadingFinish');
- if (!value) {
- mk.storage.setStorage('loadingFinish', 1);
- mk.data.sendDataEvent(DataEventId.loading, 'loading结束');
- }
- setTimeout(() => {
- gData.safeDepositBoxData.deleteJGTags();
- }, 1000)
- }
- update(dt) {
- if (gData.gameData.init_coin) {
- this.changeInfo();
- }
- if (gData.gameData.init_head) {
- this.initHead();
- }
- if (gData.gameData.init_red_point) {
- this.initRedPoint();
- }
- if (gData.gameData.init_makeInfo) {
- this.initCanPlantInfo();
- }
- if (gData.gameData.init_leftTimes) {
- this.initLeftTimes();
- }
- if (gData.gameData.init_task) {
- this.changeTaskUI();
- }
- if (gData.gameData.init_expLevel) {
- this.initFarmExpUI();
- }
- if (gData.walletCashOutData.init_cashOut) {
- this.initCashProBar();
- }
- if (gData.safeDepositBoxData.freshQipao) {
- this.initBankProBar();
- }
- gData.adData.startPopRed(dt);
- gData.gameData.firstCheckNext();
- let add = 0;
- let needAdd = true;
- let offset = 0;
- if (gData.gameData.leftTimes < gData.gameData.maxTimes && this.lastTimeSpan != 0) {
- let pass = Date.now() - this.lastTimeSpan;
- if (pass >= this.span) {
- add = Math.floor(pass / this.span);
- this.lastTimeSpan += (add * this.span);
- mk.storage.setStorage('lastTimeSpan', this.lastTimeSpan);
- offset = gData.gameData.maxTimes - gData.gameData.leftTimes;
- gData.gameData.changeLeftTimes(add, false, this.isShowAddProductTimesUI);
- }
- }
- //注释离线收益次数
- // if (!this.isShowAddProductTimesUI && needAdd) {
- // this.isShowAddProductTimesUI = true;
- // if (add > 0) {
- // add = add > offset ? offset : add;
- // if (add > 0) {
- // //add = add > gData.gameData.maxTimes ? gData.gameData.maxTimes : add;
- // gData.gameData.restoreProductTimes = add;
- // mk.ui.openPanel('module/speedUpUI/restoreProductTimes');
- // mk.data.sendDataEvent(DataEventId.offlineProductTimes, "离线生产次数弹出");
- // }
- // }
- // }
- if (this.startTimes) {
- this.btnCD += dt;
- if (this.btnCD >= 1) {
- this.startTimes = false;
- this.btnCD = 0;
- }
- }
- }
- lateUpdate() {
- gData.gameData.init_head = false;
- gData.safeDepositBoxData.freshQipao = false;
- gData.walletCashOutData.init_cashOut = false;
- }
- private initMusic() {
- mk.audio.playMusic("bgm");
- }
- /**
- * 根据配置,添加开启的功能按钮
- */
- private initBtns() {
- // let sc = this.node_btn.getComponent(FunBtns) as FunBtns;
- // sc.init();
- }
- private initInfo() {
- this.lbl_redMoney.string = gData.gameData.playerProp.redMoney / 100 + "";
- gData.gameData.init_coin = false;
- if (gData.gameData.playerProp.userFarmTaskInfo) {
- let com = gData.gameData.playerProp.userFarmTaskInfo.completeCount;
- let count = gData.gameData.playerProp.userFarmTaskInfo.taskCount;
- if (gData.gameData.init_redBagTask) {
- this.lbl_task.string = `<b><color=#8D4D32>点击领取任务!</c></b>`
- this.node_hand.active = true;
- } else {
- this.lbl_task.string = `<b><color=#8D4D32>进行${count}次生产</c><color=#D73D25>(${com}/${count})</color></b>`
- if (com >= count) {
- this.node_hand.active = true;
- } else {
- this.node_hand.active = false;
- }
- }
- }
- }
- private changeInfo() {
- //this.lbl_redMoney.node.getComponent(mk.component.numberAnim).setValue(gData.gameData.playerProp.redMoney);
- cc.tween(this.lbl_redMoney.node).to(0.1, { scale: 1.2 }).to(0.05, { scale: 1 }).start();
- this.lbl_redMoney.string = gData.gameData.playerProp.redMoney / 100 + "";
- gData.gameData.init_coin = false;
- if (gData.gameData.addHb > 0) {
- let add = Math.round(gData.gameData.addHb / 100);
- gData.gameData.addHb = 0;
- if (add > 0) {
- this.lbl_addHb.string = "+" + add.toString();
- cc.Tween.stopAllByTarget(this.node_addHb);
- this.node_addHb.active = true;
- this.node_addHb.scale = 0;
- cc.tween(this.node_addHb).to(0.1, { scale: 1 }).delay(1.5).call(() => {
- this.node_addHb.active = false;
- }).start();
- }
- }
- }
- private async initHead() {
- //let result = await mk.loader.loadRemote(gData.wechatData.avatar + "?aaa=aa.jpg", null);
- //this.img_head.spriteFrame = new cc.SpriteFrame(result);
- }
- isRefreshTask = false;
- private changeTaskUI() {
- //cc.tween(this.lbl_task.node).to(0.1, { scale: 1.2 }).to(0.1, { scale: 1 }).start();
- if (!this.isRefreshTask) {
- this.isRefreshTask = true;
- cc.tween(this.lbl_task.node).delay(0.6).to(0.1, { scale: 1.2 }).to(0.1, { scale: 1 }).call(() => {
- if (gData.gameData.playerProp.userFarmTaskInfo) {
- let com = gData.gameData.playerProp.userFarmTaskInfo.completeCount;
- let count = gData.gameData.playerProp.userFarmTaskInfo.taskCount;
- this.lbl_task.string = `<b><color=#8D4D32>进行${count}次生产</c><color=#D73D25>(${com}/${count})</color></b>`
- if (com >= count) {
- this.node_hand.active = true;
- } else {
- this.node_hand.active = false;
- }
- // if (gData.gameData.playerProp.completeFarmTaskTimes < 1) {
- // mk.tip.pop("百元红包进度+1");
- // }
- this.isRefreshTask = false;
- }
- }).start();
- }
- gData.gameData.init_task = false;
- }
- private async initFarmExpUI() {
- let preLv = parseInt(this.lbl_farmLevel.string);
- let curLevel = gData.gameData.playerProp.gradeLevel;
- this.lbl_farmLevel.string = curLevel.toString();
- //升级
- if (curLevel > preLv) {
- mk.ui.openPanel('game/prefab/uiPanel/LevelUpPanel');
- }
- if (gData.gameData.configs.UpgradeReward.length > curLevel) {
- let needExp = gData.gameData.configs.UpgradeReward[curLevel].exp - gData.gameData.configs.UpgradeReward[curLevel - 1].exp;
- let curExp = gData.gameData.playerProp.farmExpValue - gData.gameData.configs.UpgradeReward[curLevel - 1].exp;
- this.sp_levelPer.fillRange = curExp / needExp;
- }
- let nameIndex = 1;
- if (gData.gameData.playerProp.farmGradeData) {
- let data = gData.gameData.playerProp.farmGradeData.farmGradeRewardList;
- if (data) {
- let len = data.length;
- for (let i = 0; i != len; ++i) {
- if (gData.gameData.playerProp.farmExpValue >= data[i].expMax) {
- nameIndex = i + 1;
- }
- }
- }
- }
- gData.gameData.playerProp.farmGradeName = nameIndex;
- this.sp_gradeName.spriteFrame = await mk.loader.load('module/gradeReward/texture/name' + nameIndex, cc.SpriteFrame);
- gData.gameData.init_expLevel = false;
- }
- private initCashProBar() {
- let minMoney = gData.walletCashOutData.getMinCanCashMoney();
- if (!minMoney) {
- console.warn('未获取到当前最小提现金额');
- this.pro_tixian.node.parent.active = false;
- return;
- }
- this.pro_tixian.node.parent.active = true;
- let per = gData.gameData.playerProp.redMoney * 0.01 / minMoney;
- if (per > 1) {
- per = 1;
- }
- this.pro_tixian.fillRange = per;
- this.lbl_cashPro.string = `${Math.floor(per * 100)}%`;
- if (per == 1) {
- this.btn_cashOutGold.getComponent(cc.Animation).play();
- }
- else {
- this.btn_cashOutGold.getComponent(cc.Animation).setCurrentTime(0);
- this.btn_cashOutGold.getComponent(cc.Animation).stop();
- }
- }
- private initBankProBar() {
- if (!gData.safeDepositBoxData.currentRichBankCashTaskIndex || gData.safeDepositBoxData.isStartBankTask) {
- this.pro_bank.node.parent.active = false;
- }
- else {
- this.pro_bank.node.parent.active = true;
- let config = gData.safeDepositBoxData.getBankTaskIndexExtra();
- let money = config.money
- let showMoney = Math.floor(money / 100) > 0 ? (money / 100) + "" : (money / 100).toFixed(2)
- let putinMoney: number = gData.safeDepositBoxData.richBankCashAmount
- if (putinMoney == null || putinMoney == undefined) {
- putinMoney = 0
- }
- let per = (putinMoney * 0.01) / parseFloat(showMoney);
- if (per > 1) {
- per = 1;
- }
- this.pro_bank.fillRange = per;
- this.lbl_bankPro.string = `${Math.floor(per * 100)}%`
- }
- }
- /**
- * 初始化红点
- */
- private initRedPoint() {
- let showSign = gData.sign.redPoint()
- this.nodeRedPoint.node_sign.active = showSign;
- this.nodeRedPoint.node_turnable.active = gData.turnable.leftTimes > 0;
- let isShow = false;
- let data = gData.gameData.playerProp.farmGradeData.farmGradeRewardList;
- if (data) {
- let len = data.length;
- for (let i = 0; i != len; ++i) {
- if (data[i].status == 1) {
- isShow = true;
- break;
- }
- }
- }
- this.nodeRedPoint.node_gradeReward.active = isShow;
- gData.gameData.init_red_point = false;
- }
- /**
- * 自动打开面板
- * - isAutoOpenPanel 1自动开 2不自动开 其他不处理
- */
- private autoOpenPanel() {
- if (!gData.gameData.isNewPlayer()) {
- mk.ui.openPanel('module/pigBank/pigBank');
- gData.gameData.setProp(GameProp.isAutoOpenPanel, 1)
- }
- }
- /**
- * 开始运行弱引导
- */
- private runGuideWeak() {
- gData.guideWeakData.enable = true;
- }
- private async initCanPlantInfo() {
- gData.gameData.init_makeInfo = false;
- if (gData.gameData.nextCanProduct) {
- let iconPath = '';
- let namePath = '';
- if (gData.gameData.nextCanProduct.tab == ProductType.nzw) {
- iconPath = "game/coregame/texture/plant_icons/plantIcon_";
- namePath = "game/coregame/texture/plant_icons/nameIcon/plant_name_";
- }
- else if (gData.gameData.nextCanProduct.tab == ProductType.dw) {
- iconPath = 'game/coregame/texture/factory_icons/factory_';
- namePath = 'game/coregame/texture/factory_icons/factoryNams/factory_name_icon_';
- }
- else {
- iconPath = 'game/coregame/texture/factory_icons/factory_';
- namePath = 'game/coregame/texture/factory_icons/factoryNams/factory_name_icon_';
- }
- this.icon_plant.spriteFrame = await mk.loader.load(iconPath + gData.gameData.nextCanProduct.picture, cc.SpriteFrame);
- this.icon_plantName.spriteFrame = await mk.loader.load(namePath + gData.gameData.nextCanProduct.picture, cc.SpriteFrame);
- }
- }
- private initLeftTimes() {
- this.lbl_leftTimes.string = `${gData.gameData.leftTimes}/${gData.gameData.maxTimes}`;
- if (gData.gameData.leftTimes < gData.gameData.maxTimes) {
- this.lastTimeSpan = parseInt(mk.storage.getStorage('lastTimeSpan'));
- if (!this.lastTimeSpan) {
- this.lastTimeSpan = Date.now();
- mk.storage.setStorage('lastTimeSpan', this.lastTimeSpan);
- }
- }
- else {
- this.lastTimeSpan = 0;
- mk.storage.setStorage('lastTimeSpan', this.lastTimeSpan);
- }
- gData.gameData.init_leftTimes = false;
- }
- private onCount() {
- }
- /** 点击互推 */
- public onClickHuTui() {
- mk.data.sendDataEvent(DataEventId.button_click, "互推icon");
- gData.moreGame.userBehaveLog(4, gData.moreGame.placement_id, gData.moreGame.nebulaAppId);
- }
- /** 点击福利 */
- public onClickFuli() {
- if (gData.gameData.playerProp.orderData && gData.gameData.playerProp.orderData.overTimes >= gData.gameData.welfareOpenLimit) {
- mk.ui.openPanel('module/blessingBag/blessingBag');
- mk.data.sendDataEvent(DataEventId.button_click, "福利icon");
- let isClickIcon = mk.storage.getStorage("clickBlessIcon")
- if (!isClickIcon) {
- JsbSystem.addJGTags("点击过福利icon");
- mk.storage.setStorage("clickBlessIcon", 1);
- }
- } else {
- mk.tip.pop(`订单提现${gData.gameData.welfareOpenLimit}次后开启`);
- }
- }
- /** 点击漂浮红包 */
- public onClickQipaoRedBag(event) {
- mk.audio.playEffect("button");
- mk.data.sendDataEvent(DataEventId.button_click, "飘浮红包icon");
- mk.ad.videoAdType = VideoAdType.video_init_13;
- // mk.ui.openPanel('module/newOpenRedBag/newOpenRedBag');
- gData.adData.curSelQipao = event.target;
- gData.adData.curRedBagAdFun = AdFun.bubble;
- mk.ui.openPanel('module/newOpenRedBag/newOpenRedBag');
- }
- /** 点击红包提现 */
- public onClickRedBagCash() {
- mk.data.sendDataEvent(DataEventId.button_click, "常规提现-提现icon");
- }
- /** */
- public onClickTurntable() {
- mk.data.sendDataEvent(DataEventId.button_click, "抽奖icon");
- mk.console.logSingle('VVVV ', 'onClickTurntable');
- }
- /** 点击签到 */
- public onClickSign() {
- mk.data.sendDataEvent(DataEventId.button_click, "签到icon");
- mk.console.logSingle('VVVV ', 'onClickSign');
- }
- /** 点击账单提现 */
- public onClickCashOutBill() {
- mk.data.sendDataEvent(DataEventId.button_click, "提现账单icon");
- }
- /**点击分享 */
- public onClickShare() {
- mk.data.sendDataEvent(DataEventId.button_click, "邀请icon");
- if (!gData.loginData.isAuth) {
- // JsbSystem.WxAuth();
- mk.ui.openPanel('module/authUI/authUI');
- return;
- }
- JsbSystem.shareInviteUrl(gData.gameData.shareUrl, gData.gameData.shareTitle, gData.gameData.shareDes, gData.gameData.shareImgUrl);
- }
- /** 点击农场等级奖励 */
- public onClickGradeReward() {
- mk.data.sendDataEvent(DataEventId.button_click, "农场等级领奖按钮");
- }
- /** 点击红包币提现 */
- public onClickWalletCash() {
- mk.data.sendDataEvent(DataEventId.button_click, "红包币提现按钮");
- }
- /** 点击任务 */
- public onClickTask() {
- mk.data.sendDataEvent(DataEventId.button_click, "任务红包icon");
- }
- /** 点击种植 */
- public async onClickPlant() {
- mk.audio.playEffect("button");
- if (gData.gameData.leftTimes <= 0) {
- // mk.tip.pop('生产次数不足');
- // if(!mk.guide.isGuiding())
- // {
- // mk.ui.openPanel('module/speedUpUI/productReward');
- // }
- let str = gData.gameData.prohibitProductionAd[gData.loginData.userChannel].split(",");
- if (str[1 - gData.loginData.isMatched] == "1") {
- if (gData.gameData.playerProp.curProductionAdTimes >= gData.gameData.productionAdMaxTimes) {
- mk.tip.pop('今日领取生产次数已达上限!');
- return;
- }
- }
- mk.ui.openPanel('module/speedUpUI/productReward');
- return;
- }
- if (gData.gameData.isProducting) {
- //mk.tip.pop('点击太快了');
- return;
- }
- let flyRed = await gData.gameData.makeProduct();
- //任务红包刷新逻辑
- if (flyRed) {
- //mk.audio.playEffect('redmoney');
- if (gData.gameData.playerProp.userFarmTaskInfo) {
- let com = gData.gameData.playerProp.userFarmTaskInfo.completeCount;
- let count = gData.gameData.playerProp.userFarmTaskInfo.taskCount;
- let addAni = cc.instantiate(this.ani_add3);
- addAni.parent = this.ani_add3.parent;
- addAni.getComponent(cc.Label).string = `百元红包:${com}/${count}`;
- cc.tween(addAni).call(() => {
- addAni.opacity = 255;
- }).by(0.8, { y: 100 }).to(0.4, { opacity: 0 }).call(() => {
- addAni.destroy();
- }).start();
- }
- this.dpFlyRedAni();
- }
- mk.data.sendDataEvent(DataEventId.button_click, "一键生产按钮");
- }
- public dpFlyRedAni(starPos: cc.Vec2 = null) {
- if (starPos) {
- if (this.node_orderHb && this.node_orderHb.parent) {
- // let pos = this.node_taskHb.parent.convertToWorldSpaceAR(this.node_taskHb.getPosition());
- let pos = this.node_orderHb.parent.convertToWorldSpaceAR(this.node_orderHb.getPosition());
- mk.fly.PlayCoinAnim(1, 5, starPos, pos, () => {
- //gData.gameData.init_task = true;
- }, 0.8);
- } else {
- //gData.gameData.init_task = true;
- }
- } else {
- if (this.node_taskHb && this.node_taskHb.parent && this.btn_product) {
- let pos = this.node_taskHb.parent.convertToWorldSpaceAR(this.node_taskHb.getPosition());
- mk.fly.PlayCoinAnim(1, 5, this.btn_product, pos, () => {
- //gData.gameData.init_task = true;
- }, 0.8);
- } else {
- //gData.gameData.init_task = true;
- }
- }
- }
- public doFlyExpAni(exp: number, startPos: cc.Node, data) {
- // let pos = this.lbl_farmLevel.node.parent.convertToWorldSpaceAR(this.lbl_farmLevel.node.getPosition());
- //飞向农舍
- let nongshe = cc.find('Canvas/主容器/coregame/MapIconGroup/农舍');
- let pos = nongshe.parent.convertToWorldSpaceAR(nongshe.getPosition());
- let num = 3;
- // if (gData.harvestData.isMatchOrder) {
- // num = 3;
- // }
- mk.fly.PlayCoinAnim(2, num, startPos, pos, () => {
- if (gData.gameData.playerProp.gradeLevel < data.farmLevel) {
- gData.gameData.playerProp.gradeLevel = data.farmLevel;
- mk.data.setTAEventUser(0, 'farm_lv', gData.gameData.playerProp.gradeLevel);
- }
- gData.gameData.playerProp.farmExpValue = data.userExp;
- gData.gameData.playerProp.farmGradeData = data.userFarmGrageRewardInfo;
- // gData.gameData.init_add = true;
- gData.gameData.init_red_point = true;
- this.playAdd(exp);
- }, 1.2)
- }
- public registerCallBack() {
- JsbSystem.callBack = null;
- JsbSystem.callBack = () => {
- mk.ui.openPanel('module/speedUpUI/productReward2');
- }
- }
- public playAdd(exp, type = 1) {
- if (type == 1) {
- // this.ani_add.node.getComponent(cc.Label).string = `+${exp}`;
- // this.ani_add.node.active = true;
- // this.ani_add.play();
- cc.Tween.stopAllByTarget(this.node_addExp);
- this.node_addExp.active = true;
- this.node_addExp.scale = 0;
- this.lbl_addExp.string = `+${exp}`;
- cc.tween(this.node_addExp).to(0.1, { scale: 1 }).delay(1.5).call(() => {
- this.node_addExp.active = false;
- }).start();
- } else {
- this.ani_add2.getComponent(cc.Label).string = `生产次数+${exp}`;
- cc.tween(this.ani_add2).delay(1.3).call(() => {
- this.ani_add2.opacity = 255;
- }).by(0.8, { y: 100 }).to(0.4, { opacity: 0 }).call(() => {
- this.ani_add2.y = this.posY;
- }).start();
- }
- // gData.gameData.init_add = false;
- }
- //图鉴部分logic
- public initRefreshEvent() {
- mk.event.register("initFarmMapUi", this.initFarmMapUi.bind(this), this);
- mk.event.register("refreshFarmMapUI", this.refreshFarmMapUI.bind(this), this);
- mk.event.register("moveUpAndDownFarmMapUI", this.moveUpAndDownFarmMapUI.bind(this), this);
- this.initFarmMapUi();
- this.showChangePart();
- }
- public moveUpAndDownFarmMapUI(isMoveUp) {
- cc.Tween.stopAllByTarget(this.node_farmMapUI);
- if (isMoveUp) {
- cc.tween(this.node_farmMapUI).to(0.2, { y: 540 }).start();
- } else {
- cc.tween(this.node_farmMapUI).to(0.2, { y: 240 }).start();
- }
- }
- public clickFarmMapUIBtn() {
- mk.audio.playEffect("button");
- mk.data.sendDataEvent(DataEventId.button_click, "图鉴浮窗icon");
- if (this.productType == ProductType.nzw) {
- if (gData.farmSystem.currSelectFarm) {
- if (gData.farmSystem.currSelectFarm.data.state != FarmState.Empty) {
- gData.farmSystem.currSelectFarm = null;
- let farms = gData.farmSystem.farms;
- for (let i = 0; i < farms.length; i++) {
- if (farms[i].data.state == FarmState.Empty) {
- gData.farmSystem.currSelectFarm = farms[i];
- break;
- }
- }
- if (!gData.farmSystem.currSelectFarm) {
- gData.farmSystem.currSelectFarm = farms[0];
- }
- }
- } else {
- let farms = gData.farmSystem.farms;
- for (let i = 0; i < farms.length; i++) {
- if (farms[i].data.state == FarmState.Empty) {
- gData.farmSystem.currSelectFarm = farms[i];
- break;
- }
- }
- if (!gData.farmSystem.currSelectFarm) {
- gData.farmSystem.currSelectFarm = farms[0];
- }
- }
- } else {
- let factorys = gData.factorySystem.factoryIcons;
- for (let i = 0; i != factorys.length; ++i) {
- if (factorys[i].tab == this.productType) {
- gData.factorySystem.currSelectFactory = factorys[i];
- break;
- }
- }
- }
- gData.plantData.openPanel(this.productType, 1, this.productIndex - 1);
- }
- private uiShowType = 3;
- private productType = ProductType.nzw;
- private productIndex = 0;
- public async initFarmMapUi() {
- // let plantPath = '';
- // let namePath = '';
- // if (gData.farmMapData.chooseType == ProductType.nzw) {
- // plantPath = 'game/coregame/texture/plant_icons/plantIcon_';
- // namePath = 'game/coregame/texture/plant_icons/nameIcon/plant_name_';
- // }
- // else {
- // plantPath = 'game/coregame/texture/factory_icons/factory_';
- // namePath = 'game/coregame/texture/factory_icons/factoryNams/factory_name_icon_';
- // }
- if (gData.gameData.funOpenData[12] == "0") {
- this.node_farmMapUI.active = false;
- return;
- }
- //1:有可领奖的,2:正在解锁,3:所有奖励都领取完
- this.uiShowType = 3;
- for (let key in ProductType) {
- let max = gData.gameData.getMaxProductExtra(ProductType[key]);
- if (max) {
- let list_data = gData.gameData.getProductArrByType(ProductType[key]);
- for (let i = 0; i != list_data.length; ++i) {
- let data = list_data[i];
- //剔除前三个农作物
- let extraCondition = true;
- if (ProductType[key] == ProductType.nzw) {
- extraCondition = (data.picture > 10003);
- }
- if (extraCondition && data.picture <= max) {
- let state = gData.gameData.getFarmMapRewardState(this.getIndex(data));
- if (state == 0) {
- this.uiShowType = 1;
- this.productType = ProductType[key];
- this.productIndex = i;
- this.node_farmMapGetReward.active = true;
- this.node_farmMapProduct.active = false;
- this.node_farmMapUI.active = true;
- this.node_farmMapUI.width = 320;
- //this.sp_farmMapIcon.spriteFrame = await mk.loader.load(plantPath + data.picture, cc.SpriteFrame);
- return;
- }
- } else if (data.picture - 1 == max && data.unlock == 1) {
- this.uiShowType = 2
- this.productType = ProductType[key];
- this.productIndex = i;
- this.node_farmMapGetReward.active = false;
- this.node_farmMapProduct.active = true;
- this.node_farmMapUI.active = true;
- let times = gData.gameData.getProductMakeTimesById(data.picture - 1);
- let plantName = gData.gameData.getProductMap(data.picture - 1).name;
- let des = this.getDesByType(data);
- let len = plantName.length;
- this.node_farmMapUI.width = 300 + (len - 2) * 20 + (len - 2) * 5;
- this.lbl_farmMapDes.string = `<color=#7E411F>${des}<color=#FF0000>${data.value}</c>次${plantName} <color=#FF0000>${times}</c>/${data.value}</color>`;
- //this.sp_farmMapIcon.spriteFrame = await mk.loader.load('module/farmMap/texture/gift', cc.SpriteFrame);
- return;
- }
- }
- }
- }
- if (this.uiShowType == 3) {
- this.node_farmMapUI.active = false;
- }
- }
- public refreshFarmMapUI() {
- if (this.uiShowType == 2) {
- let list_data = gData.gameData.getProductArrByType(this.productType);
- let data = list_data[this.productIndex];
- let times = gData.gameData.getProductMakeTimesById(data.picture - 1);
- let plantName = gData.gameData.getProductMap(data.picture - 1).name;
- let des = this.getDesByType(data);
- this.lbl_farmMapDes.string = `<color=#7E411F>${des}<color=#FF0000>${data.value}</c>次${plantName} <color=#FF0000>${times}</c>/${data.value}</color>`;
- }
- }
- private btnCD = 0;
- private startTimes = false;
- public clickGetFarmMapRewardBtn() {
- mk.audio.playEffect("button");
- if (!this.startTimes) {
- this.startTimes = true;
- this.btnCD = 0;
- } else {
- return;
- }
- mk.data.sendDataEvent(DataEventId.button_click, "图鉴浮窗icon");
- mk.audio.playEffect("button");
- mk.ad.videoAdType = VideoAdType.video_init_6;
- mk.ad.watchAd(async (success) => {
- if (success) {
- await gData.adData.watchVideo(AdFun.farmMap);
- if (gData.farmMapData.init_award) {
- gData.farmMapData.init_award = false;
- gData.reward.adData = gData.farmMapData.adData;
- mk.ui.openPanel('module/reward/reward');
- gData.farmMapData.isStateChange = true;
- let list_data = gData.gameData.getProductArrByType(this.productType);
- let data = list_data[this.productIndex];
- gData.gameData.setFarmMapRewardState(this.getIndexExtra(data), 1);
- this.initFarmMapUi();
- }
- }
- })
- }
- showChangePart() {
- //this.changePart.active = true
- let len = this.lbl_value.length;
- let len2 = this.lbl_redMoneyValue.length;
- this.schedule(() => {
- //图鉴部分
- for (var i = 0; i < len; i++) {
- let ran = Util.rnd(0, 9);
- this.lbl_value[i].string = `${ran}`;
- }
- //订单部分
- // for (var i = 0; i < len2; i++) {
- // let ran = Util.rnd(0, 9);
- // this.lbl_redMoneyValue[i].string = `${ran}`;
- // }
- }, 0.1)
- }
- 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;
- }
- getIndexExtra(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;
- }
- getDesByType(data) {
- let des = ''
- switch (data.tab) {
- case '农作物':
- des = '种植';
- break;
- case '动物':
- des = '养殖';
- break;
- case '爆米花厂':
- case '糕点铺':
- case '制糖厂':
- case '炼乳厂':
- case '功夫面馆':
- case '快餐店':
- des = '制作';
- break;
- }
- return des;
- }
- //订单部分
- private orderPicIdArray = [];
- private isGray = true;
- public async initOrderUI(init = true) {
- this.orderPicIdArray = [];
- this.isGray = true;
- let productJson = gData.gameData.configs.Product;
- let data = gData.gameData.playerProp.orderData;
- mk.console.logSingle('initOrderUI ', data);
- if (data) {
- //红包币
- if (gData.gameData.orderRewardType == 1) {
- this.lbl_orderRedMoney.string = data.redMoneyAddition / 100 + "";
- } else {
- this.lbl_addCash.string = (data.cashMoney / 100).toFixed(2);
- }
- let len = data.orderTaskList.length;
- if (len == 3) {
- let completeCount = 0;
- for (let i = 0; i != len; ++i) {
- let dataE = data.orderTaskList[i];
- mk.console.logSingle('dataE ' + i, dataE);
- if (dataE.Id <= productJson.length) {
- let productData = productJson[dataE.Id - 1];
- let plantPath = '';
- let namePath = '';
- if (productData.tab == ProductType.nzw) {
- plantPath = 'game/coregame/texture/plant_icons/plantIcon_';
- namePath = 'game/coregame/texture/plant_icons/nameIcon/plant_name_';
- }
- else {
- plantPath = 'game/coregame/texture/factory_icons/factory_';
- namePath = 'game/coregame/texture/factory_icons/factoryNams/factory_name_icon_';
- }
- if (dataE.completeCount >= dataE.taskCount) {
- this.lbl_progress[i].node.active = false;
- this.sp_mark[i].node.active = true;
- ++completeCount;
- } else {
- this.lbl_progress[i].node.active = true;
- this.sp_mark[i].node.active = false;
- this.lbl_progress[i].string = `${dataE.completeCount}/${dataE.taskCount}`;
- }
- this.orderPicIdArray.push({ "ID": dataE.Id, "picID": productData.picture });
- this.lbl_cropName[i].string = productData.name;
- this.sp_cropIcon[i].spriteFrame = await mk.loader.load(plantPath + productData.picture, cc.SpriteFrame);
- } else {
- return;
- }
- }
- if (completeCount >= 3) {
- this.isGray = false;
- this.node_getOrderReward.setGray(false, true);
- this.node_getOrderReward.getComponent(cc.Animation).play();
- this.node_orderHand.active = true;
- } else {
- this.isGray = true;
- this.node_getOrderReward.setGray(true, true);
- this.node_getOrderReward.getComponent(cc.Animation).setCurrentTime(0);
- this.node_getOrderReward.getComponent(cc.Animation).stop();
- this.node_orderHand.active = false;
- }
- }
- }
- }
- public clickGetOrderRewardBtn() {
- mk.audio.playEffect("button");
- if (this.isGray) {
- mk.tip.pop("完成订单即可提现");
- } else {
- //smk.tip.pop("测试使用==订单领奖");
- //mk.data.sendDataEvent(DataEventId.button_click, "订单领奖按钮");
- if (!gData.loginData.isAuth) {
- // JsbSystem.WxAuth();
- gData.gameData.authUIType = 0;
- mk.ui.openPanel('module/authUI/authUI');
- return;
- }
- mk.data.sendDataEvent(DataEventId.Sundry, "订单领奖按钮");
- this.getOrderReward();
- }
- }
- public getIsCanGetOrderReward() {
- return !this.isGray;
- }
- public async getOrderReward(isGame = true) {
- // mk.ui.openPanel('game/prefab/uiPanel/OrderDrawPanel');
- // return;
- //现金提现
- if (gData.gameData.orderRewardType == 2) {
- if (cc.sys.isNative) {
- if (!gData.loginData.isAuth) {
- // JsbSystem.WxAuth();
- gData.gameData.authUIType = 0;
- mk.ui.openPanel('module/authUI/authUI');
- return;
- }
- }
- let response = await mk.http.sendData('orderTaskTree/receiveRewardCash', {});
- if (response.errcode != 0) {
- if (response.errcode == 405) {
- mk.tip.pop("今日提现额度已到上限,请明天再提现");
- mk.data.sendDataEvent(DataEventId.cashLimit, "提现触发上限");
- }
- return null;
- }
- let addMoney = gData.gameData.playerProp.orderData.cashMoney;
- gData.gameData.playerProp.orderData = response.data.userOrderTaskInfo;
- gData.safeDepositBoxData.setCashRecordDataLength();
- //处理提现逻辑
- gData.cashPro.isOrderCashOut = true;
- gData.cashPro.callBack = this.getRewardCallBack.bind(this);
- gData.receiptNotice.receip_rmb = addMoney;
- mk.ui.openPanel('module/newNotice/newNotice');
- //[FC]新增 当前订单种植数据清空
- gData.gameData.setProp(GameProp.orderPlantTimes, {});
- if (isGame) {
- this.node_crop.forEach((v) => {
- v.active = false;
- })
- this.node_orderHbIcon.active = false;
- this.node_getOrderReward.node.active = false;
- } else {
- this.showRefreshLogic();
- }
- } else {
- let data = {};
- let response = await mk.http.sendData('orderTaskTree/receiveReward', data);
- if (response.errcode != 0) {
- return null;
- }
- // let addMoney = gData.gameData.playerProp.orderData.redMoneyAddition;
- let addMoney = response.data.orderRedMoney;
- console.log("====[response.data.orderRedMoney", response.data.orderRedMoney);
- gData.gameData.playerProp.orderData = response.data.userOrderTaskInfo;
- //处理红包币逻辑
- gData.reward.closeUICallBack = this.getRewardCallBack.bind(this);
- gData.reward.adData = { videoRedMoney: { videoRewardList: null } };
- gData.reward.adData.videoRedMoney.videoRewardList = [{ rewardType: 1, rewardNum: addMoney }]
- mk.ui.openPanel('module/reward/reward');
- //[FC]新增 当前订单种植数据清空
- gData.gameData.setProp(GameProp.orderPlantTimes, {});
- if (isGame) {
- gData.gameData.isDoOrderRefreshAni = true;
- this.node_crop.forEach((v) => {
- v.active = false;
- })
- this.node_orderHbIcon.active = false;
- this.node_getOrderReward.node.active = false;
- } else {
- this.showRefreshLogic();
- }
- }
- }
- //停止农民产红包币
- isStopFarm = false;
- public getRewardCallBack() {
- this.node_extraOrderUi.active = true;
- this.node_bgUi.scale = 0;
- cc.tween(this.node_bgUi).to(0.4, { scale: 1.4 }).start();
- if (gData.gameData.funOpenData[1] == '1') {
- gData.gameData.funOpenData[1] = "0";
- this.isStopFarm = true;
- }
- }
- public showRefreshLogic() {
- gData.gameData.isDoOrderRefreshAni = false;
- this.node_crop.forEach((v) => {
- v.active = true;
- })
- this.node_orderHbIcon.active = false;
- this.node_getOrderReward.node.active = true;
- this.initOrderUI(false);
- this.showTips();
- gData.gameData.init_order = true;
- gData.gameData.checkTaskFinishUnLock();
- if (gData.gameData.orderRewardType == 2) {
- gData.gameData.richBankTeachTag = true;
- gData.safeDepositBoxData.updateQipao();
- }
- gData.cashNormal.getRecord();
- if (this.isStopFarm) {
- this.isStopFarm = false;
- gData.gameData.funOpenData[1] = '1';
- }
- }
- showTips() {
- mk.tip.pop("提现成功,订单已刷新");
- }
- async doCropFlyLogic(plantId: number, farmNode: cc.Node = null, parentNode: cc.Node = null, isNzw = false) {
- if (gData.gameData.funOpenData[11] == "0" || !gData.gameData.playerProp.orderData) {
- return;
- }
- for (let i = 0; i != this.orderPicIdArray.length; ++i) {
- if (plantId == this.orderPicIdArray[i].picID) {
- let data = gData.gameData.playerProp.orderData.orderTaskList[i];
- if (data.completeCount < data.taskCount) {
- // let plantPath = '';
- // if (isNzw) {
- // plantPath = 'game/coregame/texture/plant_icons/plantIcon_';
- // }
- // else {
- // plantPath = 'game/coregame/texture/factory_icons/factory_';
- // }
- await this.updataOrderProgress(this.orderPicIdArray[i].ID);
- //await mk.time.WaitForSeconds(1);
- // for (let index = 0; index != 4; ++index) {
- // let crop = await mk.pool.getPrefab('game/prefab/crop');
- // let sf = await mk.loader.load(plantPath + plantId, cc.SpriteFrame);
- // crop.getComponent(cc.Sprite).spriteFrame = sf;
- // mk.fly.playFlyAniExtra(farmNode, this.sp_cropIcon[i].node, crop, 0.6, index * 0.2, () => {
- // if (index == 2) {
- // this.doFlyOrderAni(i);
- // }
- // });
- // }
- if (farmNode) {
- let addAni = cc.instantiate(this.ani_add4);
- addAni.parent = farmNode;
- addAni.setPosition(cc.Vec2.ZERO);
- cc.tween(addAni).call(() => {
- addAni.opacity = 255;
- }).by(0.8, { y: 100 }).to(0.4, { opacity: 0 }).call(() => {
- addAni.destroy();
- }).start();
- }
- }
- this.doFlyOrderAni(i, parentNode);
- break;
- }
- }
- }
- public doFlyOrderAni(index, parentNode = null) {
- let orderData = gData.gameData.playerProp.orderData;
- if (orderData) {
- let isComplete = true;
- let len = orderData.orderTaskList.length;
- for (let i = 0; i != len; ++i) {
- let dataE = orderData.orderTaskList;
- if (dataE[i].completeCount < dataE[i].taskCount) {
- isComplete = false;
- break;
- }
- }
- if (isComplete) {
- this.isGray = false;
- this.node_getOrderReward.setGray(false, true);
- this.node_getOrderReward.getComponent(cc.Animation).play();
- this.node_orderHand.active = true;
- mk.ui.closeAllUI();
- if (gData.gameData.funOpenData[11] == "1") {
- let isGuide = mk.guide.open(12);
- if (!isGuide) {
- mk.tip.pop("订单已完成,快提现吧!");
- }
- } else {
- mk.tip.pop("订单已完成,快提现吧!");
- }
- }
- if (parentNode) {
- let pos = this.node_orderHb.parent.convertToWorldSpaceAR(this.node_orderHb.getPosition());
- mk.fly.PlayCoinAnim(1, 5, parentNode, pos, () => {
- //this.refreshOrderUI(index);
- if (gData.gameData.orderRewardType == 1) {
- cc.tween(this.node_showRedMoney).to(0.1, { scale: 1.3 }).to(0.1, { scale: 1 }).start();
- }
- }, 0.8);
- } else {
- let pos = this.node_orderHb.parent.convertToWorldSpaceAR(this.node_orderHb.getPosition());
- mk.fly.PlayCoinAnim(1, 5, this.btn_product, pos, () => {
- //this.refreshOrderUI(index);
- if (gData.gameData.orderRewardType == 1) {
- cc.tween(this.node_showRedMoney).to(0.1, { scale: 1.3 }).to(0.1, { scale: 1 }).start();
- }
- }, 0.8);
- }
- this.refreshOrderUI(index);
- // if (!isComplet && this.node_orderHb && this.btn_product) {
- // let pos = this.node_orderHb.parent.convertToWorldSpaceAR(this.node_orderHb.getPosition());
- // mk.fly.PlayCoinAnim(1, 5, this.btn_product, pos, () => {
- // this.lbl_progress[index].string = `${dataE.completeCount}/${dataE.taskCount}`;
- // cc.Tween.stopAllByTarget(this.lbl_progress[index].node);
- // cc.tween(this.lbl_progress[index].node).to(0.1, { scale: 1.4 }).to(0.05, { scale: 1 }).start();
- // }, 0.8);
- // }
- }
- }
- public refreshOrderUI(index) {
- let orderData = gData.gameData.playerProp.orderData;
- let dataE = orderData.orderTaskList[index];
- if (dataE) {
- if (dataE.completeCount == dataE.taskCount) {
- this.lbl_progress[index].node.active = false;
- this.sp_mark[index].node.active = true;
- } else {
- this.lbl_progress[index].string = `${dataE.completeCount}/${dataE.taskCount}`;
- cc.Tween.stopAllByTarget(this.lbl_progress[index].node);
- cc.tween(this.lbl_progress[index].node).to(0.1, { scale: 1.4 }).to(0.05, { scale: 1 }).start();
- }
- }
- }
- public async updataOrderProgress(id) {
- let data = { "id": id };
- let response = await mk.http.sendData('orderTaskTree/updateUserOrderTaskInfo', data);
- if (response.errcode != 0) {
- return null;
- }
- gData.gameData.playerProp.orderData = response.data.userOrderTaskInfo;
- }
- public clickOrderUIBtn() {
- mk.audio.playEffect("button");
- // //test
- // mk.ui.openPanel('game/prefab/uiPanel/OrderDrawPanel');
- // return
- if (mk.guide.isGuiding()) {
- // let data = gData.gameData.playerProp.orderData;
- // let orderData = data.orderTaskList;
- // let copyData = gData.gameData.playerProp.copyOrderData;
- // if (data && orderData && copyData) {
- // let num = 0;
- // for (let i = 0; i != orderData.length; ++i) {
- // num += (orderData[i].taskCount - copyData[i])
- // }
- // mk.guide.curDes = `<color=8A4312><color=ff0000>继续生产</c>${num}次,很快就\n可以完成订单了!</color>`;
- // //mk.guide.open(2, curDes);
- // }
- // let leftTimes = gData.gameData.leftTimes;
- // if(leftTimes > 0)
- // {
- // mk.guide.curDes = `<color=8A4312><color=ff0000>继续生产${leftTimes}次</c>,很快就\n可以完成订单了!</color>`;
- // }
- } else {
- if (this.isGray) {
- mk.tip.pop("完成订单即可提现");
- } else {
- mk.tip.pop("订单已完成,快提现吧");
- }
- }
- }
- public judgeContinueTeach() {
- // let data = gData.gameData.playerProp.orderData;
- // let orderData = data.orderTaskList;
- // let copyData = gData.gameData.playerProp.copyOrderData;
- // if (data && orderData && copyData) {
- // let num = 0;
- // for (let i = 0; i != orderData.length; ++i) {
- // num += (orderData[i].taskCount - copyData[i])
- // }
- // mk.guide.curDes = `<color=8A4312>继续生产${num}次,很快就\n可以提现了!</color>`;
- // if (num > 0) {
- // return true;
- // } else {
- // return false;
- // }
- // } else {
- // return false;
- // }
- let leftTimes = gData.gameData.leftTimes;
- if (leftTimes > 0) {
- mk.guide.curDes = `<color=8A4312><color=ff0000>继续生产${leftTimes}次</c>,很快就\n可以完成订单了!</color>`;
- return true;
- } else {
- // if(gData.gameData.moveMapNode)
- // {
- // gData.gameData.moveMapNode.move(new cc.Vec3(0, -370, 0));
- // }
- return false;
- }
- }
- public initGuideEvent() {
- if (gData.farmSystem._lastSeletFarm) {
- gData.farmSystem._lastSeletFarm.clickGuideBtn();
- }
- }
- //富翁银行
- /** 点击富翁银行 */
- public async onClickSafeDepositBox() {
- mk.audio.playEffect('button');
- let plantTimes = gData.gameData.getProp(GameProp.plantTimes);
- if (plantTimes == undefined) {
- plantTimes = 0;
- }
- if (plantTimes < gData.gameData.showRichBankIconLimit) {
- mk.tip.pop(`种植${gData.gameData.showRichBankIconLimit}次后开启`)
- return;
- }
- if (!gData.loginData.isAuth) {
- mk.ui.openPanel('module/authUI/authUI');
- return;
- }
- console.log(`currentRichBankCashTaskIndex 22======== ${gData.safeDepositBoxData.currentRichBankCashTaskIndex}`);
- if (gData.safeDepositBoxData.currentRichBankCashTaskIndex) {
- mk.ui.openPanel("module/safeDepositBox/SafeDepositBox");
- mk.data.sendDataEvent(DataEventId.button_click, "富翁银行icon");
- }
- }
- isAdd = true;
- public setJGTags() {
- //JsbSystem.addJGTags("富翁银行任务");
- //let curDes = `<color=8A4312>再生产${23}次,就可以收获\n啦,完成订单立即<color=ff0000>提现</color>!</color>`;
- //mk.guide.open(11, curDes);
- if (this.isAdd) {
- this.isAdd = false;
- JsbSystem.addJGTags("开玩笑");
- } else {
- this.isAdd = true;
- JsbSystem.deleteTags("开玩笑");
- }
- }
- public getAllTags() {
- JsbSystem.getAllTags();
- }
- }
|