import GameM, { VIDEO_TYPE, AUDIO_TYPE, Game_Quality } from "./manager/GameM"; import CarSpace from "./prefabs/CarSpace"; import CarMove from "./prefabs/CarMove"; import CarInfo from "./prefabs/CarInfo"; import UiM, { PANEL_NAME } from "./manager/UiM"; import GlobalStorage, { STORAGE_KEY } from "./datas/GlobalStorage"; import Shop from "./ui/Shop"; import Gift from "./ui/Gift"; import RedPointM, { RedPointType } from "./manager/RedPointM"; import Task from "./ui/Task"; import AdM from "./manager/AdM"; import PoolMgr, { NODEPOOLPREFABTYPE } from "./manager/PoolMgr"; import EffectNode from "./ui/EffectNode"; import Sciencen_M from "./utils/Sciencen_M"; import BuyProAdd from "./prefabs/BuyProAdd"; import Daily from "./ui/Daily"; import DailyCashProAdd from "./prefabs/DailyCashProAdd"; import GuideManager from "./manager/GuideManager"; import LogUtil from "./utils/LogUtil"; import BankQipaoTip from "./ui/BankQipaoTip"; import LocalManagerData from "./datas/LocalManagerData"; import Spray from "./prefabs/Spray"; import EachNodeAnim from "./ui/EachNodeAnim"; import TreasureData from "./datas/TreasureData"; import TurntableData from "./datas/TurntableData"; import CashOutData from "./datas/CashOutData"; import UIMng, { PanelType } from "./uiFrames/UIMng"; import { Role } from "./other/item/Role"; import { FightData } from "./datas/FightData"; import { MateData } from "./datas/MateData"; import MoreGameData from "./datas/MoreGameData"; import { Utils } from "./utils/Utils"; import { HTTP_TYPE, MONEY_TYPE, RecordTYPE } from "./datas/CommonData"; import UsualCaidanData from "./datas/UsualCaidanData"; import GuideMng from "./manager/GuideMng"; import DailyCashData from "./datas/DailyCashData"; import { GameController } from "./manager/GameController"; import { thirdVideoTS } from "./manager/topon/AnyThinkAdsMgr/thirdVideoTS"; import UsualCaidanNode from "./ui/UsualCaidanNode"; import NativeAdAwardData from "./manager/NativeAdAwardData"; import MyExtends from "./tools/MyExtends"; import ClubData from "./datas/ClubData"; import DailyData from "./datas/DailyData"; import HttpM from "./manager/HttpM"; import InvestData from "./datas/InvestData"; import WealthMng from "./manager/WealthMng"; import { WealthData } from "./datas/WealthData"; import Random from "./utils/Random"; import { RichData } from "./datas/RichData"; import DownloadApkData from "./datas/DownloadApkData"; import SwitchM from "./manager/SwitchM"; const { ccclass, property } = cc._decorator; @ccclass export default class Main extends cc.Component { @property(cc.Node) topPart: cc.Node = null @property(cc.Node) centerPart: cc.Node = null @property(cc.Sprite) head: cc.Sprite = null @property(cc.Label) labGold: cc.Label = null @property(cc.Label) labGoldSecond: cc.Label = null @property(cc.Node) CarPark: cc.Node = null @property(cc.Node) btnBuy: cc.Node = null @property(cc.Node) posBtnBuy: cc.Node = null @property(cc.Label) labLevel: cc.Label = null @property(cc.Label) labMoney: cc.Label = null @property(cc.Sprite) expFill: cc.Sprite = null @property(sp.Skeleton) composeAni: sp.Skeleton = null @property(cc.Animation) cicleFade: cc.Animation = null @property(cc.Node) hand: cc.Node = null @property(cc.Node) buyHand: cc.Node = null @property(cc.Animation) airshipAni: cc.Animation = null @property(cc.Animation) airshipHandAni: cc.Animation = null @property(cc.Button) chatBtn: cc.Button = null; @property(cc.Button) cashBtn: cc.Button = null; @property(cc.Node) redeemBtn: cc.Node = null; //看视频领红包 @property(cc.Node) adRbBtn: cc.Node = null; //模块按钮 @property(cc.Button) shopBtn: cc.Button = null; @property(cc.Button) taskBtn: cc.Button = null; @property(cc.Button) turntableBtn: cc.Button = null; @property(cc.Button) investBtn: cc.Button = null; @property(cc.Button) dailyCashBtn: cc.Button = null; @property(cc.Button) dailyBtn: cc.Button = null; @property(cc.Button) tixianProBtn: cc.Button = null; @property(cc.Node) wealthBtn: cc.Node = null; @property(cc.Node) richmanBtn: cc.Node = null; @property(cc.Button) treasureBtn: cc.Button = null; @property(cc.Button) bankBtn: cc.Button = null; @property(cc.Button) moreGameBtn: cc.Button = null; @property(cc.Button) shareBtn: cc.Button = null; //彩蛋按钮 @property(cc.Button) caidanBtn: cc.Button = null; @property(cc.Button) guideInstallBtn: cc.Button = null; @property(cc.Node) caidanHand: cc.Node = null; @property(cc.Node) cashHand: cc.Node = null @property(cc.Node) tipPos: cc.Node = null @property(cc.Node) canGet: cc.Node = null @property(cc.Sprite) tixianPro: cc.Sprite = null @property(cc.Label) labTixian: cc.Label = null @property(cc.Label) labTixianLv: cc.Label = null @property(cc.Label) labtargetCarLevel: cc.Label = null; @property(cc.Sprite) spTixianCar: cc.Sprite = null @property(cc.Sprite) carProSp: cc.Sprite = null; @property(cc.Node) approachEff: cc.Node = null @property(cc.Animation) hallLabAddEff: cc.Animation = null; @property(cc.Sprite) tixianFill: cc.Sprite = null; @property(cc.Label) tixianPercent: cc.Label = null @property(cc.Node) bankQipaoNode: cc.Node = null; @property(cc.Label) labTixianPro: cc.Label = null; @property(cc.Node) labWuFuNode: cc.Node = null; @property(BankQipaoTip) BankQipaoTip: BankQipaoTip = null; //常规彩蛋 @property(cc.Sprite) spCaidan: cc.Sprite = null; @property(cc.Node) newdan1: cc.Node = null; @property(cc.Label) labCaidanCount: cc.Label = null; @property(cc.Prefab) private pfb_Guide: cc.Prefab = null; //西游 @property(cc.Node) private xiYou_mates: cc.Node[] = []; //@property(sp.Skeleton) //private xiYou_spineSun: sp.Skeleton = null; //@property(sp.Skeleton) //private xiYou_spineBa: sp.Skeleton = null; @property(cc.Node) private xiYou_bgback: cc.Node = null; @property(cc.Sprite) private xiYou_bg: cc.Sprite = null; @property(cc.Node) private xiYou_bg_bottom: cc.Node = null; @property(cc.Node) private xiYou_talentParent: cc.Node = null; @property(cc.Prefab) private xiYouPfb_telentItem: cc.Prefab = null; @property(cc.Label) private txt_buyBtn: cc.Label = null; @property(cc.Node) private xiyou_guide_click: cc.Node = null; @property(cc.Node) private xiyou_guide_drag: cc.Node = null; private txt_wealthCoolTimer: cc.Label = null; @property(cc.Sprite) private spMoregame: cc.Sprite = null @property(cc.Label) private labMoregame: cc.Label = null private richBtnQipao: cc.Node = null; private richQipaoTxt: cc.Label = null; curCashCfg = null facLock: cc.Node = null carP: cc.Node carSpaceP: cc.Node index_s: number = 0 carSpaceArr = [] //offPos: cc.Vec2 = cc.v2(375, 627) offPos: cc.Vec2 = cc.v2(375, 667) //根据不同设备适配 P1: cc.Node = null P2: cc.Node = null hasHand = false handTween = null /** 舞台宽高 */ sW: number = 0 sH: number = 0 /** 当前买车类型 */ curBuyType: number = 0 //帧频采样数组 startGetFrameTime = false frameTotal = 0 frameTimeTotal = 0 frameAdd = 0 testFrames = 60 averageTime = 0 /** 放弃飞艇飞走中 */ airshipUp = false /** 每日提现当前配置 */ dailyCash = null //西游 /**车位尺寸*/ //carParkSize:cc.Vec2=cc.v2(138,138); //carParkSize: cc.Vec2 = cc.v2(100, 100); carParkSize: cc.Vec2 = cc.v2(141, 141); /**移动或合成最终y轴偏移量 标准分辨率为-303*/ moveEndY: number = -303; /**CarPark下边离屏幕下边距离*/ parkBottom: number = 152.50;// 189;// 162; //parkBottom: number = 230; /**park layout spacing x*/ parkSpaceX: number = 8;//25; /**park layout spacing y*/ parkSpaceY: number = 25;//70;// 40; /**点击时间戳 在此时间内的点击算单击车位 否为算拖拽*/ dragTime: number = 0.2; /**点击计时器*/ dragTimer: number = 0; onLoad() { //AdM.onSendEvent('loadEnd', '加载结束', 'load'); cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this); } async start() { if (!GameM.commonData.redSwitch) { cc.find('Canvas/HallNode/topPart/btnFight').active = false cc.find('Canvas/HallNode/centorPart/btnTask').active = false cc.find('Canvas/HallNode/downPart/btnInvestment').active = false cc.find('Canvas/HallNode/downPart/btnMate').active = false } this.composeRectNode = cc.find("Canvas/HallNode/ComposeRect"); this.txt_wealthCoolTimer = this.wealthBtn.getChildByName('normal').getChildByName('txtcooling').getComponent(cc.Label); this.richBtnQipao = this.richmanBtn.getChildByName('normal').getChildByName('qipao'); this.richQipaoTxt = this.richBtnQipao.getComponentInChildren(cc.Label); //this.txt_wealthCoolTimer=this.wealthBtn.getChildByName('normal').getChildByName('labLock').getComponent(cc.Label); cc.game.addPersistRootNode(this.node) GameM.commonData.updateGold('0') TurntableData.Instance.updateResetTurntable() //各模块是否解锁 this.checkModelBtnsUnlock(); this.addParkCar() this.carBuyInfo() this.updateBuyBtnState(); this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this) this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this) //西游 this.sW = cc.winSize.width this.sH = cc.winSize.height this.offPos = cc.v2(375, this.sH / 2); //西游 let temppy = this.parkBottom + this.CarPark.height / 2; this.moveEndY = -((temppy <= this.sH / 2 ? this.sH / 2 - temppy : temppy - this.sH / 2) + 86.9); //this.moveEndY = -(86.9 + Math.abs(this.CarPark.y)); //console.log("----->" + this.moveEndY + " temppy:" + temppy + "PY:" + (temppy <= this.sH ? this.sH - temppy : temppy - this.sH)); if (this.sH > 1500) { this.topPart.y += 90 } this.delayAddGift() this.startAddTimer() this.schedule(this.storeGameTime, 10) this.storeGameTime() GameM.commonData.updateRoleDataExp('0') // let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.hangupVideoTimes * 0.2 - 2)) // if (percent >= 1) { // let videoSpan = 15 // this.schedule(this.checkPopVideo, videoSpan) // } UiM.Instance.taskNode.getComponent(Task).init() this.setGuideInstallVisible(false) this.setImg() if (GameM.commonData.redSwitch) { this.labMoney.string = `${Math.floor(GameM.commonData.redMoney)} ≈ ${(GameM.commonData.redMoney * 0.0001).toFixed(3)}元` } else { this.labMoney.string = `${GameM.commonData.redMoney}` } this.checkShowAirship() GameM.httpM.sendDatas(HTTP_TYPE.getRedMoneyRecord, null, GameM.commonData.resultRedMoneyRecord.bind(GameM.commonData)) GameM.audioM.init() this.checkNewUser() this.scheduleOnce(() => { this.checkOfflineAward() }, 0.5) this.chatBtn.node.active = GameM.commonData.redSwitch //西游 //this.cashBtn.node.active = GameM.commonData.redSwitch this.dailyBtn.node.active = GameM.commonData.redSwitch this.dailyCashBtn.node.active = GameM.commonData.redSwitch this.bankBtn.node.active = GameM.commonData.redSwitch this.treasureBtn.node.active = GameM.commonData.redSwitch this.tixianProBtn.node.active = GameM.commonData.redSwitch this.shareBtn.node.active = false // GameM.commonData.redSwitch this.freshDailyRed() GameM.commonData.quality = Game_Quality.mediumHigh this.checkTixianPro(true) TreasureData.Instance.getLuckydrawConfig() let loadEnd = GameM.globalStorage.getStorage(STORAGE_KEY.firstLoadEnd) if (loadEnd == null) { loadEnd = 1 GameM.globalStorage.setStorage(STORAGE_KEY.firstLoadEnd, loadEnd) AdM.onSendEvent('firstLoadEnd', '第一次加载结束') } AdM.onSendEvent('loadEnd', '加载结束进入主场景', 'load') if (SwitchM.firstLoginLog) { AdM.sendUmeng('umLoadEnd', '加载结束') } SwitchM.firstLoginLog = false //检查授权 //注释掉 还原为一上线就授权 // AdM.checkPermission() let can = GameM.commonData.checkCanShowSplash() if (can) { AdM.showSplash() } this.checkCanVideo() GameM.commonData.checkShowFull() if (GameM.commonData.maxCarLevel >= GameM.commonData.richBankUnLockLevel && GameM.commonData.isopenrichbank == 0) { GameM.httpM.sendDatas(HTTP_TYPE.backIsOpenRichBank) GameM.commonData.isopenrichbank = 1 } //UIMng.Ins.GetPanel(PanelType.TestPanel).OnEnter(); // this.caidanBtn.node.active = false UsualCaidanData.Instance.getUsualEggData(false) // //test // this.caidanBtn.node.active = true this.freshDailyPro() //每日登录奖励红点 DailyData.Instance.checkHasGet() MateData.Ins.checkMateRedPoint() //西游 this.DisplayMate(); MateData.Ins.DisplayTalent(this.xiYou_talentParent, this.xiYouPfb_telentItem); MoreGameData.Instance.sendRecommendList(); this.UpdateMainBg(); //首次新手引导 GuideMng.Ins.CheckGuide1(); //西游测试 this.txt_buyBtn.string = "购买按钮(购买次数):" + GameM.commonData.buyTimeTotal; //常规引导 this.schedule(this.CheckNormalGuide, 5); if (GameM.commonData.IsTest) { this.scheduleOnce(() => { GameM.commonData.updateGold("999999999999999999999999"); GameM.httpM.sendDatas(HTTP_TYPE.updateGold, { 'gold': GameM.commonData.gold }); }, 3); } //请求工会数据 用于埋点 ClubData.Instance.requestClubMyRecruitMembers() //初始化天降财神 let wealth = cc.instantiate(await Utils.loadResPromise("prefabs/GameWealth")); wealth.parent = this.node.parent; wealth.setSiblingIndex(this.node.getSiblingIndex() + 1); //大富翁 this.RichManInit(); //this.UpdateRichManQipao(); //礼包兑换 this.CheckRedeem(); //看视频领红包 this.CheckAdRb(); this.checkShowCashBtns(); } freshDailyPro() { if (GameM.commonData.roleData.dailyCashAniPlayed == 1) { if (DailyCashData.Instance.userDailyCashInfo) { this.labTixianPro.node.active = true // this.dailyCash = DailyCashData.Instance.getTodayDailyCash() this.dailyCash = DailyCashData.Instance.userDailyCashInfo this.tixianFill.fillRange = GameM.commonData.roleData.dailyPro / this.dailyCash.buyTime this.labTixianPro.string = `提现进度:${GameM.commonData.roleData.dailyPro}/${this.dailyCash.buyTime}` this.labWuFuNode.active = false } else { DailyCashData.Instance.getDailyCashBuyTime() } } else { this.labTixianPro.node.active = false this.labWuFuNode.active = true } } /**更新金币*/ UpdateCoinTxt(num: string) { this.labGold.string = num; cc.Tween.stopAllByTarget(this.labGold.node); cc.tween(this.labGold.node) .to(0.15, { scale: 1.2 }) .to(0.15, { scale: 1 }) .start(); } /**获取引导物体*/ GetGuide() { return cc.instantiate(this.pfb_Guide); } update(dt) { this.frameTotal++ if (this.frameTotal == 600) { this.startGetFrameTime = true this.frameTimeTotal = 0 this.frameAdd = 0 } if (this.startGetFrameTime) { this.frameAdd++ if (this.frameAdd <= this.testFrames) { this.frameTimeTotal += dt if (this.frameAdd == this.testFrames) { this.averageTime = this.frameTimeTotal / this.testFrames this.frameTotal = 0 this.startGetFrameTime = false if (this.averageTime > 0.0222222) { if (GameM.commonData.quality > Game_Quality.low) { GameM.commonData.quality-- } } else { if (GameM.commonData.quality < Game_Quality.high) { GameM.commonData.quality++ } } } } } this.MoveBg(dt); this.TimerWealthCooling(); } freshDailyRed() { RedPointM.instance.ActiveRedPoint(RedPointType.ChatReaPacket, true) // let len = GameM.commonData.dailyCfg.length // let red = false // let data = null // for (var i = 0; i < len; i++) { // data = GameM.commonData.dailyCfg[i] // if (GameM.commonData.dailyGetArr[i] == '0') { // if (GameM.commonData.loginDays >= data.getDay) { // if (data.conditionType == 1) { // red = true // break // } // if (data.conditionType == 2) { // if (GameM.commonData.maxCarLevel >= data.conditionLv) { // red = true // break // } // } // else if (data.conditionType == 3) { // if (GameM.commonData.roleData.lv >= data.conditionLv) { // red = true // break // } // } // } // } // } // RedPointM.instance.ActiveRedPoint(RedPointType.ChatReaPacket, red) } /** 显示提现引导 */ showCashHand() { this.cashHand.active = true } hideCashHand() { this.cashHand.active = false } /** 是否是新用户 */ checkNewUser() { if (GameM.commonData.redSwitch) { if (GameM.commonData.roleData.newuser < 2) { if (GameM.commonData.roleData.newuser == 0) { this.scheduleOnce(() => { //先创建全屏的秘书引导,再进行之前的引导 GuideManager.Instance.createFullGuide(this.node, 1, () => { this.checkNewUser() }) //GuideMng.Ins.CheckGuide1(); }, 1) } else { this.scheduleOnce(() => { //先创建全屏的秘书引导,再进行之前的引导 GuideManager.Instance.createFullGuide(this.node, 4, () => { if (GameM.commonData.step < 4 && GameM.commonData.roleData.lv < 2) { this.buyHand.active = false // UiM.Instance.guideNode.getComponent(Guide).showStep() } }) }, 0.1) } } else { this.scheduleOnce(() => { if (GameM.commonData.step < 4 && GameM.commonData.roleData.lv < 2) { this.buyHand.active = false // UiM.Instance.guideNode.getComponent(Guide).showStep() } }, 0.1) } } } /** 第二天登录,满足条件弹出 */ checkPopSecretary() { this.scheduleOnce(() => { if (GameM.commonData.loginDays >= 2) { if (GameM.commonData.maxCarLevel >= GameM.commonData.dailyCashOpenLevel && GameM.commonData.roleData.dailyCashAniPlayed == 0) { UiM.Instance.redPackageNode.init(0, 0, 4, null, true) UiM.Instance.redPackageNode.node.x = 0 UiM.Instance.redPackageNode.node.active = true //西游 if (!RichData.Ins.isOpenRichPanel) { GameM.audioM.setPauseMusic(); GameM.audioM.playMateEffect(AUDIO_TYPE.fiveluckbgm); } } else { this.checkShowClubGuideNode() // if (GameM.commonData.roleData.ifGuideSecrtary) { // GameM.commonData.checkDaysPieceUnlock() // } } } else { } }, 2) } //弹出俱乐部海报 checkShowClubGuideNode() { //吐槽 不弹出 裂变海报 return; let showClubGirl = GameM.globalStorage.getStorage(STORAGE_KEY.showClubGirl) if (showClubGirl > 0) { GameM.globalStorage.setStorage(STORAGE_KEY.showClubGirl, 0) UiM.Instance.onPanel(PANEL_NAME.clubGuideNode) } } showDialyPanel(force = false) { if (GameM.commonData.redSwitch) { if (force) { //console.log("-------------------1") UiM.Instance.onPanel(PANEL_NAME.DailyNode) } else { if (!UiM.Instance.dailyNode && GameM.commonData.maxCarLevel >= 10) { //console.log("-------------------2") UiM.Instance.onPanel(PANEL_NAME.DailyNode) } } } } setImg() { let self = this if (GameM.commonData.headimgurl != '') { cc.loader.load(GameM.commonData.headimgurl + "?aaa=aa.jpg", (err, res) => { if (err) { console.log('err:', err); return; } if (self.head) { let tex: cc.Texture2D = res as cc.Texture2D; self.head.spriteFrame = new cc.SpriteFrame(tex); } }) } this.checkShowGuideInstall() } /**检查各模块是否解锁*/ checkModelBtnsUnlock() { if (GameM.commonData.maxCarLvCanBuy >= GameM.commonData.curVideoCarType) { RedPointM.instance.ActiveRedPoint(RedPointType.Shop, true) } else { RedPointM.instance.ActiveRedPoint(RedPointType.Shop, false) } this.checkTaskRed() this.checkTurntableRed() let isUnlockInvest = GameM.commonData.maxCarLevel >= GameM.commonData.investOpenLevel ? true : false if (isUnlockInvest) { InvestData.Instance.getInvestInfo() } RedPointM.instance.UpdateRedPointState(); //提现 //this.unLockBtn(this.tixianProBtn, GameM.commonData.cashOpenLevel) //每日提现 this.unLockBtn(this.dailyCashBtn, GameM.commonData.dailyCashOpenLevel) //投资引导 //this.checkMateLockBtn(3, GameM.commonData.investOpenLevel) this.unLockBtn(this.investBtn, GameM.commonData.investOpenLevel) //转盘 this.unLockBtn(this.turntableBtn, GameM.commonData.turntableOpenLevel) //小秘书 // this.unLockBtn(this.secretaryBtn, 9) //登录豪礼 this.unLockBtn(this.dailyBtn, GameM.commonData.loginRewardOpenLevel) //现金夺宝 this.unLockBtn(this.treasureBtn, GameM.commonData.trerasureOpenLevel) // //银行富翁 改为判断4号伙伴 // this.checkMateLockBtn(4, GameM.commonData.richBankUnLockLevel) //银行富翁 this.unLockBtn(this.bankBtn, GameM.commonData.richBankUnLockLevel) //每日任务 this.unLockBtn(this.taskBtn, GameM.commonData.taskOpenLevel) //财神降临 this.unLockBtn(this.wealthBtn.getComponent(cc.Button), GameM.commonData.unlockWealthLevel) } /** 检查任务红点 */ checkTaskRed() { if (GameM.commonData.dailyTaskRedNum > 0) { RedPointM.instance.ActiveRedPoint(RedPointType.Task, true) } else { RedPointM.instance.ActiveRedPoint(RedPointType.Task, false) } if (UiM.Instance.taskNode) { UiM.Instance.taskNode.getComponent(Task).freshRed() } } /** 是否显示飞艇 */ checkShowAirship() { if (GameM.commonData.step > 3) { this.airshipAni.node.active = false if (this.airshipHandAni.node.active) { this.airshipHandAni.node.active = false; } if (GameM.commonData.airshipTimes < 10) { let delayTime = 90 this.scheduleOnce(this.showAirship, delayTime) NativeAdAwardData.Instance.resetGetAward(2) // this.schedule(this.getAirByRan, 90) } } } curAirCfg = null getAirByRan() { LogUtil.logV("getAirByRan", "start") if (GameM.commonData.airshipTimes < 10) { let tempCfg = GameM.commonData.airshipCfg let airCfg = new Array() let range = 0 for (let entry of tempCfg) { if (entry.limit != null && entry.limit != undefined) { let reward = new Number(entry.reward).valueOf() let nowTimes = 0 let canAdd = true switch (reward) { case MONEY_TYPE.speedCard: nowTimes = GameM.commonData.roleData.airshipSpeedCard if (GameM.commonData.maxCarLevel < GameM.commonData.investOpenLevel) { canAdd = false } break; case MONEY_TYPE.turnTableCard: nowTimes = GameM.commonData.roleData.airshipTurntableCard break; case MONEY_TYPE.treasureCard: nowTimes = GameM.commonData.roleData.airshipTicket if (GameM.commonData.maxCarLevel < GameM.commonData.trerasureOpenLevel) { canAdd = false } break; } if (nowTimes < entry.limit && canAdd) { airCfg.push(entry) range += entry.chance } } else { airCfg.push(entry) range += entry.chance } } // LogUtil.logV("getAirByRan airCfg", airCfg) let ran = Math.floor(Math.random() * range) let add = 0 for (var i = 0; i < airCfg.length; i++) { add += airCfg[i].chance if (ran <= add) { if (this.curAirCfg == airCfg[i]) { this.getAirByRan() } else { this.curAirCfg = airCfg[i] } break } } } else { this.unschedule(this.getAirByRan) } // LogUtil.logV("getAirByRan curAirCfg", this.curAirCfg) } showAirship() { this.getAirByRan() this.airshipAni.node.active = true this.airshipAni.setCurrentTime(0, 'airship') this.airshipAni.play() NativeAdAwardData.Instance.setGetAward(2) } /** 离线奖励 */ checkOfflineAward() { if (GameM.commonData.offlineTime >= 60) { let awardTime = GameM.commonData.offlineTime <= GameM.commonData.offlineTimeMax ? GameM.commonData.offlineTime : GameM.commonData.offlineTimeMax let goldNum = Sciencen_M.instance.accMul(GameM.commonData.goldSecond.toString(), String(awardTime * 1)) //白龙马天赋2 goldNum = Sciencen_M.instance.addition(goldNum, Sciencen_M.instance.accMul(goldNum, (MateData.Ins.Mate3Talent2 * 0.01).toString())) if (goldNum != '0') { UiM.Instance.checkDelayShow(() => { UiM.Instance.giftNode.active = true let gift = UiM.Instance.giftNode.getComponent(Gift) gift.init(MONEY_TYPE.offlineGold, goldNum) GameM.commonData.offlineTime = 0 }) } } else { if (DailyData.Instance.checkHasGet() && GameM.commonData.maxCarLevel >= GameM.commonData.loginRewardOpenLevel) { UiM.Instance.onPanel(PANEL_NAME.DailyNode) } else { this.checkPopSecretary() } } } /** 开始游戏检查是否可以看视频 * @param start true 开始游戏检查 false 点击视频检查 */ checkCanVideo(start = true) { if (start) { if (GameM.commonData.videoCoolDown > 0) { this.schedule(this.onVideoTimeSchedule, 1) } } else { let can = false if (GameM.commonData.videoCoolDown <= 0) { can = true } else { can = false EffectNode.instance.PlayTip(`当前看视频太频繁了,请${GameM.commonData.videoCoolDown}秒后再试`) } return can } } /** 开始看视频冷却倒计时 */ startVideoCoolDown() { GameM.commonData.videoCoolDown = GameM.commonData.videoCoolTime console.log('startVideoCoolDown ', GameM.commonData.videoCoolDown) GlobalStorage.Instance.setStorage(STORAGE_KEY.videoCoolDown, GameM.commonData.videoCoolDown) this.schedule(this.onVideoTimeSchedule, 1) } onVideoTimeSchedule() { GameM.commonData.videoCoolDown-- console.log('onVideoTimeSchedule ', GameM.commonData.videoCoolDown) if (GameM.commonData.videoCoolDown % 10 == 0) { GlobalStorage.Instance.setStorage(STORAGE_KEY.videoCoolDown, GameM.commonData.videoCoolDown) } if (GameM.commonData.videoCoolDown <= 0) { this.unschedule(this.onVideoTimeSchedule) } } checkTurntableRed() { if (TurntableData.Instance.turntableTimes > 0) { RedPointM.instance.ActiveRedPoint(RedPointType.Turnplate, true) } else { RedPointM.instance.ActiveRedPoint(RedPointType.Turnplate, false) } } /** 探索红点 */ setInvestRed(state) { // this.schedule(this.freshInvestTime, 1) RedPointM.instance.ActiveRedPoint(RedPointType.Invest, state) } // /** 刷新投资倒计时 */ // freshInvestTime() { // InvestData.Instance.updateInvestDataTime() // } private firstIn = true /** 存储游戏时间戳,用来计算离线时间 */ storeGameTime() { if (this.firstIn) { this.firstIn = false if (!GameM.commonData.useLocalData) { GameM.commonData.gameTime = GameM.commonData.currentTime } this.schedule(this.onGameTimeAdd, 1) } else { GameM.commonData.gameAdd += 10 GameM.globalStorage.setStorage(STORAGE_KEY.gameAdd, GameM.commonData.gameAdd) } if (GameM.commonData.useLocalData) { GameM.commonData.gameTime = new Date().getTime() GameM.globalStorage.setStorage(STORAGE_KEY.gameTime, GameM.commonData.gameTime) } else { GameM.httpM.sendDatas(HTTP_TYPE.updateGold, { 'gold': GameM.commonData.gold }) } TurntableData.Instance.updateResetTurntable() if (GameM.commonData.popIdentifySwitch) { GameM.commonData.todayPlayTime += 10 GameM.globalStorage.setStorage(STORAGE_KEY.todayPlayTime, GameM.commonData.todayPlayTime) if (UiM.Instance.AntiAddictionNode == null) { if (GameM.commonData.identification == 2) { if (GameM.commonData.todayPlayTime >= 5400) { UiM.Instance.onPanel(PANEL_NAME.AntiAddictionNode) } } } } } onGameTimeAdd() { if (!GameM.commonData.useLocalData) { GameM.commonData.gameTime += 1 * 1000 } } /** 自动拉取视频 */ checkPopVideo() { if (GameM.commonData.maxCarLevel < 7) { return } if (!GameM.commonData.isWatchVideo) { if (!GameM.commonData.hasTouch) { let percent1 = 1 / (1 + Math.max(0, GameM.commonData.roleData.hangupVideoTimes * 0.2 - 2)) if (percent1 < 1) { this.unschedule(this.checkPopVideo) return } let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.hangupVideoTimes * 0.4 - 2)) //弹出视频 if (GameM.commonData.hasPopVideo) { GameM.commonData.hasTouch = true let gift = UiM.Instance.giftNode.getComponent(Gift) let num = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold num = Sciencen_M.instance.accMul(num, percent.toString()) percent = Math.floor(percent * 100) gift.init(MONEY_TYPE.gold, num, null, false, 0, null, percent) UiM.Instance.giftNode.active = true UiM.Instance.giftNode.x = 1000 if (GameM.commonData.isVideoTest) { this.onHangUpAdEnd() } else { GameM.adM.watchVideo(VIDEO_TYPE.hangUp) } } else { GameM.commonData.hasPopVideo = true let gift = UiM.Instance.giftNode.getComponent(Gift) let num = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold num = Sciencen_M.instance.accMul(num, percent.toString()) percent = Math.floor(percent * 100) UiM.Instance.giftNode.x = 0 gift.init(MONEY_TYPE.popVideo, num, null, false, 0, null, percent) UiM.Instance.giftNode.active = true // if (!UiM.Instance.guideNode.active) { // } } } else { GameM.commonData.hasTouch = false } } else { GameM.commonData.hasTouch = false } } onHandUpAdFail() { GameM.commonData.hasPopVideo = false UiM.Instance.giftNode.active = false UiM.Instance.giftNode.x = 0 AdM.destroyNative() } onHangUpAdEnd() { EffectNode.instance.PlayTip('视频观看成功,额外奖励已发放') let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.hangupVideoTimes * 0.4 - 2)) let num = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold num = Sciencen_M.instance.accMul(num, percent.toString()) GameM.commonData.updateGold(num) GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)); GameM.commonData.updateHangupVideoTimes() GameM.commonData.hasPopVideo = false } /**西游 增加一个角色*/ addRunRole(type, carspace: CarSpace, startRan = false) { let role = new Role(); role.Init(type, startRan, carspace); //GameM.commonData.roleArr.push(role) carspace.role = role; GameM.commonData.updateGoldSecond(); } /**西游 删除一个角色*/ removeRunRole(carspace: CarSpace) { if (carspace.role != null) { carspace.role.RemoveStrike(); } carspace.role = null; carspace.RoleInit(false); GameM.commonData.updateGoldSecond(); } /**西游 清除所有的罢工状态*/ clearAllCoolTime() { for (let entry of this.carSpaceArr) { // if(entry){ if (cc.isValid(entry)) { let carSprace: CarSpace = entry.getComponent(CarSpace) if (carSprace && carSprace.role) { carSprace.role.RemoveStrike() carSprace.RoleInit(false) } } } } async addParkCar() { let pre = await Utils.loadResPromise("prefabs/CarMove") GameM.selCarMove = cc.instantiate(pre) this.node.addChild(GameM.selCarMove) GameM.otherCarMove = cc.instantiate(pre) this.node.addChild(GameM.otherCarMove) let s; let data = null console.log("CarParkNum:" + this.CarPark.childrenCount); this.CarPark.children.forEach(space => { s = space.getComponent(CarSpace) s.index = this.index_s space.name = s.index.toString() //console.log("--->index:"+s.index); data = GameM.commonData.getBagCarDataByPos(s.index) s.type = data.type if (s.type == MONEY_TYPE.redMoney) { GameM.commonData.hasRedMoney++ } if (s.type != 0 && s.type < 10000) { //西游 if (GameM.commonData.isUseXiYouAddCoin) { this.addRunRole(s.type, s, true); //s.AddCoinSpawn(true); } } s.init(true, data.num) this.index_s++ this.carSpaceArr.push(space) }); LogUtil.logV('GameM.commonData.hasRedMoney ', GameM.commonData.hasRedMoney) } addAParkCar(pos, type) { GameM.commonData.updateBagCarData(pos, type) let space = this.CarPark.getChildByName(pos) let s = space.getComponent(CarSpace) s.type = type s.init(true) if (GameM.commonData.isUseXiYouAddCoin) { //西游 this.addRunRole(type, s); //s.AddCoinSpawn(); } } /**是否存在空车位*/ IsHaveEmptySpace() { let len = GameM.commonData.bagCar.length for (var i = 0; i < len; i++) { if (GameM.commonData.bagCar[i].type == 0) { return true; } } return false; } /** 获取一个空位 */ getEmptySpace() { let value = '' let len = GameM.commonData.bagCar.length //console.log("Length:" + len); // for (var i = 0; i < len; i++) { // if (GameM.commonData.bagCar[i].type == 0) { // value = GameM.commonData.bagCar[i].pos.toString() // break // } // } //西游 for (var i = 0; i < len; i++) { if (GameM.commonData.bagCar[i].type == 0) { if (this.carSpaceArr[i].getComponent(CarSpace).isCanOperate) { value = GameM.commonData.bagCar[i].pos.toString() break } } } return value } private strikeNode: cc.Node = null; /** * 西游 * 获取一个有车车位索引 */ GetRoleSpaceIndex() { let value = '' let len = GameM.commonData.bagCar.length for (var i = 0; i < len; i++) { if (GameM.commonData.bagCar[i].type != 0 && GameM.commonData.bagCar[i].type < 10000) { value = GameM.commonData.bagCar[i].pos.toString() this.strikeNode = this.CarPark.getChildByName(value); break } } return value; } /** 检测是否点到 * @param point 点击的点 * @param state 0 起始点 1 结束点 */ checkClickPos(point: cc.Vec2, state: number) { let result = false let addX = this.CarPark.width * 0.5 let addY = this.CarPark.height * 0.5 //let pointY = point.y - 130 let pointY = point.y - this.offPos.y; //console.log("X:" + point.x + "," + point.y + " YY:" + pointY + " ADDA:" + (this.CarPark.y - addY) + ",ADDB:" + (this.CarPark.y + addY)); //let pointY = point.y - 100 if (point.x < this.offPos.x - addX || point.x > this.offPos.x + addX) { console.log("false 1") return result } if (pointY < this.CarPark.y - addY || pointY > this.CarPark.y + addY) { //console.log("false 2") return result } //航海 //if (pointY < this.offPos.y - addY || pointY > this.offPos.y + addY) { // console.log("false 2") // return result //} if (GameM.commonData.step <= 3 && GameM.commonData.roleData.lv < 2) { if (point.x > this.offPos.x + addX - 200) { console.log("false 3") return result } //if (pointY < this.offPos.y - addY + 120 * 4 + 60) { //航海 //if (pointY < this.offPos.y - addY + 120 * 3 + 45) { //西游 //console.log("---<>" + this.CarPark.y + " ofY:" + this.offPos.y + " TY:" + (this.offPos.y - addY + 120 * 3 + 45)); //if (pointY < this.CarPark.y - addY + 138 * 2 + 30) { //西游 if (pointY < this.CarPark.y - addY + this.carParkSize.x * 2 + 80) { //西游 console.log("false 4") return result } } let localPosX = point.x - this.offPos.x //let localPosY = pointY - this.offPos.y //航海 //let localPosY = pointY - this.CarPark.y - 80; let localPosY = pointY - this.CarPark.y; //let localPosY = pointY - this.CarPark.y - 26; //console.log("LocalY: " + localPosY); //let tx = 170 * 0.5 //let ty = 120 * 0.5 let tx = this.carParkSize.x * 0.5 let ty = this.carParkSize.x * 0.5 this.CarPark.children.forEach(element => { if (localPosX >= element.position.x - tx && localPosX <= element.position.x + tx) { //if (localPosY >= element.position.y - ty - 36 && localPosY <= element.position.y + ty - 26) { //if (localPosY >= element.position.y - ty - this.parkSpaceY * 2 && localPosY <= element.position.y + ty - this.parkSpaceY * 2) { if (localPosY >= element.position.y - ty && localPosY <= element.position.y + ty) { if (state == 0) { this.P1 = element let s = this.P1.getComponent(CarSpace) if (s.type != 0 && s.type < 10000) { s.hideImg() } GameM.selCarMove.getComponent(CarMove).onShow(s.index, s.type) if (s.type != 0) { result = true } } else if (state == 1) { this.P2 = element let s = this.P2.getComponent(CarSpace) if (this.P1 != null && s.type < 10000) { //西游 if (this.coolTime && this.curGuideId != 11) { let s1 = this.P1.getComponent(CarSpace) if (s1.type != 0 && s1.type < 10000) { if (s.isCanOperate) { s.hideImg() GameM.otherCarMove.setPosition(cc.v2(this.P2.position.x, this.P2.position.y - 70 + this.moveEndY)) GameM.otherCarMove.getComponent(CarMove).onShow(s.index, s.type) result = true } } } //航海 //let s1 = this.P1.getComponent(CarSpace) //if (s1.type != 0 && s1.type < 10000) { // s.hideImg() // GameM.otherCarMove.setPosition(cc.v2(this.P2.position.x, this.P2.position.y - 70 + this.moveEndY)) // GameM.otherCarMove.getComponent(CarMove).onShow(s.index, s.type) // result = true //} } } } } }) return result } /** 检测是否点到非空非车位(角色 金币 礼包等) * @param point 点击的点 */ checkClickNoEmptyOther(point: cc.Vec2,) { let result = false let addX = this.CarPark.width * 0.5 let addY = this.CarPark.height * 0.5 //let pointY = point.y - 130 let pointY = point.y - this.offPos.y; //console.log("X:" + point.x + "," + point.y + " YY:" + pointY + " ADDA:" + (this.CarPark.y - addY) + ",ADDB:" + (this.CarPark.y + addY)); //let pointY = point.y - 100 if (point.x < this.offPos.x - addX || point.x > this.offPos.x + addX) { //console.log("false 1") return result } if (pointY < this.CarPark.y - addY || pointY > this.CarPark.y + addY) { //console.log("false 2") return result } //航海 //if (pointY < this.offPos.y - addY || pointY > this.offPos.y + addY) { // console.log("false 2") // return result //} if (GameM.commonData.step <= 3 && GameM.commonData.roleData.lv < 2) { if (point.x > this.offPos.x + addX - 200) { console.log("false 3") return result } //if (pointY < this.offPos.y - addY + 120 * 4 + 60) { //航海 //if (pointY < this.offPos.y - addY + 120 * 3 + 45) { //西游 //console.log("---<>" + this.CarPark.y + " ofY:" + this.offPos.y + " TY:" + (this.offPos.y - addY + 120 * 3 + 45)); //if (pointY < this.CarPark.y - addY + 138 * 2 + 30) { //西游 if (pointY < this.CarPark.y - addY + this.carParkSize.x * 2 + 80) { //西游 console.log("false 4") return result } } let localPosX = point.x - this.offPos.x //let localPosY = pointY - this.offPos.y //航海 //let localPosY = pointY - this.CarPark.y - 80; let localPosY = pointY - this.CarPark.y; //let localPosY = pointY - this.CarPark.y - 26; //console.log("LocalY: " + localPosY); //let tx = 170 * 0.5 //let ty = 120 * 0.5 let tx = this.carParkSize.x * 0.5 let ty = this.carParkSize.x * 0.5 this.CarPark.children.forEach(element => { if (localPosX >= element.position.x - tx && localPosX <= element.position.x + tx) { //if (localPosY >= element.position.y - ty - 36 && localPosY <= element.position.y + ty - 26) { //if (localPosY >= element.position.y - ty - this.parkSpaceY * 2 && localPosY <= element.position.y + ty - this.parkSpaceY * 2) { if (localPosY >= element.position.y - ty && localPosY <= element.position.y + ty) { //console.log("------ok"); this.P1 = element let s = this.P1.getComponent(CarSpace) if (s.type != 0 && s.type > 0) { result = true; } //if (s.type != 0) { // if (s.type >= 10000) { // result = true; // } else { // //单击到角色 // result = false; // //s.ClickRole(); // } //} } } }) return result } hideHandGuide() { if (this.hasHand) { this.hasHand = false if (this.handTween) { this.handTween.stop() } this.hand.active = false } } hideAllHand() { this.hasHand = false if (this.handTween) { this.handTween.stop() } this.hand.active = false this.buyHand.active = false this.cashHand.active = false } showBuyCarHand() { // this.hideHandGuide() // this.buyHand.x = 50 // this.buyHand.active = true cc.tween(this.btnBuy) .delay(0.3) .to(0.3, { scale: 1.2 }) .to(0.3, { scale: 1 }) .start() } showInvestHand() { this.hideHandGuide() //this.buyHand.x = 200 this.buyHand.x = 180 this.buyHand.active = true } private coolTime = false onTouchStart(evt) { //MyExtends.GetAryByAry(5, [1, 2, 3, 4, 5, 6, 7], true); //console.log("----Cool" + this.coolTime); if (this.coolTime) { return } this.P1 = null this.P2 = null //西游 let tempstartpos = evt.touch._point; this.moveStartPos = cc.v2(); this.moveStartPos.x = tempstartpos.x; this.moveStartPos.y = tempstartpos.y; this.IsClickOther = this.checkClickNoEmptyOther(evt.touch._point); if (this.IsClickOther) { this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this) this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchCacel, this) //console.log("--->On End") } this.curGuideId = GuideMng.Ins.CurGuideId; //航海 //let result = this.checkClickPos(evt.touch._point, 0) //if (result) { // this.coolTime = true // this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this) // this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this) // this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchCacel, this) // // let localPosX = evt.touch._point.x - this.sW * 0.5 // let localPosY = evt.touch._point.y - this.sH * 0.5 // GameM.selCarMove.setPosition(localPosX, localPosY) // // this.showCanCompose() // this.hideHandGuide() // // if (GameM.selCarMove.getComponent(CarMove).type < 10000 && GameM.selCarMove.getComponent(CarMove).type != 0) // this.ActiceTrashState(true); //} } showCanCompose() { let type = this.P1.getComponent(CarSpace).type let s this.CarPark.children.forEach(element => { if (element != this.P1) { s = element.getComponent(CarSpace) if (s.type != 0 && s.type < 10000 && s.type == type) { s.showCanCompose() } } }) } hideCanCompose() { let s this.CarPark.children.forEach(element => { s = element.getComponent(CarSpace) s.hideCanCompose() }) } //西游 /**合成引导移动限制区域*/ composeRectNode: cc.Node = null; curGuideId: number = -1; /**是否点击到非车位 金币 礼包等*/ IsClickOther: boolean = false; /**移动相应距离算拖拽*/ moveDisTarget: number = 30; /**移动的距离*/ moveDis: number = 0; /**点击坐标*/ moveStartPos: cc.Vec2 = null; /**拖动坐标*/ moveingPos: cc.Vec2 = cc.v2(); /**是否可以拖动*/ moveOpen: boolean = false onTouchMove(evt) { //西游 if (this.moveStartPos == null) return; this.moveingPos = this.moveStartPos.sub(evt.touch._point); this.moveDis = this.moveingPos.len(); if (this.moveDis >= this.moveDisTarget && !this.coolTime) { let result = this.checkClickPos(this.moveStartPos, 0) if (result) { this.coolTime = true //console.log("---Set true") this.moveOpen = true; if (!this.IsClickOther) { //this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this)//航海 this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this) this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchCacel, this) //console.log("--->On End move") } let localPosX = evt.touch._point.x - this.sW * 0.5; let localPosY = evt.touch._point.y - this.sH * 0.5; GameM.selCarMove.setPosition(localPosX, localPosY); this.showCanCompose() this.hideHandGuide() if (GameM.selCarMove.getComponent(CarMove).type < 10000 && GameM.selCarMove.getComponent(CarMove).type != 0) this.ActiceTrashState(true); } } if (this.coolTime) { if (GameM.selCarMove.getComponent(CarMove).sel) { let localPosX = evt.touch._point.x - this.sW * 0.5 let localPosY = evt.touch._point.y - this.sH * 0.5 if (this.curGuideId == 1) { if (!MyExtends.PointIsOverRect(cc.v2(localPosX, localPosY), this.composeRectNode)) { GameM.selCarMove.setPosition(localPosX, localPosY); } } else if (this.curGuideId == 11) { } else { GameM.selCarMove.setPosition(localPosX, localPosY); } //let localPosX = evt.touch._point.x - this.sW * 0.5 //let localPosY = evt.touch._point.y - this.sH * 0.5 //GameM.selCarMove.setPosition(localPosX, localPosY) } } //console.log("---Move CooolTime:" + this.coolTime); //航海 //console.log("Start:" + this.moveStartPos.x + " Move:" + this.moveingPos.x + "---Length:" + this.moveDis); //if (GameM.selCarMove.getComponent(CarMove).sel) { // let localPosX = evt.touch._point.x - this.sW * 0.5 // let localPosY = evt.touch._point.y - this.sH * 0.5 // GameM.selCarMove.setPosition(localPosX, localPosY) //} } onTouchEnd(evt) { let ms = GameM.selCarMove.getComponent(CarMove) let os = GameM.otherCarMove.getComponent(CarMove) let self = this //this.node.off(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this) this.node.off(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this) this.node.off(cc.Node.EventType.TOUCH_CANCEL, this.onTouchCacel, this) //console.log("--->Off End") this.checkClickPos(evt.touch._point, 1) if (this.curGuideId == 1) { //if (point.x > this.offPos.x + addX - 200) { // console.log("false 3") // return result //} // ////if (pointY < this.offPos.y - addY + 120 * 4 + 60) { //航海 ////if (pointY < this.offPos.y - addY + 120 * 3 + 45) { //西游 ////console.log("---<>" + this.CarPark.y + " ofY:" + this.offPos.y + " TY:" + (this.offPos.y - addY + 120 * 3 + 45)); ////if (pointY < this.CarPark.y - addY + 138 * 2 + 30) { //西游 //if (pointY < this.CarPark.y - addY + 138 * 2 + 80) { //西游 // console.log("false 4") // return result //} let localPosX = evt.touch._point.x - this.sW * 0.5 let localPosY = evt.touch._point.y - this.sH * 0.5 if (MyExtends.PointIsOverRect(cc.v2(localPosX, localPosY), this.composeRectNode)) { cc.tween(GameM.selCarMove) .to(0.15, { position: cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY) }) .call(function () { ms.onHide() self.P1.getComponent(CarSpace).showImg() self.coolTime = false }) .start() this.ActiceTrashState(false); this.moveStartPos = null; this.hideCanCompose(); return; } } else if (this.curGuideId == 11) { GameM.selCarMove.setPosition(cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY)); ms.onHide(); self.P1.getComponent(CarSpace).showImg(); //self.coolTime = false; this.ActiceTrashState(false); //this.moveStartPos = null; this.hideCanCompose(); if (ms.sel && ms.type != 0 && ms.type < 10000) { } else { if (this.P1 == this.P2) { let s = this.P1.getComponent(CarSpace) //console.log("Click type:"+s.type); if (s.type <= 10000) { //点击角色 if (s.type != 0 && s.type < 10000) { s.ClickRole(); } } } } self.coolTime = false; this.moveStartPos = null; return; } if (ms.sel && ms.type != 0 && ms.type < 10000) { this.hideCanCompose() //回到原位置 if (!os.sel) { let localPosX = evt.touch._point.x - this.sW * 0.5 let localPosY = evt.touch._point.y - this.sH * 0.5 let tw = this.btnBuy.width * 0.5 let ty = this.btnBuy.height * 0.5 if (localPosX >= this.btnBuy.x - tw && localPosX <= this.btnBuy.x + tw && localPosY >= this.btnBuy.y - ty && localPosY <= this.btnBuy.y + ty && GameM.commonData.step > 3) { //回收 ms.onHide() self.P1.getComponent(CarSpace).changeType(0) GameM.commonData.updateBagCarData(ms.index.toString(), 0) //西游 if (GameM.commonData.isUseXiYouAddCoin) { self.removeRunRole(self.P1.getComponent(CarSpace)); } GameM.commonData.updateGold(GameM.commonData.carCfg[ms.type.toString()].price) this.scheduleOnce(() => { self.checkGiftByQucece() self.coolTime = false }, 0.1) this.ActiceTrashState(false); EffectNode.instance.PlayTrashAni(Number(GameM.commonData.carCfg[ms.type.toString()].price)); this.CheckNormalGuide(); } else { if (GameM.commonData.quality > Game_Quality.medium) { cc.tween(GameM.selCarMove) .to(0.15, { position: cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY) }) .call(function () { ms.onHide() self.P1.getComponent(CarSpace).showImg() self.coolTime = false }) .start() } else { GameM.selCarMove.setPosition(cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY)) ms.onHide() self.P1.getComponent(CarSpace).showImg() self.coolTime = false } this.ActiceTrashState(false); } } else { //合成 if (os.type != 0) { if (os.type >= 10000) { //回到原位置 if (GameM.commonData.quality > Game_Quality.medium) { cc.tween(GameM.selCarMove) .to(0.15, { position: cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY) }) .call(function () { ms.onHide() self.P1.getComponent(CarSpace).showImg() self.coolTime = false }) .start() } else { GameM.selCarMove.setPosition(cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY)) ms.onHide() self.P1.getComponent(CarSpace).showImg() self.coolTime = false } os.onHide() } else { if (ms.index != os.index) { if (ms.type == os.type) { self.scheduleOnce(function () { GameM.audioM.playEffect(AUDIO_TYPE.compose) self.composeAni.node.setPosition(cc.v2(self.P2.position.x, self.P2.position.y + 74 + this.moveEndY)) self.composeAni.node.active = true self.composeAni.setAnimation(0, 'animation', false) self.scheduleOnce(() => { self.composeAni.node.active = false }, 1.5) }, 0.13) GameM.selCarMove.setPosition(cc.v2(this.P2.position.x - 120, this.P2.position.y + 74 + this.moveEndY)) GameM.selCarMove.angle = 0 GameM.otherCarMove.setPosition(cc.v2(this.P2.position.x + 120, this.P2.position.y + 74 + this.moveEndY)) GameM.otherCarMove.angle = 0 cc.tween(GameM.selCarMove) .to(0.05, { position: cc.v2(this.P2.position.x - 150, this.P2.position.y + 74 + this.moveEndY), angle: 30 }) .to(0.15, { position: cc.v2(this.P2.position.x, this.P2.position.y + 74 + this.moveEndY), angle: 0 }) .call(function () { ms.onHide() let p1CarSpace = self.P1.getComponent(CarSpace) p1CarSpace.changeType(0) //self.P1.getComponent(CarSpace).changeType(0) //西游 if (GameM.commonData.isUseXiYouAddCoin) { self.removeRunRole(p1CarSpace); //p1CarSpace.RemoveCoinSpawn(); } self.checkGiftByQucece() }) .start() cc.tween(GameM.otherCarMove) .to(0.05, { position: cc.v2(this.P2.position.x + 150, this.P2.position.y + 74 + this.moveEndY), angle: -30 }) .to(0.15, { position: cc.v2(this.P2.position.x, this.P2.position.y + 74 + this.moveEndY), angle: 0 }) .call(function () { os.onHide() let p2CarSpace = self.P2.getComponent(CarSpace); p2CarSpace.changeType(Number(os.type) + 1) //self.P2.getComponent(CarSpace).changeType(Number(os.type) + 1) let last = Sciencen_M.instance.accMul(GameM.commonData.carCfg[(Number(ms.type)).toString()].exp, '2') let exp = Sciencen_M.instance.subtraction(GameM.commonData.carCfg[(Number(ms.type) + 1).toString()].exp, last) //西游 因为会重新AddCoinSpawn所以不用Remove //p1CarSpace.RemoveCoinSpawn(); if (GameM.commonData.isUseXiYouAddCoin) { self.removeRunRole(p2CarSpace); } GameM.commonData.updateBagCarData(ms.index.toString(), 0, 1, false) GameM.commonData.updateBagCarData(os.index.toString(), Number(os.type) + 1) //西游 if (GameM.commonData.isUseXiYouAddCoin) { self.addRunRole(Number(os.type) + 1, p2CarSpace); p2CarSpace.role.ComposeRole(); //p2CarSpace.AddCoinSpawn(); } UiM.Instance.panelFuns.push(() => GameM.commonData.updateRoleDataExp(exp)); UiM.Instance.panelFuns.push(() => GameM.commonData.updateMaxCarLevel(Number(os.type) + 1)); //最先执行 后进先出 //西游 //弃用 继续使用 maxCarLevel 更新合成的最高等级 //GameM.commonData.UpdateComposeMaxRoleLv(Number(os.type) + 1); UiM.Instance.displayPanel(); self.coolTime = false // if (GameM.commonData.step == 3) { // UiM.Instance.guideNode.getComponent(Guide).setStep() // } self.CheckNormalGuide(); }) .start() //西游 切换背景 //this.UpdateMainBg(); //this.ChangeBgSelf(); if (GameM.commonData.composeCarTimes == 0) { AdM.onSendEvent('compose_1', '合成第1只武将', 'compose') } GameM.commonData.updateComposeCarTimes() AdM.onSendEvent(`operate${Number(os.type) + 1}`, `合成${Number(os.type) + 1}级的武将`) this.ActiceTrashState(false); //EffectNode.instance.PlayExpEffect(cc.v2(this.P2.position.x, this.P2.position.y + 60 + this.moveEndY)); } //交换位置 else { let cs1 = self.P1.getComponent(CarSpace) let cs2 = self.P2.getComponent(CarSpace) let tempCs1role: any = cs1.role let tempCs2Role: any = cs2.role if (GameM.commonData.quality > Game_Quality.medium) { cc.tween(GameM.selCarMove) .to(0.15, { position: cc.v2(this.P2.position.x, this.P2.position.y + 60 + this.moveEndY) }) .call(function () { ms.onHide() cs2.changeType(ms.type) cs2.role = tempCs1role cs2.role.UpdateRoleSpace(cs2) }) .start() GameM.otherCarMove.y += 130 cc.tween(GameM.otherCarMove) .to(0.15, { position: cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY) }) .call(function () { os.onHide() cs1.changeType(os.type) cs1.role = tempCs2Role cs1.role.UpdateRoleSpace(cs1) GameM.commonData.updateBagCarData(os.index.toString(), ms.type, 1, false) GameM.commonData.updateBagCarData(ms.index.toString(), os.type) self.coolTime = false //console.log("---Set False quality") self.CheckNormalGuide(); }) .start() } else { GameM.selCarMove.setPosition(cc.v2(this.P2.position.x, this.P2.position.y + 60 + this.moveEndY)) ms.onHide() cs2.changeType(ms.type) cs2.role = tempCs1role cs2.role.UpdateRoleSpace(cs2) GameM.commonData.updateBagCarData(os.index.toString(), ms.type, 1, false) GameM.otherCarMove.setPosition(cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY)) os.onHide() cs1.changeType(os.type) cs1.role = tempCs2Role cs1.role.UpdateRoleSpace(cs1) GameM.commonData.updateBagCarData(ms.index.toString(), os.type) self.coolTime = false //console.log("---Set False no quality") this.CheckNormalGuide(); } this.ActiceTrashState(false); } } else { //回到原位置 if (GameM.commonData.quality > Game_Quality.medium) { cc.tween(GameM.selCarMove) .to(0.15, { position: cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY) }) .call(function () { ms.onHide() self.P1.getComponent(CarSpace).showImg() self.coolTime = false }) .start() } else { GameM.selCarMove.setPosition(cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY)) ms.onHide() self.P1.getComponent(CarSpace).showImg() self.coolTime = false } os.onHide() this.ActiceTrashState(false); } } } else { let cs1 = self.P1.getComponent(CarSpace) let cs2 = self.P2.getComponent(CarSpace) let tempCs1role: any = cs1.role if (GameM.commonData.quality > Game_Quality.medium) { cc.tween(GameM.selCarMove) .to(0.15, { position: cc.v2(this.P2.position.x, this.P2.position.y + 60 + this.moveEndY) }) .call(function () { ms.onHide() os.onHide() cs2.changeType(ms.type) cs1.changeType(0) tempCs1role.RemoveOldStrike() cs2.role = tempCs1role cs2.role.UpdateRoleSpace(cs2) cs1.ClearRole(); //cs1.role GameM.commonData.updateBagCarData(os.index.toString(), ms.type, 1, false) GameM.commonData.updateBagCarData(ms.index.toString(), 0) self.coolTime = false self.CheckNormalGuide(); }) .start() } else { GameM.selCarMove.setPosition(cc.v2(this.P2.position.x, this.P2.position.y + 60 + this.moveEndY)) ms.onHide() os.onHide() self.P2.getComponent(CarSpace).changeType(ms.type) self.P1.getComponent(CarSpace).changeType(0) GameM.commonData.updateBagCarData(os.index.toString(), ms.type, 1, false) GameM.commonData.updateBagCarData(ms.index.toString(), 0) self.coolTime = false } this.ActiceTrashState(false); this.CheckNormalGuide(); } } } else { if (this.P1 == this.P2) { let s = this.P1.getComponent(CarSpace) //console.log("Click type:"+s.type); if (s.type > 10000) { //打开礼包 if (s.type == MONEY_TYPE.box) { let type = Number(GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].box_car) this.P1.getComponent(CarSpace).openBox(type) //console.log("click box"); } else { if (s.type == MONEY_TYPE.redMoney) { UiM.Instance.redPackageNode.init(s.num, 1, 3, this.P1) UiM.Instance.openPanel(UiM.Instance.redPackageNode.node, false) //console.log("click redmoney"); } else { //console.log("click others"); //显示领取道具 UiM.Instance.checkDelayShow(() => { UiM.Instance.giftNode.active = true UiM.Instance.giftNode.x = 0 let gift = UiM.Instance.giftNode.getComponent(Gift) gift.init(s.type, String(s.num), this.P1, false, 0) }) } } this.CheckNormalGuide(); } else { //点击角色 if (s.type != 0 && s.type < 10000) { s.ClickRole(); } } } self.coolTime = false } //this.unschedule(this.CheckNormalGuide) //this.scheduleOnce(this.CheckNormalGuide, 0.2) //常规引导 this.unschedule(this.CheckNormalGuide) this.scheduleOnce(() => { //console.log("----------End") //this.CheckNormalGuide(); this.schedule(this.CheckNormalGuide, 5); }, 0.2) //西游 清空点击点坐标数据 防止误操作 this.moveStartPos = null //console.log("------>End"); } onTouchCacel(evt) { //西游 清空点击点坐标数据 this.moveStartPos = null let self = this let ms = GameM.selCarMove.getComponent(CarMove) if (ms.sel) { if (GameM.commonData.quality > Game_Quality.medium) { cc.tween(GameM.selCarMove) .to(0.15, { position: cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY) }) .call(function () { ms.onHide() self.P1.getComponent(CarSpace).showImg() }) .start() } else { GameM.selCarMove.setPosition(cc.v2(this.P1.position.x, this.P1.position.y + 60 + this.moveEndY)) ms.onHide() self.P1.getComponent(CarSpace).showImg() } //this.node.off(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this) this.node.off(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this) this.node.off(cc.Node.EventType.TOUCH_CANCEL, this.onTouchCacel, this) self.coolTime = false console.log("--->Off End cancel") } console.log("----------Cancel") if (GameM.commonData.maxCarLevel >= 10) { } else { this.CheckNormalGuide(); } } /** 开启判断给礼包定时器 */ startAddTimer() { LogUtil.logV("startAddTimer", "start") if (GameM.commonData.maxCarLevel >= GameM.commonData.dropGiftOpenLevel) { if (GameM.commonData.giftTimes < GameM.commonData.giftMaxTimes) { //let timespan = GameM.commonData.giftCfg.timespan + Math.min(50, GameM.commonData.giftTimes * 5) //test let timespan = GameM.commonData.giftCfg.timespan + Math.min(50, GameM.commonData.giftTimes * 5) this.scheduleOnce(() => { GameM.commonData.updateGiftCacheNum(1) this.addGiftBag() this.startAddTimer() }, timespan) } } } /** 有空位检查添加礼包 */ checkGiftByQucece() { LogUtil.logV("checkGiftByQucece", "") if (GameM.commonData.maxCarLevel < GameM.commonData.dropGiftOpenLevel) { return; } if (GameM.commonData.boxCacheNum > 0) { this.addBoxBag() } else if (GameM.commonData.giftCacheNum > 0) { this.addGiftBag() } } delayAddGift() { if (GameM.commonData.maxCarLevel < GameM.commonData.dropGiftOpenLevel) { return; } if (GameM.commonData.giftCacheNum > 0 || GameM.commonData.boxCacheNum > 0) { this.schedule(this.addGifts, 1, GameM.commonData.giftCacheNum) } } addGifts() { if (GameM.commonData.boxCacheNum <= 0 && GameM.commonData.giftCacheNum <= 0) { this.unschedule(this.addGifts) } else { this.checkGiftByQucece() } } /** 立即获得box礼包 */ addBoxGiftNow() { let pos = this.getEmptySpace() if (pos != '') { GameM.audioM.playEffect(AUDIO_TYPE.giftFall) let num = 1 GameM.commonData.updateBagCarData(pos, MONEY_TYPE.box, num) let space = this.CarPark.getChildByName(pos) let s = space.getComponent(CarSpace) s.type = MONEY_TYPE.box s.init(true, num) } else { this.CheckNormalGuide() GameM.commonData.updateBoxCacheNum(1) } } /** 添加礼包 * @param type 礼包类型 * 10001:金币 * 10002:红包币 * 10003:时间段收益(当前的每秒收益*时间段) * 10004:惊喜礼包(打开后获得对应等级的轮船) */ addGiftBag() { LogUtil.logV("addGiftBag", "") //只在此处可能出现元宝币 let data = GameM.commonData.giftRandomAdd() let pos = this.getEmptySpace() //console.log("Empty:" + pos) if (pos != '') { GameM.audioM.playEffect(AUDIO_TYPE.giftFall) let num = 0 if (data[0] == MONEY_TYPE.gold.toString()) { num = Number(GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].box_gold) } else { num = Number(data[1]) } if (data[0] == MONEY_TYPE.redMoney.toString()) { this.redMoneyInGiftBag(pos, MONEY_TYPE.redMoney) } else { GameM.commonData.updateBagCarData(pos, Number(data[0]), num) this.scheduleOnce(() => { let space = this.CarPark.getChildByName(pos) let s = space.getComponent(CarSpace) s.type = Number(data[0]) s.init(true, num) GameM.commonData.updateGiftCacheNum(-1) }, 0.05) } } else { this.CheckNormalGuide() } } redMoneyInGiftBag(pos, type) { HttpM.Instance.SendData(HTTP_TYPE.adShowConfig, {}, (res) => { LogUtil.logV("redMoneyInGiftBag:", res) if (res && res.data) { let num = 0 let average_ecpm = res.data.average_ecpm if (average_ecpm == 0) { num = GameM.commonData.giftBagRedMoney[0][2] } else { for (let entry of GameM.commonData.giftBagRedMoney) { if (average_ecpm > entry[0] && average_ecpm <= entry[1]) { num = entry[2] break } } if (num == 0) { num = GameM.commonData.giftBagRedMoney[0][2] } } GameM.commonData.updateBagCarData(pos, type, num) this.scheduleOnce(() => { let space = this.CarPark.getChildByName(pos) let s = space.getComponent(CarSpace) s.type = Number(type) s.init(true, num) GameM.commonData.updateGiftCacheNum(-1) }, 0.05) } //console.log("-->uplevel talent:", res); }) } /** 只添加box * @param type * 10004:惊喜礼包(打开后获得对应等级的轮船) */ addBoxBag() { let pos = this.getEmptySpace() if (pos != '') { GameM.audioM.playEffect(AUDIO_TYPE.giftFall) let num = 1 let type = 10004 GameM.commonData.updateBagCarData(pos, type, num) this.scheduleOnce(() => { let space = this.CarPark.getChildByName(pos) let s = space.getComponent(CarSpace) s.type = type s.init(true, num) GameM.commonData.updateBoxCacheNum(-1) }, 0.1) } else { this.CheckNormalGuide() } } private lvupPos = '' private lvupLv = -1 private lvupPreLv = -1 /** 点击购买车辆 */ onBuyCar() { GameM.audioM.playEffect(AUDIO_TYPE.purchaseCar) let pos = this.getEmptySpace() if (pos != '') { let price = GameM.commonData.getPriceByType(this.curBuyType) //白龙马天赋3 price = Sciencen_M.instance.subtraction(price, Sciencen_M.instance.accMul(price, (MateData.Ins.Mate3Talent3 * 0.01).toString())); if (GameM.commonData.updateGoldMinus(price)) { if (GameM.commonData.maxCarLevel > 14) { let result = GameM.commonData.checkShowLvUp() if (result > 0) { if (GameM.commonData.buyTimeTotal - GameM.commonData.lastVideoUpCarBuyTimes >= 10) { GameM.commonData.updatelastVideoUpCarBuyTimes() UiM.Instance.checkDelayShow(() => { UiM.Instance.giftNode.active = true this.lvupPos = pos this.lvupLv = result this.lvupPreLv = this.curBuyType let gift = UiM.Instance.giftNode.getComponent(Gift) gift.init(MONEY_TYPE.carLvUp, String(result), this.curBuyType, false, 0, VIDEO_TYPE.carLvUp) }) } } } if (this.buyHand.active) { this.buyHand.active = false } this.addAParkCar(pos, this.curBuyType) GameM.commonData.updateBuyTimeData(this.curBuyType) GameM.commonData.updateBuyTimeTotal() this.CheckNormalGuide() //西游测试 this.txt_buyBtn.string = "购买按钮(购买次数):" + GameM.commonData.buyTimeTotal; if (GameM.commonData.maxCarLevel >= GameM.commonData.dailyCashOpenLevel && GameM.commonData.roleData.dailyCashAniPlayed == 1) { // this.dailyCash = DailyCashData.Instance.getTodayDailyCash() if (DailyCashData.Instance.userDailyCashInfo) { this.dailyCash = DailyCashData.Instance.userDailyCashInfo if (GameM.commonData.roleData.dailyPro < this.dailyCash.buyTime) { let addGold = PoolMgr.Inst.getPoolPrefab(NODEPOOLPREFABTYPE.DailyCashProAdd); addGold.getComponent(DailyCashProAdd).init("进度+1"); // addGold.x = 50; this.dailyCashBtn.node.addChild(addGold); GameM.commonData.updateDailyCash(0, 1, true) this.tixianFill.fillRange = GameM.commonData.roleData.dailyPro / this.dailyCash.buyTime this.labTixianPro.string = `提现进度:${GameM.commonData.roleData.dailyPro}/${this.dailyCash.buyTime}` // let str = `当前提现进度: ${GameM.commonData.roleData.dailyPro}/${this.dailyCash.buyTime}` // let labPre = PoolMgr.Inst.getPoolPrefab(NODEPOOLPREFABTYPE.BuyProAdd); // labPre.getComponent(BuyProAdd).init(str) // this.posBtnBuy.addChild(labPre) this.labTixianPro.node.active = true this.labWuFuNode.active = false //飞红包 EffectNode.instance.PlayCoinAnim(14, 5, cc.v2(this.btnBuy.position.x, this.btnBuy.position.y), true, cc.v2(this.dailyCashBtn.node.position.x, this.dailyCashBtn.node.position.y + this.centerPart.y)) GameM.audioM.playEffect(AUDIO_TYPE.getGold) cc.tween(this.dailyCashBtn.node) .delay(1) .to(0.2, { scale: 1.2 }) .to(0.2, { scale: 1 }) .start() if (GameM.commonData.roleData.dailyPro == this.dailyCash.buyTime && GameM.commonData.roleData.canDailyCash != 0) { AdM.onSendEvent('nextcash_finish', '明日提现任务完成', 'nextcash') } if (this.dailyBtn != null) { if (GameM.commonData.roleData.dailyPro >= this.dailyCash.buyTime) { GuideMng.Ins.CheckFiveluck2Guide12() } } // EffectNode.instance.PlayExpEffect(cc.v2(this.posBtnBuy.x, this.posBtnBuy.y), 2); } } } let exp = GameM.commonData.carCfg[this.curBuyType.toString()].exp GameM.commonData.updateRoleDataExp(exp) GameM.httpM.sendDatas(HTTP_TYPE.updateGold, { 'gold': GameM.commonData.gold }) this.carBuyInfo() //财神降临 WealthData.Ins.CheckTrigger(); AdM.onSendEvent(`buy_${GameM.commonData.buyTimeTotal}`, `第${GameM.commonData.buyTimeTotal}次买车`, 'buy') } else { if (GameM.commonData.dayBuyCarVideoLimitTimes <= 0) { EffectNode.instance.PlayTip('今日金币获取次数已用尽') this.hideAllHand() this.CheckNormalGuide() //弹出金币获取方式界面 UiM.Instance.onPanel(PANEL_NAME.CoinTipNode) } else { if (GameM.commonData.checkShowMainPop()) { let gift = UiM.Instance.giftNode.getComponent(Gift) let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold; //唐僧天赋3 videoPrice = Sciencen_M.instance.addition(videoPrice, Sciencen_M.instance.accMul(videoPrice, (MateData.Ins.Mate1Talent3 * 0.01).toString())); let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.clickVideoTimes * 0.25 - 10)) videoPrice = Sciencen_M.instance.accMul(videoPrice, percent.toString()) percent = Math.floor(percent * 100) gift.init(MONEY_TYPE.mainBuyCarGold, videoPrice, null, false, 0, VIDEO_TYPE.buyCarMainBtn, percent) UiM.Instance.giftNode.x = 0 UiM.Instance.giftNode.active = true } else { let gift = UiM.Instance.giftNode.getComponent(Gift) let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold; let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.clickVideoTimes * 0.25 - 10)) videoPrice = Sciencen_M.instance.accMul(videoPrice, percent.toString()) //唐僧天赋3 videoPrice = Sciencen_M.instance.addition(videoPrice, Sciencen_M.instance.accMul(videoPrice, (MateData.Ins.Mate1Talent3 * 0.01).toString())); percent = Math.floor(percent * 100) gift.init(MONEY_TYPE.gold, videoPrice, null, false, 0, VIDEO_TYPE.buyCarMainBtn, percent) UiM.Instance.giftNode.x = 1000 UiM.Instance.giftNode.active = true GameM.adM.watchVideo(VIDEO_TYPE.buyCarMainBtn); } } } //判断是否可以购买车辆 this.updateBuyBtnState(); } else { EffectNode.instance.PlayTip("位置已满"); this.CheckNormalGuide() } } resetFillRange() { this.tixianFill.fillRange = 0 } getDailyCar(carlv) { let pos = this.getEmptySpace() if (pos != '') { this.addAParkCar(pos, carlv) GameM.commonData.updateMaxCarLevel(carlv, true) // let exp = GameM.commonData.carCfg[carlv.toString()].exp // GameM.commonData.updateRoleDataExp(exp) UiM.Instance.dailyNode.getComponent(Daily).hasOpen() EffectNode.instance.PlayTip("武将已发放到位置"); } else { EffectNode.instance.PlayTip("位置已满,请空出位置再领"); } } getTaskAwardCar(carlv) { let pos = this.getEmptySpace() if (pos != '') { this.addAParkCar(pos, carlv) GameM.commonData.updateMaxCarLevel(carlv, true) EffectNode.instance.PlayTip(`${carlv}级武将已发放`); } else { EffectNode.instance.PlayTip("位置已满,请空出位置再领"); } } /** 看视频升级车成功 */ carLvUpVideoEnd() { UiM.Instance.giftNode.active = false EffectNode.instance.PlayTip("升级成功!"); GameM.commonData.updateBagCarData(this.lvupPos, this.lvupLv) let space = this.CarPark.getChildByName(this.lvupPos) let s = space.getComponent(CarSpace) s.type = this.lvupLv s.init() let expPre = GameM.commonData.carCfg[this.lvupPreLv.toString()].exp let exp = GameM.commonData.carCfg[this.lvupLv.toString()].exp GameM.commonData.updateRoleDataExp(Sciencen_M.instance.subtraction(exp, expPre)) //西游 if (GameM.commonData.isUseXiYouAddCoin) { this.addRunRole(this.lvupLv, s); //s.AddCoinSpawn(); } this.hideHandGuide() this.CheckNormalGuide() if (UiM.Instance.shopNode) { UiM.Instance.shopNode.getComponent(Shop).refreshPrice(this.shopBuyCarType) this.shopBuyCarType = 0 } } /** * 判断是否有足够金币买车 * 显示按钮状态 */ updateBuyBtnState() { //判断是否可以购买车辆 let nextPrice = GameM.commonData.getPriceByType(this.curBuyType); if (Sciencen_M.instance.ContrastNumber(GameM.commonData.gold, nextPrice)) { //显示购买按钮 this.btnBuy.getComponent(CarInfo).ShowBuyBtn(); } else { //显示广告按钮 this.btnBuy.getComponent(CarInfo).ShowAdBtn(); } } /**显示或隐藏立即回收按钮*/ ActiceTrashState(active: boolean) { if (GameM.commonData.step <= 3) { return } if (GameM.selCarMove.getComponent(CarMove).type < 10000 && GameM.selCarMove.getComponent(CarMove).type != 0) this.btnBuy.getComponent(CarInfo).ActiveTrasnBtn(active, GameM.commonData.carCfg[GameM.selCarMove.getComponent(CarMove).type.toString()].price); } private shopBuyCarType = 0 /** 购买指定车辆 * @param type 指定类型车 * @param buyMoney 0 金币 1 视频 2 红包币 */ onBuyTypeCar(type, buyMoney = 0) { GameM.audioM.playEffect(AUDIO_TYPE.purchaseCar) let pos = this.getEmptySpace() if (pos != '') { if (buyMoney == 0) { let price = GameM.commonData.getPriceByType(type) if (GameM.commonData.updateGoldMinus(price)) { this.addAParkCar(pos, type) GameM.commonData.roleData.shopTotal++ // AdM.onSendEvent(`shop_buy_car_${GameM.commonData.roleData.shopTotal}`, `商城买怪${GameM.commonData.roleData.shopTotal}次成功`, 'shop_buy_car') let exp = GameM.commonData.carCfg[type.toString()].exp GameM.commonData.updateRoleDataExp(exp) GameM.commonData.updateBuyTimeData(type, true) GameM.httpM.sendDatas(HTTP_TYPE.updateGold, { 'gold': GameM.commonData.gold }) //购买次数修改 let times = LocalManagerData.Instance.getBuyCarData(type) times++ LocalManagerData.Instance.saveBuyCarData(type, times) UiM.Instance.shopNode.getComponent(Shop).refreshPrice(type) EffectNode.instance.PlayTip("购买成功"); //判断是否可以购买车辆 this.updateBuyBtnState(); } else { // EffectNode.instance.PlayTip("金币不足,购买失败"); if (GameM.commonData.isVideoTest) { if (GameM.commonData.dayBuyCarVideoLimitTimes <= 0) { EffectNode.instance.PlayTip('金币不足,并且今日金币获取次数已用尽') this.hideAllHand() this.CheckNormalGuide() } else { this.shopBuyCarType = type UiM.Instance.checkDelayShow(() => { let gift = UiM.Instance.giftNode.getComponent(Gift) let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold; let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.clickVideoTimes * 0.25 - 10)) videoPrice = Sciencen_M.instance.accMul(videoPrice, percent.toString()) //唐僧天赋3 videoPrice = Sciencen_M.instance.addition(videoPrice, Sciencen_M.instance.accMul(videoPrice, (MateData.Ins.Mate1Talent3 * 0.01).toString())); percent = Math.floor(percent * 100) gift.init(MONEY_TYPE.buyCarGold, videoPrice, null, false, 0, VIDEO_TYPE.shopBuyCarBtn, percent) UiM.Instance.giftNode.x = 0 UiM.Instance.giftNode.active = true }) } } else { if (GameM.commonData.dayBuyCarVideoLimitTimes <= 0) { EffectNode.instance.PlayTip('今日金币获取次数已用尽') this.hideAllHand() this.CheckNormalGuide() } else { this.shopBuyCarType = type UiM.Instance.checkDelayShow(() => { let gift = UiM.Instance.giftNode.getComponent(Gift) let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold; let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.clickVideoTimes * 0.25 - 10)) videoPrice = Sciencen_M.instance.accMul(videoPrice, percent.toString()) //唐僧天赋3 videoPrice = Sciencen_M.instance.addition(videoPrice, Sciencen_M.instance.accMul(videoPrice, (MateData.Ins.Mate1Talent3 * 0.01).toString())); percent = Math.floor(percent * 100) gift.init(MONEY_TYPE.buyCarGold, videoPrice, null, false, 0, VIDEO_TYPE.shopBuyCarBtn, percent) UiM.Instance.giftNode.x = 0 UiM.Instance.giftNode.active = true }) } } } } else if (buyMoney == 1) { //调取看视频接口 this.tempPos = pos this.tempType = type GameM.adM.watchVideo(VIDEO_TYPE.buyCar) } else if (buyMoney == 2) { let price = GameM.commonData.getMoneyPriceBuyType(type) if (GameM.commonData.updateRedMoney(-price, RecordTYPE.buyNewCar)) { this.addAParkCar(pos, type) GameM.commonData.roleData.shopTotal++ // AdM.onSendEvent(`shop_buy_car_${GameM.commonData.roleData.shopTotal}`, `商城买怪${GameM.commonData.roleData.shopTotal}次成功`, 'shop_buy_car') let exp = GameM.commonData.carCfg[type.toString()].exp GameM.commonData.updateRoleDataExp(exp) GameM.commonData.updateBuyTimeData(type, true) UiM.Instance.shopNode.getComponent(Shop).refreshPrice(type) EffectNode.instance.PlayTip("购买成功"); } else { EffectNode.instance.PlayTip("红包币不足,购买失败"); } } } else { EffectNode.instance.PlayTip("位置已满"); this.CheckNormalGuide() } } /**购买按钮视频广告回调*/ onBuyCarAdEnd() { if (GameM.commonData.checkShowMainPop()) { this.onGetGold() } else { UiM.Instance.giftNode.active = true UiM.Instance.giftNode.x = 0 AdM.showNative(0) } GameM.commonData.updateClickVideoTimes() GameM.commonData.addDailyFinishTimesDataByType(7) this.updateBuyBtnState(); } onShopBuyCarAdEnd() { this.onGetGold() } onGetGold() { let key = 'dddddddddddddddddddddddddddddddd' GameM.commonData.dayBuyCarVideoLimitTimes-- let d = Utils.Encrypt(GameM.commonData.dayBuyCarVideoLimitTimes, key, GameM.commonData.appid) GameM.globalStorage.setStorage(STORAGE_KEY.dayBuyCarVideoLimitTimes, d, 1) UiM.Instance.giftNode.active = false EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放"); let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold; let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.clickVideoTimes * 0.25 - 10)) videoPrice = Sciencen_M.instance.accMul(videoPrice, percent.toString()) //唐僧天赋3 videoPrice = Sciencen_M.instance.addition(videoPrice, Sciencen_M.instance.accMul(videoPrice, (MateData.Ins.Mate1Talent3 * 0.01).toString())); GameM.commonData.updateGold(videoPrice) GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)); } onBuyCarAdFail() { // UiM.Instance.giftNode.active = false // UiM.Instance.giftNode.x = 0 // AdM.destroyNative() } private tempType = 0 private tempPos = '' onVideoBuyCarEnd() { this.addAParkCar(this.tempPos, this.tempType) GameM.commonData.roleData.shopTotal++ // AdM.onSendEvent(`shop_buy_car_${GameM.commonData.roleData.shopTotal}`, `商城买怪${GameM.commonData.roleData.shopTotal}次成功`, 'shop_buy_car') let exp = GameM.commonData.carCfg[this.tempType.toString()].exp GameM.commonData.updateRoleDataExp(exp) GameM.commonData.updateBuyTimeData(this.tempType, true) UiM.Instance.shopNode.getComponent(Shop).refreshPrice(this.tempType) GameM.commonData.addDailyFinishTimesDataByType(7) EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放"); } /** 设置购买车信息 */ carBuyInfo() { //console.log("---->BuyTimes:" + GameM.commonData.buyTimeTotal); let info = this.btnBuy.getComponent(CarInfo) let times = GameM.commonData.buyTimeTotal + 1 this.curBuyType = Number(GameM.commonData.buyNumCfg[times.toString()].car_level) //TEST if (GameM.commonData.IsTest) this.curBuyType = GameM.commonData.maxCarLevel <= 0 ? 1 : GameM.commonData.maxCarLevel; info.changeType(this.curBuyType) } /** 点击打开商店 */ clickOpenShop() { AdM.onSendEvent('button_11', '妖洞icon', 'button') GameM.audioM.playEffect(AUDIO_TYPE.button); UiM.Instance.onPanel(PANEL_NAME.ShopNode) } /** 点击打开设置 */ clickHead() { AdM.onSendEvent('button_14', '头像icon', 'button') GameM.audioM.playEffect(AUDIO_TYPE.button) UiM.Instance.onPanel(PANEL_NAME.SettingNode) } /** 打开转盘 */ clickTurntable() { AdM.onSendEvent('button_10', '转盘icon', 'button') GameM.audioM.playEffect(AUDIO_TYPE.button); if (GameM.commonData.maxCarLevel < GameM.commonData.turntableOpenLevel) { EffectNode.instance.PlayTip(`首次合成${GameM.commonData.turntableOpenLevel}级武将解锁`) return } UiM.Instance.onPanel(PANEL_NAME.TurnTableNode) } /** 打开任务 */ clickTask() { AdM.onSendEvent('button_7', '日常icon', 'button') GameM.audioM.playEffect(AUDIO_TYPE.button); if (GameM.commonData.maxCarLevel < GameM.commonData.taskOpenLevel) { EffectNode.instance.PlayTip(`首次合成${GameM.commonData.taskOpenLevel}级武将解锁`) return } UiM.Instance.taskNode.active = true; } /** 打开提现 */ clickCash() { AdM.onSendEvent('button_15', '提现icon', 'button') GameM.audioM.playEffect(AUDIO_TYPE.button) if (!GameM.commonData.redSwitch) { EffectNode.instance.PlayTip('敬请期待') return } if (GameM.commonData.maxCarLevel < GameM.commonData.cashOpenLevel) { EffectNode.instance.PlayTip(`首次合成${GameM.commonData.cashOpenLevel}级武将可查看`) return } UiM.Instance.onPanel(PANEL_NAME.CashNode, true) } /** 打开投资 */ clickInvest() { AdM.onSendEvent('button_12', '探索icon', 'button') GameM.audioM.playEffect(AUDIO_TYPE.button); // //test // UiM.Instance.onPanel(PANEL_NAME.InvestNode) // return //if (MateData.Ins.mateUnlockAry[3] == 0) { if (GameM.commonData.maxCarLevel < GameM.commonData.investOpenLevel) { EffectNode.instance.PlayTip(`首次合成${GameM.commonData.investOpenLevel}级武将解锁`) return } UiM.Instance.onPanel(PANEL_NAME.InvestNode) if (GameM.commonData.roleData.investGuide == 0) { GameM.commonData.roleData.investGuide = 1 GameM.commonData.updateRoleData() this.hideAllHand() // UiM.Instance.guideNode.getComponent(Guide).showInvestStep2() } } /** 打开保险箱 */ clickSafeBox() { GameM.audioM.playEffect(AUDIO_TYPE.button); AdM.onSendEvent("button_8", "钱庄icon", 'button') // if (MateData.Ins.mateUnlockAry[4] == 0) { // EffectNode.instance.PlayTip('收服23级沙僧解锁') // return // } if (GameM.commonData.maxCarLevel < GameM.commonData.richBankUnLockLevel) { EffectNode.instance.PlayTip(`首次合成${GameM.commonData.richBankUnLockLevel}级武将解锁`) return } UiM.Instance.onPanel(PANEL_NAME.SafeDepositBox) if (GameM.commonData.roleData.investGuide == 0) { GameM.commonData.roleData.investGuide = 1 GameM.commonData.updateRoleData() this.hideAllHand() } } /** 每日豪礼 */ clickChat() { AdM.onSendEvent('button_6', '登录奖励icon', 'button') GameM.audioM.playEffect(AUDIO_TYPE.button) if (GameM.commonData.maxCarLevel < GameM.commonData.loginRewardOpenLevel) { EffectNode.instance.PlayTip(`首次合成${GameM.commonData.loginRewardOpenLevel}级武将解锁`) return } UiM.Instance.onPanel(PANEL_NAME.DailyNode) } /**俱乐部 */ clickClubShare() { AdM.onSendEvent('button_1', '师徒icon', 'button') if (GameM.commonData.maxCarLevel < GameM.commonData.clubOpenLevel) { GameM.audioM.playEffect(AUDIO_TYPE.button) EffectNode.instance.PlayTip(`首次合成${GameM.commonData.clubOpenLevel}级武将解锁`) return } if (GameM.commonData.isAuth) { LogUtil.logV("ClubMain", "clickShare") UiM.Instance.onPanel(PANEL_NAME.clubMainNode) } else { AdM.WxLogin(); } } /**分享 */ clickShare() { // AdM.onSendEvent('shareClick', '分享icon点击') if (GameM.commonData.isAuth) { AdM.sharePic(); } else { AdM.WxLogin(); } } clickAirship() { AdM.onSendEvent('button_16', '空投icon', 'button') GameM.audioM.playEffect(AUDIO_TYPE.Airship) if (this.airshipUp) { return } this.airshipAni.pause() UiM.Instance.checkDelayShow(() => { let data = this.curAirCfg UiM.Instance.giftNode.active = true let gift = UiM.Instance.giftNode.getComponent(Gift) let num = String(data.num) if (data.reward == MONEY_TYPE.gold) { let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold; num = Sciencen_M.instance.accMul(videoPrice, num) } gift.init(data.reward, num, null, true, data.is_video) }) } /** 随机一个新的热气球奖励 */ ranNewAirShip() { this.getAirByRan() let data = this.curAirCfg UiM.Instance.giftNode.active = true let gift = UiM.Instance.giftNode.getComponent(Gift) let num = String(data.num) if (data.reward == MONEY_TYPE.gold) { let videoPrice = GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].gold; num = Sciencen_M.instance.accMul(videoPrice, num) } gift.init(data.reward, num, null, true, data.is_video) } /** 恢复飞艇飞行 */ resumeAirShip() { if (this.airshipUp) { return } this.airshipAni.resume() } /** 放弃飞艇 */ dropAirShip() { this.airshipAni.stop() this.airshipUp = true EffectNode.instance.PlayTip('我会回来的!') cc.tween(this.airshipAni.node) .to(0.2, { scale: 0.6 }) .to(0.3, { scale: 1.2 }) .to(0.2, { scale: 1 }) .by(1, { x: -1000 }, cc.easeIn(3.0)) .call(() => { this.airshipUp = false this.checkShowAirship() }) .start() } /** 每日提现 */ clickTixian() { GameM.audioM.playEffect(AUDIO_TYPE.button) AdM.onSendEvent('button_4', '天天红包icon', 'button') if (GameM.commonData.maxCarLevel < GameM.commonData.dailyCashOpenLevel) { EffectNode.instance.PlayTip(`首次合成${GameM.commonData.dailyCashOpenLevel}级武将解锁`) return } UiM.Instance.redPackageNode.init(0, 0, 4, null, false) UiM.Instance.redPackageNode.node.x = 0 UiM.Instance.redPackageNode.node.active = true //西游 GameM.audioM.setPauseMusic(); GameM.audioM.playMateEffect(AUDIO_TYPE.fiveluckbgm); } /** 检查提现进度 */ checkTixianPro(checkNew = false) { if (checkNew) { this.curCashCfg = null } if (!this.curCashCfg) { let cfg = CashOutData.Instance.cashCft let len = cfg.length for (var i = 0; i < len; i++) { if (CashOutData.Instance.getCashStatus(cfg[i].index) == 0) { this.curCashCfg = cfg[i] break } } } let money = this.curCashCfg.moneyshow.split('~')[1] this.labTixian.string = `${money}` //西游 this.labtargetCarLevel.string = GameM.commonData.fightRoleCfg[this.curCashCfg.type_value.toString()].name; this.labTixianLv.string = this.curCashCfg.type_value.toString() let pro = GameM.commonData.maxCarLevel / this.curCashCfg.type_value this.tixianPro.fillRange = pro this.tixianPercent.string = Math.floor(GameM.commonData.maxCarLevel / this.curCashCfg.type_value * 100) + "%" if (pro >= 1) { this.canGet.active = true } else { this.canGet.active = false } if (pro >= 0.8) { this.approachEff.active = true } else { this.approachEff.active = false } if (checkNew) { cc.loader.loadRes('carPic/side/side_' + this.curCashCfg.type_value.toString(), cc.SpriteFrame, (err, assets) => { if (err) { cc.error(err); return; } this.spTixianCar.spriteFrame = assets }) } } playCarProEff() { // cc.loader.loadRes('carPic/side/side_' + GameM.commonData.maxCarLevel, cc.SpriteFrame, (err, assets) => { // if (err) { // cc.error(err); // return; // } // this.carProSp.spriteFrame = assets // // this.carProSp.node.setPosition(cc.v2(0, 0)) // this.carProSp.node.setPosition(GameM.selCarMove.position) // this.carProSp.node.scale = 0.4 // this.carProSp.node.active = true // cc.tween(this.carProSp.node).to(0.7, { position: this.tixianProBtn.node.position, scale: 0.4 }) // .call(() => { // this.carProSp.node.active = false // let nodeAnim = UiM.Instance.hallNode.getComponent(Main).tixianProBtn.node.getComponent(EachNodeAnim) // nodeAnim.startChildAnim() // this.scheduleOnce(() => { // this.hallLabAddEff.play('upFadeC', 0) // }, 0.4) // // this.hallLabAddEff.play('upFadeC', 0) // this.checkTixianPro() // }) // .start() // }) //改为飞红包 EffectNode.instance.PlayCoinAnim(14, 10, cc.v2(GameM.selCarMove.position.x, GameM.selCarMove.position.y), true, cc.v2(this.tixianProBtn.node.position.x, this.tixianProBtn.node.position.y + this.topPart.y)) GameM.audioM.playEffect(AUDIO_TYPE.getGold) cc.tween(this.tixianProBtn.node) .delay(1) .to(0.2, { scale: 1.2 }) .to(0.2, { scale: 1 }) .start() this.checkTixianPro() } //-----现金夺宝功能---- private hasTap = false clickTreasure() { // //test // EffectNode.instance.playEggIn() // return GameM.audioM.playEffect(AUDIO_TYPE.button) if (GameM.commonData.maxCarLevel < GameM.commonData.trerasureOpenLevel) { EffectNode.instance.PlayTip(`首次合成${GameM.commonData.trerasureOpenLevel}级武将解锁`) return } AdM.onSendEvent('button_9', '现金icon', 'button') if (!GameM.commonData.isAuth) { if (!this.hasTap) { console.log('clickGoAuth') this.hasTap = true AdM.WxLogin() this.scheduleOnce(() => { this.hasTap = false }, 1) } } else { UiM.Instance.onPanel(PANEL_NAME.TreasureNode) } } clickMoreGame() { GameM.audioM.playEffect(AUDIO_TYPE.button) AdM.onSendEvent('button_3', '更多红包icon', 'button') UiM.Instance.onPanel(PANEL_NAME.moreGameNode) } setUnlockBtnColor() { if (GameM.commonData.maxCarLevel == GameM.commonData.dailyCashOpenLevel) { //每日提现 this.unLockBtn(this.dailyCashBtn, GameM.commonData.dailyCashOpenLevel) } else if (GameM.commonData.maxCarLevel == GameM.commonData.investOpenLevel) { //投资引导 this.unLockBtn(this.investBtn, GameM.commonData.cashOpenLevel) InvestData.Instance.getInvestInfo() // if (GameM.commonData.roleData.investGuide == 0) { // UiM.Instance.guideNode.getComponent(Guide).showInvestStep1() // } } else if (GameM.commonData.maxCarLevel == GameM.commonData.loginRewardOpenLevel) { //登录豪礼 this.unLockBtn(this.dailyBtn, GameM.commonData.loginRewardOpenLevel) } else if (GameM.commonData.maxCarLevel == GameM.commonData.taskOpenLevel) { //每日任务 this.unLockBtn(this.taskBtn, GameM.commonData.taskOpenLevel) } else if (GameM.commonData.maxCarLevel == GameM.commonData.trerasureOpenLevel) { //现金夺宝 this.unLockBtn(this.treasureBtn, GameM.commonData.trerasureOpenLevel) } else if (GameM.commonData.maxCarLevel == GameM.commonData.richBankUnLockLevel) { this.unLockBtn(this.bankBtn, GameM.commonData.richBankUnLockLevel) } } /** * 判断伙伴解锁按钮 */ checkMateLockBtn(mateData, unlockLv: number) { if (mateData == 3) { // this.unLockBtn(this.investBtn, 0, mateData) } else if (mateData == 4) { this.unLockBtn(this.bankBtn, 0, mateData) } } /** 设置按钮解锁显示状态 * @param btn 按钮 * @param unlockLv 解锁等级 */ unLockBtn(btn: cc.Button, unlockLv: number, mateData = -1) { let normal = btn.node.getChildByName('normal') let lock = btn.node.getChildByName('lock') if (mateData != -1) { if (MateData.Ins.mateUnlockAry[mateData] == 1) { normal.active = true lock.active = false } else { normal.active = false lock.active = true let labLock = lock.getChildByName('labLock') if (mateData == 3) { labLock.getComponent(cc.Label).string = `收服八戒` } else if (mateData == 4) { labLock.getComponent(cc.Label).string = `收服沙僧` } } return } if (GameM.commonData.maxCarLevel >= unlockLv) { normal.active = true lock.active = false } else { normal.active = false lock.active = true let labLock = lock.getChildByName('labLock') labLock.getComponent(cc.Label).string = `${unlockLv}级解锁` } } //西游 /**战斗按钮*/ Click_FightBtn() { AdM.onSendEvent('button_2', '降妖伏魔icon', 'button') GameM.audioM.playEffect(AUDIO_TYPE.button); FightData.Ins.EnterFight(); } /**伙伴按钮*/ Click_MateBtn() { AdM.onSendEvent('button_13', '伙伴icon', 'button') GameM.audioM.playEffect(AUDIO_TYPE.button); UIMng.Ins.AsyncGetPanel(PanelType.MatePanel, (panel) => { panel.OnEnter(); }); //UIMng.Ins.GetPanel(PanelType.MatePanel).OnEnter(); } /**财神按钮*/ Click_WealthBtn() { //console.log("-------------Max" + GameM.commonData.maxCarLevel + " unlock:" + GameM.commonData.unlockWealthLevel); //RichManData.Ins.GetData(); AdM.onSendEvent(`button_17`, `财神icon点击`, 'button'); GameM.audioM.playEffect(AUDIO_TYPE.button) if (!WealthData.Ins.isUnlock) { EffectNode.instance.PlayTip(`首次合成${GameM.commonData.unlockWealthLevel}级武将解锁`) return } //if (GameM.commonData.maxCarLevel < GameM.commonData.unlockWealthLevel) { // EffectNode.instance.PlayTip(`首次合成${GameM.commonData.unlockWealthLevel}级武将解锁`) // return //} WealthData.Ins.Click_MainWealthBtn(); } Click_GetCoinBtn() { UiM.Instance.onPanel(PANEL_NAME.CoinTipNode); } Click_RichManBtn() { UIMng.Ins.AsyncGetPanel(PanelType.RichPanel, (panel) => { panel.OnEnter(); }); //UIMng.Ins.GetPanel(PanelType.RichPanel).OnEnter(); AdM.onSendEvent(`button_18`, `取经icon点击`, 'button'); } Click_AdRbBtn() { //UIMng.Ins.AsyncGetPanel(PanelType.AdRbPanel, (panel) => { // panel.OnEnter(); //}); //AdM.onSendEvent(`button_21`, `每日红包icon点击`, 'button'); //return; if (GameM.commonData.isAuth) { UIMng.Ins.AsyncGetPanel(PanelType.AdRbPanel, (panel) => { panel.OnEnter(); }); } else { AdM.WxLogin(); } AdM.onSendEvent(`button_21`, `每日红包icon点击`, 'button'); } /**更新天赋详情*/ UpdateTalentDetaile() { MateData.Ins.DisplayTalent(this.xiYou_talentParent, this.xiYouPfb_telentItem); } private mateBaJiePos: cc.Vec2 = null; /** * 显示伙伴 */ DisplayMate() { let num = MateData.Ins.GetUnlcokMateNum(); let posAry: cc.Vec2[]; let index = 0; if (MateData.Ins.mateUnlockAry[2] == 0) { //白龙马未解锁 } else { //白龙马已解锁 } if (num == 1 || num == 0) { posAry = MateData.Ins.matePosAry1; } else if (num == 2) { if (MateData.Ins.mateUnlockAry[2] == 1) posAry = MateData.Ins.matePosAry1; else posAry = MateData.Ins.matePosAry2; } else if (num == 3) { if (MateData.Ins.mateUnlockAry[2] == 1) posAry = MateData.Ins.matePosAry3; else posAry = MateData.Ins.matePosAry4; } else if (num == 4) { if (MateData.Ins.mateUnlockAry[2] == 1) posAry = MateData.Ins.matePosAry4; else posAry = MateData.Ins.matePosAry5; } else if (num == 5) { posAry = MateData.Ins.matePosAry5; } // console.log("---------------------> ", posAry); //if (MateData.Ins.mateUnlockAry[2] == 1) { // this.xiYou_mates[0].active = false; // this.xiYou_mates[2].active = true; // this.xiYou_mates[2].setPosition(posAry[index]); //} else { // this.xiYou_mates[0].active = true; // this.xiYou_mates[2].active = false; // this.xiYou_mates[0].setPosition(posAry[index]); //} //index++; for (let i = 0; i < 5; i++) { this.xiYou_mates[i].active = false; if (MateData.Ins.mateUnlockAry[i] == 1) { this.xiYou_mates[i].active = true; // console.log("---------------------> index:" + i + " index2:" + index + " PosX:" + posAry[index].x); //if (i == 3) // this.mateBaJiePos = posAry[index]; //this.xiYou_mates[i].setPosition(posAry[index]); //index++; } //if (i != 0 && i != 2) { // this.xiYou_mates[i].active = false; // if (MateData.Ins.mateUnlockAry[i] == 1) { // this.xiYou_mates[i].active = true; // // console.log("---------------------> index:" + i + " index2:" + index + " PosX:" + posAry[index].x); // if (i == 3) // this.mateBaJiePos = posAry[index]; // this.xiYou_mates[i].setPosition(posAry[index]); // index++; // } //} } } private isUpdateBg = true; private bgPos: cc.Vec2 = cc.v2(-375, 310); private bgBackPos: cc.Vec2 = cc.v2(-375, 310); private mateBaTimer: number = 0; private mateSunTimer: number = 0; private mateBaIndex = 0; private mateSunIndex = 0; private mateBaUpdate1: boolean = false; private mateBaPos: cc.Vec2 = cc.v2(-375, 310); private mateBaAniTime: number[] = [3, 8, 11]; private mateSunAniTime: number[] = [2, 3, 4, 6, 7]; /**移动背景*/ MoveBg(dt) { if (this.isUpdateBg) { //三国战戟 不再移动背景 return; this.bgPos.x -= dt * 100; if (this.bgPos.x <= -1333) { this.bgPos.x = -375; } this.bgBackPos.x -= dt * 50; if (this.bgBackPos.x <= -1333) { this.bgBackPos.x = -375; } this.xiYou_bgback.setPosition(this.bgBackPos); //console.log("POS:",this.bgPos); ////伙伴动画处理 //if (this.xiYou_mates[3].active) { // this.mateBaTimer += dt; // // // if (this.mateBaUpdate1) { // this.mateBaPos.x -= dt * 100; // this.xiYou_mates[3].setPosition(this.mateBaPos); // } // // if (this.mateBaTimer > this.mateBaAniTime[this.mateBaIndex]) { // if (this.mateBaIndex == 0) { // //this.xiYou_spineBa.clearTrack(0); // //this.xiYou_spineBa.setBonesToSetupPose(); // this.xiYou_spineBa.setAnimation(0, "fall", false); // this.mateBaIndex++; // this.scheduleOnce(() => { // this.mateBaPos = this.xiYou_mates[3].getPosition(); // this.mateBaUpdate1 = true; // }, 0.5) // } else if (this.mateBaIndex == 1) { // this.mateBaUpdate1 = false; // //this.xiYou_spineBa.clearTrack(0); // //this.xiYou_spineBa.setBonesToSetupPose(); // this.xiYou_spineBa.setAnimation(0, "run", true); // // cc.tween(this.xiYou_mates[3]) // .to(1, { position: this.mateBaJiePos }) // .call(() => { // //this.xiYou_spineBa.clearTrack(0); // //this.xiYou_spineBa.setBonesToSetupPose(); // this.xiYou_spineBa.setAnimation(0, "walk", true); // }) // .start(); // this.mateBaIndex++; // } else if (this.mateBaIndex == 2) { // this.mateBaTimer = 0 // this.mateBaIndex = 0; // } // } //} // //if (this.xiYou_mates[1]) { // this.mateSunTimer += dt; // // if (this.mateSunTimer > this.mateSunAniTime[this.mateSunIndex]) { // if (this.mateSunIndex == 0) { // //this.xiYou_spineSun.clearTrack(0); // //this.xiYou_spineSun.setBonesToSetupPose(); // this.xiYou_spineSun.setAnimation(0, "jump", false); // this.mateSunIndex++; // } else if (this.mateSunIndex == 1) { // //this.xiYou_spineSun.clearTrack(0); // //this.xiYou_spineSun.setBonesToSetupPose(); // this.xiYou_spineSun.setAnimation(0, "idle", true); // this.mateSunIndex++; // } else if (this.mateSunIndex == 2) { // //this.xiYou_spineSun.clearTrack(0); // //this.xiYou_spineSun.setBonesToSetupPose(); // this.xiYou_spineSun.setAnimation(0, "idle_ue", false); // this.mateSunIndex++; // } else if (this.mateSunIndex == 3) { // //this.xiYou_spineSun.clearTrack(0); // //this.xiYou_spineSun.setBonesToSetupPose(); // this.xiYou_spineSun.setAnimation(0, "jump down", false); // this.mateSunIndex++; // } else if (this.mateSunIndex == 4) { // //this.xiYou_spineSun.clearTrack(0); // //this.xiYou_spineSun.setBonesToSetupPose(); // this.xiYou_spineSun.setAnimation(0, "walk", true); // this.mateSunTimer = 0; // this.mateSunIndex = 0; // } // } //} } } private id = 1; private bgIndex = 0; UpdateMainBg() { let bgCfg = GameM.commonData.mainBgCfg; //console.log("----->MainCfg MaxCar:" + GameM.commonData.maxCarLevel); for (let i = 0; i < bgCfg.length; i++) { //console.log("----->MainCfg MaxCar:" + GameM.commonData.maxCarLevel + " CfgLv:" + bgCfg[i].maxLv + " Index:" + i); if (GameM.commonData.maxCarLevel <= bgCfg[i].maxLv) { this.ChangeBg(bgCfg[i].bgId, cc.color(bgCfg[i].color[0], bgCfg[i].color[1], bgCfg[i].color[2])) return; } } let len = bgCfg.length; this.ChangeBg(bgCfg[len - 1].bgId, cc.color(bgCfg[len - 1].color[0], bgCfg[len - 1].color[1], bgCfg[len - 1].color[2])); } /**切换背景*/ ChangeBgSelf() { //this.xiYou_spineBa.clearTrack(0); //this.xiYou_spineBa.setBonesToSetupPose(); //this.xiYou_spineBa.setAnimation(0, "walk", true); //this.scheduleOnce(()=>{ // this.xiYou_spineBa.clearTrack(0); // this.xiYou_spineBa.setBonesToSetupPose(); // this.xiYou_spineBa.setAnimation(0, "fall", false); // this.scheduleOnce(()=>{ // this.xiYou_spineBa.clearTrack(0); // this.xiYou_spineBa.setBonesToSetupPose(); // this.xiYou_spineBa.setAnimation(0, "run", true); // },1) //},1) this.UpdateMainBg(); //this.id++; //this.bgIndex++; //if (this.id > 8) this.id = 1; //if (this.bgIndex > 7) this.id = 0; ////this.id = this.id == 1 ? 2 : 1; //this.ChangeBg(this.id,GameM.commonData.mainBgCfg[this.bgIndex]); } private xiYou_bgColors: cc.Color[] = [ cc.color(93, 75, 34), cc.color(71, 96, 99), cc.color(40, 65, 55), cc.color(89, 43, 23), cc.color(11, 69, 20), cc.color(64, 22, 22), cc.color(21, 101, 38), cc.color(123, 116, 106) ] /** * 更新背景 * @param bgId 背景id */ ChangeBg(bgId: number, color: cc.Color) { cc.loader.loadRes("maps/tucao_bg" + bgId, cc.SpriteFrame, (err, res2) => { if (err) { console.log("load xiYou bg back err:" + err + " id:" + bgId); } else { this.xiYou_bg.spriteFrame = res2; this.xiYou_bg_bottom.color = color; } }); //cc.loader.loadRes("maps/xiyou_bgfront_" + bgId, cc.SpriteFrame, (err, res) => { // if (err) { // console.log("load xiYou bg err:" + err + " id:" + bgId); // } else { // cc.loader.loadRes("maps/xiyou_bgback_" + bgId, cc.SpriteFrame, (err, res2) => { // if (err) { // console.log("load xiYou bg back err:" + err + " id:" + bgId); // } else { // this.xiYou_bgUp.opacity = 0; // for (let i = 0; i < this.xiYou_bgUpImgs.length; i++) { // this.xiYou_bgUpImgs[i].spriteFrame = res; // } // this.xiYou_bgUpBottom.color = color; // cc.tween(this.xiYou_bgUp).to(0.7, { opacity: 255 }) // .call(() => { // for (let i = 0; i < this.xiYou_bgImgs.length; i++) { // this.xiYou_bgImgs[i].spriteFrame = res; // } // this.xiYou_bgBottom.color = color; // }) // .start(); // cc.tween(this.xiYou_bgDown).to(0.7, { opacity: 0 }) // .call(() => { // this.xiYou_bgDown.opacity = 255; // }) // .start(); // // // this.xiYou_bgBackUp.opacity = 0; // for (let i = 0; i < this.xiYou_bgBackUpImgs.length; i++) { // this.xiYou_bgBackUpImgs[i].spriteFrame = res2; // } // cc.tween(this.xiYou_bgBackUp).to(0.7, { opacity: 255 }) // .call(() => { // for (let i = 0; i < this.xiYou_bgBackImgs.length; i++) { // this.xiYou_bgBackImgs[i].spriteFrame = res2; // } // }) // .start(); // cc.tween(this.xiYou_bgBackDown).to(0.7, { opacity: 0 }) // .call(() => { // this.xiYou_bgBackDown.opacity = 255; // }) // .start(); // } // }); // } //}); } private isOpenNormalGuide = true; private carSpaceNum = 15; /**是否有可合成的武将*/ private guideHaveCompose = false; /**是否有金币*/ private guideHaveCoin = false; /**是否有宝箱*/ private guideHaveBox = false; /**是否有多余空位*/ private guideHaveEmpty = false; /**主界面常规引导*/ CheckNormalGuide() { if (this.isOpenNormalGuide && !GuideMng.Ins.IsGuideing) { this.guideHaveCompose = false; this.guideHaveCoin = false; this.guideHaveBox = false; let otherItem: cc.Node = null; let other2Item: cc.Node = null; let item1: cc.Node = null; let item2: cc.Node = null; let temp1 = null; let temp2 = null; let s1: CarSpace = null; let s2: CarSpace = null; let curMaxlv = 0; let curMinlv = 100; for (let i = 0; i < this.carSpaceNum; i++) { temp1 = this.CarPark.getChildByName(i.toString()) s1 = temp1.getComponent(CarSpace) if (s1.type == 10001) { if (!this.guideHaveCoin) { this.guideHaveCoin = true; otherItem = temp1; } } if (s1.type == 10004) { if (!this.guideHaveCoin && !this.guideHaveBox) { this.guideHaveBox = true; otherItem = temp1; } } if (s1.type > 0 && s1.type < 10000) { if (!this.guideHaveCoin && !this.guideHaveBox) { if (s1.type > curMaxlv && s1.CheckIsStrike()) { curMaxlv = s1.type; otherItem = temp1; } if (s1.type <= curMinlv) { curMinlv = s1.type; other2Item = temp1; } } } if (s1.type > 10000 || s1.type == 0) { continue } item1 = temp1; for (var j = i + 1; j < this.carSpaceNum; j++) { temp2 = this.CarPark.getChildByName(j.toString()) s2 = temp2.getComponent(CarSpace) if (s1.type == s2.type) { item2 = temp2 this.guideHaveCompose = true; break } } if (this.guideHaveCompose) { break } } if (this.guideHaveCompose) { if (item1 == null || item2 == null) return; this.xiyou_guide_click.active = false; this.xiyou_guide_drag.setPosition(GameController.Ins.GetWorldPos(item1)); this.xiyou_guide_drag.active = true; this.xiyou_guide_drag.stopAllActions(); let f1 = cc.moveTo(0.5, GameController.Ins.GetWorldPos(item2)); let f2 = cc.delayTime(0.5); let f3 = cc.callFunc(() => { this.xiyou_guide_drag.setPosition(GameController.Ins.GetWorldPos(item1)) }); let f = cc.sequence(f1, f2, f3).repeatForever(); this.xiyou_guide_drag.runAction(f); } else { if (this.guideHaveCoin) { this.xiyou_guide_drag.active = false; this.xiyou_guide_click.setPosition(GameController.Ins.GetWorldPos(otherItem)); this.xiyou_guide_click.active = true; } else { if (this.guideHaveBox) { this.xiyou_guide_drag.active = false; this.xiyou_guide_click.setPosition(GameController.Ins.GetWorldPos(otherItem)); this.xiyou_guide_click.active = true; } else { //判断是否有多余空位 if (this.IsHaveEmptySpace()) { let nextPrice = GameM.commonData.getPriceByType(this.curBuyType); let need = Sciencen_M.instance.subtraction(nextPrice, GameM.commonData.gold) if (need[0] == '-') { //今日视频次数没达到上限 if (GameM.commonData.dayBuyCarVideoLimitTimes > 0) { this.xiyou_guide_drag.active = false; this.xiyou_guide_click.setPosition(GameController.Ins.GetWorldPos(this.btnBuy)); this.xiyou_guide_click.active = true; } else { //引导点击未罢工的最高级武将 if (curMaxlv != 0) { this.xiyou_guide_drag.active = false; this.xiyou_guide_click.setPosition(GameController.Ins.GetWorldPos(otherItem)); this.xiyou_guide_click.active = true; } else { this.xiyou_guide_drag.stopAllActions(); this.xiyou_guide_drag.active = false; this.xiyou_guide_click.active = false; } } } else { this.xiyou_guide_drag.active = false; this.xiyou_guide_click.setPosition(GameController.Ins.GetWorldPos(this.btnBuy)); this.xiyou_guide_click.active = true; } } else { //无多余空位 if (curMinlv != 100) { this.xiyou_guide_click.active = false; this.xiyou_guide_drag.setPosition(GameController.Ins.GetWorldPos(other2Item)); this.xiyou_guide_drag.active = true; this.xiyou_guide_drag.stopAllActions(); let f1 = cc.moveTo(0.5, GameController.Ins.GetWorldPos(this.btnBuy)); let f2 = cc.delayTime(0.5); let f3 = cc.callFunc(() => { this.xiyou_guide_drag.setPosition(GameController.Ins.GetWorldPos(other2Item)) }); let f = cc.sequence(f1, f2, f3).repeatForever(); this.xiyou_guide_drag.runAction(f); } else { this.xiyou_guide_drag.stopAllActions(); this.xiyou_guide_drag.active = false; this.xiyou_guide_click.active = false; } } } } } } else { this.xiyou_guide_drag.stopAllActions(); this.xiyou_guide_drag.active = false; this.xiyou_guide_click.active = false; } } /** * 改变常规引导状态 * @param state 状态 1 开启 0 关闭 */ ChangeNormalGuideState(state: number) { if (state == 1) { this.isOpenNormalGuide = true; } else { this.isOpenNormalGuide = false; this.xiyou_guide_drag.stopAllActions(); this.xiyou_guide_drag.active = false; this.xiyou_guide_click.active = false; } } /** 检查显示彩蛋返回 * @param type 彩蛋类型 1 投放彩蛋 2 常规彩蛋 3 裂变彩蛋 */ showCaidan(type) { this.caidanBtn.node.y = 202.2 this.caidanBtn.node.active = true this.spCaidan.node.active = false this.newdan1.active = true if (type != 1) { this.labCaidanCount.node.parent.active = false } } /** 点击彩蛋 */ clickCaidan() { GameM.audioM.playEffect(AUDIO_TYPE.button) AdM.onSendEvent('button_5', '彩蛋icon', 'button') if (UsualCaidanData.Instance.userUsualEggInfo.isTodayFinished == 1) { if (GameM.commonData.roleData.canDailyCash == 1) { EffectNode.instance.PlayTip('今日已经领取三个彩蛋奖励了,请明天再来') } else { EffectNode.instance.PlayTip('每日提现后开启!') } } else { if (UsualCaidanData.Instance.userUsualEggInfo.isEnd == 0) { this.caidanHand.active = false UiM.Instance.onPanel(PANEL_NAME.UsualCaidanNode, false, () => { UiM.Instance.usualCaidanNode.getComponent(UsualCaidanNode).init() }) } } } /** 彩蛋飞走 */ caidanFlyAway() { cc.tween(this.caidanBtn.node) .to(1, { y: 1000 }) .call(() => { this.caidanBtn.node.active = false LogUtil.logV('UsualCaidan ', "彩蛋消失4 ") }) .start() } /** 获取彩蛋效果 */ caiDanEff() { this.caidanBtn.node.active = true this.labCaidanCount.node.parent.active = false this.spCaidan.node.active = true this.newdan1.active = false this.spCaidan.node.scale = 1 let parPos = this.caidanBtn.node.position this.spCaidan.node.setPosition(-parPos.x, -parPos.y + 110) cc.tween(this.spCaidan.node) .to(1, { position: cc.v2(0, 18), scale: 0.5 }) .call(() => { // if (CaiDanData.Instance.leftTime > 0) { // this.labCaidanCount.node.parent.active = true // } // else { // this.labCaidanCount.node.parent.active = false // } this.labCaidanCount.node.parent.active = false this.spCaidan.node.active = false this.newdan1.active = true }) .start() } // caiDanCount() { // CaiDanData.Instance.leftTime-- // this.labCaidanCount.string = utils.ParseTime2Format(CaiDanData.Instance.leftTime) // if (CaiDanData.Instance.leftTime <= 0) { // this.caidanBtn.node.active = false // this.unschedule(this.caiDanCount) // } // } //财神降临 TimerWealthCooling() { if (WealthData.Ins.wealthInfo != null) { if (WealthData.Ins.wealthInfo.wealthGodStatus == 1) { if (WealthData.Ins.coolingTimer > 0) { this.txt_wealthCoolTimer.string = MyExtends.TimeToFormat(WealthData.Ins.coolingTimer, 3); } else { this.txt_wealthCoolTimer.string = "" } } else { this.txt_wealthCoolTimer.string = "" } } else { this.txt_wealthCoolTimer.string = "" } } RichManInit() { this.richmanBtn.active = RichData.Ins.richCfg.richmanopen == 1; this.UpdateRichManQipao(); } UpdateRichManQipao() { this.richBtnQipao.active = RichData.Ins.diceTotalNum > 0; this.richQipaoTxt.string = RichData.Ins.diceTotalNum + ""; } isgamepause: boolean = false; onKeyDown(event: cc.Event.EventKeyboard) { switch (event.keyCode) { case cc.macro.KEY.space: if (this.isgamepause) { cc.game.resume(); this.isgamepause = false; } else { cc.game.pause(); this.isgamepause = true; } break; } } setGuideInstallVisible(active) { this.guideInstallBtn.node.active = active } /** 打开引导安装 */ clickGuideInstall() { GameM.audioM.playEffect(AUDIO_TYPE.button); AdM.onSendEvent('button_19', '宝葫芦icon点击', 'button') UiM.Instance.onPanel(PANEL_NAME.GuideInstallApkNode) } /** 检查是否显示宝葫芦 */ checkShowGuideInstall() { if (DownloadApkData.Instance.installSwitch && GameM.commonData.isAuth) { AdM.checkPathApk() //定时检查是否有新安装包 this.schedule(() => { if (!this.guideInstallBtn.node.active) { AdM.checkPathApk() } }, 60) } } /** * 检查是否有礼包兑换 */ CheckRedeem() { HttpM.Instance.SendData(HTTP_TYPE.redeemGetRedemption, {}, (res) => { console.log("--->RedeemGift:", res); if (res.data != null && res.errcode == 0) { GameM.commonData.redeemData = res.data; this.redeemBtn.active = res.data.code == 1; } }); } Click_RedeemBtn() { UiM.Instance.onPanel(PANEL_NAME.RedeemNode); GameM.audioM.playEffect(AUDIO_TYPE.button); AdM.onSendEvent('button_20', '兑换码icon点击', 'button') } CheckAdRb() { this.adRbBtn.active = GameM.commonData.globalCfg.VideoRedBagOpen == 1; } /** 设置更多游戏图片 */ setMoreGameSp(arr) { let len = arr.length let index = Utils.rnd(0, len - 1) let data = arr[index] this.showMoreGameSp(data) this.schedule(() => { index++ index = (index % len) LogUtil.logV('setMoreGameSp ', 'index ' + index) data = arr[index] this.showMoreGameSp(data) }, 10) } showMoreGameSp(data) { cc.loader.load(data.icon, (err, res) => { if (err) { console.log('err:', err); return; } if (this.spMoregame) { let tex: cc.Texture2D = res as cc.Texture2D; this.spMoregame.spriteFrame = new cc.SpriteFrame(tex); } }) this.labMoregame.string = data.title } /** 是否显示常规提现、每日提现、钱庄按钮 */ checkShowCashBtns() { if (GameM.commonData.loginDays == 1 || (CashOutData.Instance.cashStatus.length + DailyCashData.Instance.dailyCashStatus.length) <= 0) { } else { if (GameM.commonData.cashStateBtnsArr[0] == '1') { this.tixianProBtn.node.active = true } else { this.tixianProBtn.node.active = false } if (GameM.commonData.cashStateBtnsArr[1] == '1') { this.dailyCashBtn.node.active = true } else { this.dailyCashBtn.node.active = false } if (GameM.commonData.cashStateBtnsArr[2] == '1') { this.bankBtn.node.active = true } else { this.bankBtn.node.active = false } } } }