// Learn TypeScript: // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html import GameM, { VIDEO_TYPE, AUDIO_TYPE } from "../manager/GameM"; import CarSpace from "../prefabs/CarSpace"; import { HTTP_TYPE, MONEY_TYPE, RecordTYPE } from "../datas/CommonData"; import EffectNode from "./EffectNode"; import UiM, { PANEL_NAME } from "../manager/UiM"; import Main from "../Main"; import AdM from "../manager/AdM"; import Sciencen_M from "../utils/Sciencen_M"; import GlobalStorage, { STORAGE_KEY } from "../datas/GlobalStorage"; import GuideManager from "../manager/GuideManager"; import LogUtil from "../utils/LogUtil"; import Treasure from "./Treasure"; import RoleManageData from "../datas/RoleManageData"; import Turntable from "./Turntable"; import SwitchM from "../manager/SwitchM"; import GuideMng from "../manager/GuideMng"; import { FightData } from "../datas/FightData"; import { MateData } from "../datas/MateData"; import { Utils } from "../utils/Utils"; import NativeAdAwardData from "../manager/NativeAdAwardData"; import NativeADAwardNode from "./NativeAdAwardNode"; import DailyData from "../datas/DailyData"; import { RichData } from "../datas/RichData"; import { PlayerPrefs } from "../tools/MyExtends"; import MoreGameData from "../datas/MoreGameData"; const { ccclass, property } = cc._decorator; @ccclass export default class Gift extends cc.Component { @property(cc.Node) light: cc.Node = null; @property(cc.Node) xing: cc.Node = null; @property(cc.Node) goldIcons: cc.Node = null; @property(cc.Node) redMoneyIcons: cc.Node = null; @property(cc.Node) offlineIcons: cc.Node = null; @property(cc.Node) boxIcons: cc.Node = null; @property(cc.Node) lvupcarIcons: cc.Node = null; @property(cc.Node) popVideoIcons: cc.Node = null; @property(cc.Node) icon: cc.Node = null; @property(cc.Label) labNum: cc.Label = null; @property(cc.Node) btnGetGold: cc.Node = null; @property(cc.RichText) labDayLeft: cc.RichText = null; @property(cc.Node) btnGetOffline: cc.Node = null; @property(cc.Node) lyGold: cc.Node = null; @property(cc.Node) newcarIcons: cc.Node = null; @property(cc.Sprite) car: cc.Sprite = null; //被动视频 @property(cc.Node) popVideoIcon: cc.Node = null; //znh @property(cc.Label) maxCarLvTxt: cc.Label = null; @property(cc.Node) btn_close: cc.Node = null; @property(cc.Node) btn_offlineSingle: cc.Node = null; //new car @property(cc.Label) labCarNum: cc.Label = null; @property(cc.Label) labCarMoney: cc.Label = null; @property(cc.Node) newCarBg: cc.Node = null; @property(cc.Node) btnCarGet: cc.Node = null; @property(cc.Node) btnCarDouble: cc.Node = null; @property(cc.Node) btnCarSingle: cc.Node = null; @property(cc.Node) videoIcon: cc.Node = null; @property(cc.Label) labGoldBtnDes: cc.Label = null; @property(cc.Node) btnGet: cc.Node = null; @property(cc.Sprite) btnBanner: cc.Sprite = null; @property(cc.Node) newCarVideoIcon: cc.Node = null; //lvup @property(cc.Sprite) carTo: cc.Sprite = null; @property(cc.Sprite) carN: cc.Sprite = null; @property(cc.Label) labCarTo: cc.Label = null; @property(cc.Label) labCarN: cc.Label = null; @property(cc.RichText) labPercent: cc.RichText = null; @property(cc.Node) videoGetGold: cc.Node = null; @property(cc.RichText) videoLabPercent: cc.RichText = null; @property(cc.Label) labVideoGold: cc.Label = null; @property(cc.Label) labCurGold: cc.Label = null; //新增加底 @property(cc.Node) giftBg: cc.Node = null; @property(cc.Node) titleBg: cc.Node = null; @property(cc.Node) treasureTicket: cc.Node = null; @property(cc.Node) propNode: cc.Node = null; @property(cc.Sprite) spriteProp: cc.Sprite = null; @property(cc.Label) treasureGold: cc.Label = null; @property(cc.Label) propNum: cc.Label = null; @property(cc.Node) labDrop: cc.Node = null; @property(cc.Node) clearCoolNode: cc.Node = null; @property(cc.Node) clearBtnNode: cc.Node = null; @property(cc.Node) clearCloseNode: cc.Node = null; /** 类型 10001:金币 10002:红包币 10003:时间段收益(当前的每秒收益*时间段) 10004:惊喜礼包(打开后获得对应等级的汽车) 10005:离线收益*/ type = 0 /** 数量 */ num = '0' /** 车位 */ carSp = null /** 是飞船 */ isAirship = false isVideo = false //是否观看视频 adType: VIDEO_TYPE = null; //视频类型 countDown = 0 turntable = false streamData = null onEnable() { } onDisable() { if (this.type == MONEY_TYPE.box) { AdM.createInter(2); } else if (this.type == MONEY_TYPE.offlineGold) { AdM.createInter(4); UiM.Instance.hallNode.getComponent(Main).checkPopSecretary() } else if (this.type == MONEY_TYPE.getNewCar) { AdM.createInter(9); } else if (this.type == MONEY_TYPE.gold) { AdM.createInter(11); } else if (this.type == MONEY_TYPE.carLvUp) { AdM.createInter(12); } AdM.destroyNative() AdM.destroyBanner() if (this.isAirship) { UiM.Instance.hallNode.getComponent(Main).resumeAirShip() } UiM.Instance.hallNode.getComponent(Main).CheckNormalGuide(); } init(type, num, carSp = null, isAirship = false, isvideo = 0, adType: VIDEO_TYPE = null, percent = -1, turntable = false) { this.type = type this.num = num this.carSp = carSp this.isAirship = isAirship this.isVideo = (isvideo == 1) this.adType = adType this.turntable = turntable this.labNum.node.parent.scale = 1 if (this.isAirship) { this.changeAir = false if (NativeAdAwardData.Instance.canGetAward(2)) { this.labDrop.active = true } else { this.labDrop.active = false this.labNum.node.parent.scale = 0 cc.tween(this.labNum.node.parent) .to(0.6, { scale: 1 }) .start() } } else { this.labDrop.active = false } this.labNum.string = Sciencen_M.instance.format(this.num) if (percent == -1) { this.labPercent.string = '' } else { let add if (GameM.commonData.loginDays <= 7) { add = GameM.commonData.loginDays * 10 } else { add = 70 } percent += add //航海 //this.labPercent.string = `视频收益 ${percent}%(登录${GameM.commonData.loginDays}天+${add}%)` } this.light.active = true this.xing.active = true this.goldIcons.active = false this.redMoneyIcons.active = false this.offlineIcons.active = false this.lvupcarIcons.active = false this.popVideoIcons.active = false this.treasureTicket.active = false this.clearCoolNode.active = false this.icon.active = false this.lyGold.active = false this.newcarIcons.active = false this.boxIcons.active = false this.videoIcon.active = false this.btnGetGold.active = false this.btn_close.active = true // this.btn_close.y = 311 // this.light.y = 149 this.giftBg.active = false this.titleBg.active = false this.btnGet.active = false this.btnBanner.node.active = false this.videoGetGold.active = false this.labGoldBtnDes.string = '领取奖励' this.propNode.active = false GameM.audioM.playEffect(AUDIO_TYPE.open_interface) let self = this switch (this.type) { case MONEY_TYPE.gold: //金币 this.giftBg.active = true this.btnGetGold.active = true if (this.adType == VIDEO_TYPE.buyCarMainBtn || this.adType == VIDEO_TYPE.shopBuyCarBtn) { this.labDayLeft.string = `今日剩余次数:${GameM.commonData.dayBuyCarVideoLimitTimes - 1}` //西游 //唐僧天赋3 if (MateData.Ins.Mate1Talent3 > 0) { this.videoLabPercent.string = `金币加成 ${MateData.Ins.Mate1Talent3}%` } else { this.videoLabPercent.string = ""; } this.labVideoGold.string = Sciencen_M.instance.format(this.num); this.videoGetGold.active = true } else { this.labDayLeft.string = '' this.labNum.string = Sciencen_M.instance.format(this.num); this.goldIcons.active = true this.lyGold.active = true if (this.isVideo) { this.videoIcon.active = true; } } if (this.carSp != null) { NativeAdAwardData.Instance.setGetAward(3) if (NativeAdAwardData.Instance.canGetAward(3)) { this.labGoldBtnDes.string = `${NativeAdAwardData.Instance.nativeAwardTimes}倍领取` this.btnGet.active = true this.streamData = MoreGameData.Instance.getRandomSteam() if (this.streamData) { cc.loader.load(this.streamData.stream, (err, res) => { if (err) { console.log('err:', err); return; } if (this.btnBanner) { let tex: cc.Texture2D = res as cc.Texture2D; this.btnBanner.spriteFrame = new cc.SpriteFrame(tex); this.btnBanner.node.active = true } }) } } else { this.labGoldBtnDes.string = '领取奖励' this.btnGet.active = false } } else { this.labGoldBtnDes.string = '领取奖励' this.btnGet.active = false } break case MONEY_TYPE.redMoney: //红包币 含飞船奖励 this.giftBg.active = true this.btnGetGold.active = true this.redMoneyIcons.active = true this.lyGold.active = true if (this.isVideo) { this.videoIcon.active = true; } break case MONEY_TYPE.timespanGold: break case MONEY_TYPE.box: //含飞船奖励 this.giftBg.active = true this.boxIcons.active = true this.lyGold.active = true this.icon.active = false if (isvideo) { this.videoIcon.active = true } this.btnGetGold.active = true this.labNum.string = '惊喜宝箱 x' + this.num.toString() break case MONEY_TYPE.turnTableCard: this.propNode.active = true this.btnGetGold.active = true this.giftBg.active = true this.propNum.string = "x" + this.num cc.loader.loadRes('gift/spriteZhuanpanka', cc.SpriteFrame, (err, assets) => { if (err) { cc.error(err); return; } this.spriteProp.spriteFrame = assets; this.spriteProp.node.scale = 0.8 }) if (this.isVideo) { this.videoIcon.active = true; } this.propNode.getChildByName("propName").getComponent(cc.Label).string = "转盘卡" // if (this.adType == VIDEO_TYPE.buyCarMainBtn || this.adType == VIDEO_TYPE.shopBuyCarBtn) { // this.labDayLeft.string = `今日剩余次数:${GameM.commonData.dayBuyCarVideoLimitTimes - 1}` // } // else { // this.labDayLeft.string = '' // } break case MONEY_TYPE.treasureCard: this.propNode.active = true this.btnGetGold.active = true this.giftBg.active = true this.propNum.string = "x" + this.num cc.loader.loadRes('gift/spriteDuobaoquan', cc.SpriteFrame, (err, assets) => { if (err) { cc.error(err); return; } this.spriteProp.spriteFrame = assets; this.spriteProp.node.scale = 0.8 }) if (this.isVideo) { this.videoIcon.active = true; } this.propNode.getChildByName("propName").getComponent(cc.Label).string = "夺宝券" break case MONEY_TYPE.speedCard: this.propNode.active = true this.btnGetGold.active = true this.giftBg.active = true this.propNum.string = "x" + this.num cc.loader.loadRes('gift/spriteJiasuka', cc.SpriteFrame, (err, assets) => { if (err) { cc.error(err); return; } this.spriteProp.spriteFrame = assets; this.spriteProp.node.scale = 0.8 }) if (this.isVideo) { this.videoIcon.active = true; } this.propNode.getChildByName("propName").getComponent(cc.Label).string = "加速券" break case MONEY_TYPE.talentCoin: this.propNode.active = true this.btnGetGold.active = true this.giftBg.active = true this.propNum.string = "x" + this.num LogUtil.logV("HTTP_TYPE.updateBattleStoneCount show", MateData.Ins.talentCoin) cc.loader.loadRes('xiyou/icon/1003', cc.SpriteFrame, (err, assets) => { if (err) { cc.error(err); return; } this.spriteProp.spriteFrame = assets; this.spriteProp.node.scale = 2 }) this.propNode.getChildByName("propName").getComponent(cc.Label).string = "天赋石" break case MONEY_TYPE.offlineGold: //离线收益 this.giftBg.active = false this.titleBg.active = true this.btnGetGold.active = false this.offlineIcons.active = true this.icon.active = true this.btn_close.active = false this.lyGold.active = false this.btn_offlineSingle.active = false; this.light.active = false this.offlineIcons.getChildByName("offlineNumLab").getComponent(cc.Label).string = Sciencen_M.instance.format(this.num) //白龙马天赋2 if (MateData.Ins.Mate3Talent2 > 0) { this.labPercent.string = `天赋加成 ${MateData.Ins.Mate3Talent2}%` } else { this.labPercent.string = ""; } this.scheduleOnce(() => { // this.offlineIcons.getChildByName("offlineClose").active = true; // this.btn_offlineSingle.active = true; // this.btn_offlineSingle.opacity = 0; // cc.tween(this.btn_offlineSingle).to(0.5, { opacity: 255 }).start(); }, 0); break case MONEY_TYPE.getNewCar: this.titleBg.active = false this.btn_close.active = false this.light.active = false this.xing.active = false this.btnCarDouble.active = true this.btnCarGet.active = false self.car.node.active = false cc.loader.loadRes('carPic/side/side_' + GameM.commonData.maxCarLevel, cc.SpriteFrame, (err, assets) => { if (err) { cc.error(err); return; } self.car.spriteFrame = assets; self.car.node.active = true }) this.unschedule(this.getNewCarDelayCall); this.btn_close.active = false; this.btnCarSingle.active = false; this.maxCarLvTxt.string = GameM.commonData.maxCarLevel.toString(); if (GameM.commonData.maxCarLevel <= 4) { this.btnCarDouble.active = false this.btnCarGet.active = true } else { this.btnCarDouble.active = true this.btnCarGet.active = false } this.newcarIcons.active = true this.labCarNum.string = this.num if (GameM.commonData.redSwitch) { this.labCarMoney.string = `可兑换${(Number(this.num) * 0.0001).toFixed(2)}元` } else { this.labCarMoney.string = '' } this.newCarBg.y = -90 cc.tween(this.newCarBg) .delay(0.2) .to(0.5, { y: 100 }).start() let delayTime = 0 if (SwitchM.forceMakeMoney) { // delayTime = 2 } this.scheduleOnce(this.getNewCarDelayCall, delayTime); break case MONEY_TYPE.carLvUp: this.titleBg.active = true this.btn_close.active = false this.lvupcarIcons.active = true self.carTo.node.active = false this.light.active = false this.giftBg.active = false this.labCarTo.string = this.num.toString() this.labCarN.string = this.carSp.toString() cc.loader.loadRes('carPic/side/side_' + this.num, cc.SpriteFrame, (err, assets) => { if (err) { cc.error(err); return; } self.carTo.spriteFrame = assets; self.carTo.node.active = true }) self.carN.node.active = false cc.loader.loadRes('carPic/side/side_' + this.carSp, cc.SpriteFrame, (err, assets) => { if (err) { cc.error(err); return; } self.carN.spriteFrame = assets; self.carN.node.active = true }) // this.btn_close.active = false // this.scheduleOnce(() => { // this.btn_close.active = true; // }, 0); break case MONEY_TYPE.popVideo: //主动拉视频 this.giftBg.active = true this.btnGetGold.active = false this.popVideoIcons.active = true // if (GameM.commonData.roleData.hangVideoFree == 0) { // this.popVideoIcon.active = false // } // else { // this.popVideoIcon.active = true // } this.popVideoIcon.active = true this.icon.active = true this.lyGold.active = true this.labCurGold.string = Sciencen_M.instance.format(GameM.commonData.gold) this.scheduleOnce(() => { this.btn_close.active = true; }, 0); break case MONEY_TYPE.buyCarGold: //点击购买汽车按钮,金币不足 case MONEY_TYPE.mainBuyCarGold: //主界面点击购买汽车按钮,金币不足 this.giftBg.active = true this.btnGetGold.active = true this.videoIcon.active = true // this.goldIcons.active = true // this.lyGold.active = true this.labVideoGold.string = Sciencen_M.instance.format(this.num); this.videoGetGold.active = true this.labDayLeft.string = `今日剩余次数:${GameM.commonData.dayBuyCarVideoLimitTimes}` //西游 //唐僧天赋3 if (MateData.Ins.Mate1Talent3 > 0) { // this.labPercent.string = `天赋加成 ${MateData.Ins.Mate1Talent3}%` this.videoLabPercent.string = `金币加成 ${MateData.Ins.Mate1Talent3}%` } else { // this.labPercent.string = "" this.videoLabPercent.string = `金币加成 ${0}%` } break case MONEY_TYPE.treasureTicket: //视频获得兑奖券 this.titleBg.active = false this.treasureTicket.active = true this.giftBg.active = true this.light.active = false this.treasureGold.string = Sciencen_M.instance.format(this.num) break case MONEY_TYPE.clearCooltime: //清除所有罢工时间 this.giftBg.active = false this.titleBg.active = false this.btn_close.active = false this.clearCoolNode.active = true this.light.active = false this.unschedule(this.showCleartime) this.clearBtnNode.active = false this.clearCloseNode.active = false let closeTime = 1//显示关闭时间 if (GameM.commonData.adShowConfig && GameM.commonData.adShowConfig.is_show_banner == 1) { closeTime = 0 } this.scheduleOnce(this.showCleartime, closeTime) break } AdM.destroyNative() if (this.adType != VIDEO_TYPE.hangUp) { this.node.x = 0 } if (this.giftBg.active) { // if (this.adType == VIDEO_TYPE.buyCarMainBtn || this.adType == VIDEO_TYPE.shopBuyCarBtn // || this.type == MONEY_TYPE.buyCarGold || this.type == MONEY_TYPE.mainBuyCarGold // || this.btnGet.active) { if (this.btnGet.active || (this.type == MONEY_TYPE.gold && this.adType == VIDEO_TYPE.buyCarMainBtn)) { // if (GameM.commonData.checkShowMainPop()) { // AdM.showNative(0) // } } else { AdM.showNative(0) } } if (!this.btnGet.active) { AdM.showBanner() } } getNewCarDelayCall() { // this.btn_close.active = true; this.btnCarSingle.active = true; this.btnCarSingle.opacity = 0; cc.tween(this.btnCarSingle).to(0.5, { opacity: 255 }).start(); } clickLvUp() { GameM.audioM.playEffect(AUDIO_TYPE.button) GameM.adM.watchVideo(this.adType); } showCleartime() { this.clearBtnNode.active = true this.clearCloseNode.active = true } clickClearCoolTime() { GameM.audioM.playEffect(AUDIO_TYPE.button) if (GameM.commonData.isVideoTest) { this.clearCoolTime() } else { GameM.adM.watchVideo(this.adType); } } //清除所有罢工 clearCoolTime() { this.node.active = false EffectNode.instance.PlayTip(`成功清除所有武将罢工`) UiM.Instance.hallNode.getComponent(Main).clearAllCoolTime() } clickGetGold() { GameM.audioM.playEffect(AUDIO_TYPE.button) if (this.turntable) { UiM.Instance.turntableNode.getComponent(Turntable).updateCurrentNum() } switch (this.type) { case MONEY_TYPE.gold: if (this.carSp != null) { if (!NativeAdAwardData.Instance.canGetAward(3)) { let s = this.carSp.getComponent(CarSpace) s.changeType(0) GameM.commonData.updateBagCarData(s.index.toString(), 0) this.scheduleOnce(() => { UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece() }, 0.1) } } if (this.isVideo) { if (this.isAirship) { GameM.adM.watchVideo(VIDEO_TYPE.gift_gold); } } else { if (this.isAirship) { GameM.commonData.updateAirShipTimes() } if (this.carSp != null) { if (!NativeAdAwardData.Instance.canGetAward(3)) { GameM.commonData.updateGold(this.num) GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)); } else { UiM.Instance.onPanel(PANEL_NAME.NativeAdAwardNode, false, () => { UiM.Instance.nativeAdAwardNode.getComponent(NativeADAwardNode).init(3, this.num, this.carSp) }) } } else { GameM.commonData.updateGold(this.num) GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)); } this.node.active = false } if (this.adType == VIDEO_TYPE.buyCarMainBtn || this.adType == VIDEO_TYPE.shopBuyCarBtn) { this.adType = null 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) EffectNode.instance.PlayTip(`今日剩余次数:${GameM.commonData.dayBuyCarVideoLimitTimes}`) } break case MONEY_TYPE.redMoney: //含飞船奖励 this.node.active = false //if (this.isAirship) { if (this.isVideo) { if (this.isAirship) { //飞船奖励400元宝看广告获取 GameM.adM.watchVideo(VIDEO_TYPE.gift_redMoney); } else { //车位元宝视频 //最高等级车奖励视频 GameM.adM.watchVideo(this.adType); } } else { GameM.commonData.updateRedMoney(Number(this.num), RecordTYPE.onlineGiftRed) if (this.carSp != null) { let s = this.carSp.getComponent(CarSpace) s.changeType(0) GameM.commonData.updateBagCarData(s.index.toString(), 0) this.scheduleOnce(() => { UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece() }, 0.1) } if (this.isAirship) { GameM.commonData.updateAirShipTimes() } GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) EffectNode.instance.PlayCoinAnim(1, 20, cc.v2(0, -300)); } break case MONEY_TYPE.offlineGold: GameM.commonData.updateGold(this.num) this.node.active = false GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)); break case MONEY_TYPE.box: //含飞船奖励 if (this.isVideo) { GameM.adM.watchVideo(VIDEO_TYPE.gift_box) } else { this.node.active = false if (this.isAirship) { GameM.commonData.updateAirShipTimes() } //立刻生成 for (let i = 0; i < Number(this.num); i++) { UiM.Instance.hallNode.getComponent(Main).addBoxGiftNow(); } } break case MONEY_TYPE.buyCarGold: GameM.adM.watchVideo(VIDEO_TYPE.shopBuyCarBtn); break case MONEY_TYPE.mainBuyCarGold: GameM.adM.watchVideo(VIDEO_TYPE.buyCarMainBtn); break case MONEY_TYPE.turnTableCard: if (this.isVideo) { if (GameM.commonData.isVideoTest) { this.onPropADEnd() } else { GameM.adM.watchVideo(VIDEO_TYPE.gift_Prop); } // return } else { if (this.carSp != null) { let s = this.carSp.getComponent(CarSpace) s.changeType(0) GameM.commonData.updateBagCarData(s.index.toString(), 0) this.scheduleOnce(() => { UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece() }, 0.1) } if (this.isAirship) { GameM.commonData.updateAirShipTimes() GameM.commonData.roleData.airshipTurntableCard++ } this.node.active = false RoleManageData.Instance.addTurntableCardCount(Number(this.num).valueOf()) EffectNode.instance.PlayTip(`转盘卡+${this.num}`) } // GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) // EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)); break case MONEY_TYPE.treasureCard: if (this.isVideo) { if (GameM.commonData.isVideoTest) { this.onPropADEnd() } else { GameM.adM.watchVideo(VIDEO_TYPE.gift_Prop); } // return } else { if (this.carSp != null) { let s = this.carSp.getComponent(CarSpace) s.changeType(0) GameM.commonData.updateBagCarData(s.index.toString(), 0) this.scheduleOnce(() => { UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece() }, 0.1) } if (this.isAirship) { GameM.commonData.updateAirShipTimes() GameM.commonData.roleData.airshipTicket++ } this.node.active = false RoleManageData.Instance.addTreasureCard(Number(this.num).valueOf()) EffectNode.instance.PlayTip(`夺宝券+${this.num}`) } // GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) // EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)); break case MONEY_TYPE.speedCard: if (this.isVideo) { if (GameM.commonData.isVideoTest) { this.onPropADEnd() } else { GameM.adM.watchVideo(VIDEO_TYPE.gift_Prop); } // return } else { if (this.isAirship) { GameM.commonData.updateAirShipTimes() GameM.commonData.roleData.airshipSpeedCard++ } if (this.carSp != null) { let s = this.carSp.getComponent(CarSpace) s.changeType(0) GameM.commonData.updateBagCarData(s.index.toString(), 0) this.scheduleOnce(() => { UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece() }, 0.1) } this.node.active = false RoleManageData.Instance.addInvestCard(Number(this.num).valueOf()) EffectNode.instance.PlayTip(`加速券+${this.num}`) } break case MONEY_TYPE.talentCoin: if (this.isVideo) { // if (GameM.commonData.isVideoTest) { // this.onPropADEnd() // } else { // GameM.adM.watchVideo(VIDEO_TYPE.gift_Prop); // } // return } else { if (this.isAirship) { // GameM.commonData.updateAirShipTimes() // GameM.commonData.roleData.airshipSpeedCard++ } // if (this.carSp != null) { // let s = this.carSp.getComponent(CarSpace) // s.changeType(0) // GameM.commonData.updateBagCarData(s.index.toString(), 0) // this.scheduleOnce(() => { // UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece() // }, 0.1) // } this.node.active = false MateData.Ins.talentCoin += Number(this.num) LogUtil.logV("HTTP_TYPE.updateBattleStoneCount one", MateData.Ins.talentCoin) GameM.httpM.SendData(HTTP_TYPE.updateBattleStoneCount, { "count": MateData.Ins.talentCoin }) //更新红点 MateData.Ins.checkMateRedPoint() EffectNode.instance.PlayTip(`天赋石+${this.num}`) } break } //显示界面 UiM.Instance.displayPanel(); } // /**购买按钮视频广告回调*/ // onBuyCarAdEnd() { // EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放"); // // this.type = MONEY_TYPE.gold // // this.videoIcon.active = false // GameM.commonData.updateClickVideoTimes() // GameM.commonData.updateGold(this.num) // UiM.Instance.hallNode.getComponent(Main).updateBuyBtnState(); // this.node.active = false // GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) // EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)); // } //飞船看广告后得宝箱 onGiftBoxWatchEnd() { GameM.commonData.updateGiftCacheNum(this.num) this.node.active = false if (this.isAirship) { GameM.commonData.updateAirShipTimes() } EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放"); //显示界面 UiM.Instance.displayPanel(); } //飞船看广告后奖励元宝 onGiftRedMoneyAdEnd() { GameM.commonData.updateRedMoney(Number(this.num), RecordTYPE.airship) GameM.commonData.updateAirShipTimes() GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) EffectNode.instance.PlayCoinAnim(1, 20, cc.v2(0, -300)); EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放"); } //飞船看广告后得金币 onGiftGoldADEnd() { GameM.commonData.updateAirShipTimes() this.node.active = false GameM.commonData.updateGold(this.num) GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)); } /** 双倍领取离线收益 */ clickGetOffline() { GameM.audioM.playEffect(AUDIO_TYPE.button) GameM.adM.watchVideo(VIDEO_TYPE.offLineDouble) } onOfflineWatchEnd() { this.num = Sciencen_M.instance.accMul(this.num, '2') GameM.commonData.updateGold(this.num) GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)) this.node.active = false EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放"); //显示界面 UiM.Instance.displayPanel(); } //飞船看广告后获得物品 //夺宝券,加速卡,转盘卡 onPropADEnd() { if (this.isAirship) { GameM.commonData.updateAirShipTimes() switch (this.type) { case MONEY_TYPE.turnTableCard: GameM.commonData.roleData.airshipTurntableCard++ break; case MONEY_TYPE.treasureCard: GameM.commonData.roleData.airshipTicket++ break; case MONEY_TYPE.speedCard: GameM.commonData.roleData.airshipSpeedCard++ break; } } EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放"); switch (this.type) { case MONEY_TYPE.turnTableCard: if (this.carSp != null) { let s = this.carSp.getComponent(CarSpace) s.changeType(0) GameM.commonData.updateBagCarData(s.index.toString(), 0) this.scheduleOnce(() => { UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece() }, 0.1) } RoleManageData.Instance.addTurntableCardCount(Number(this.num).valueOf()) EffectNode.instance.PlayTip(`转盘卡+${this.num}`) // GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) // EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)); break case MONEY_TYPE.treasureCard: if (this.carSp != null) { let s = this.carSp.getComponent(CarSpace) s.changeType(0) GameM.commonData.updateBagCarData(s.index.toString(), 0) this.scheduleOnce(() => { UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece() }, 0.1) } RoleManageData.Instance.addTreasureCard(Number(this.num).valueOf()) EffectNode.instance.PlayTip(`夺宝券+${this.num}`) // GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) // EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)); break case MONEY_TYPE.speedCard: if (this.carSp != null) { let s = this.carSp.getComponent(CarSpace) s.changeType(0) GameM.commonData.updateBagCarData(s.index.toString(), 0) this.scheduleOnce(() => { UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece() }, 0.1) } RoleManageData.Instance.addInvestCard(Number(this.num).valueOf()) EffectNode.instance.PlayTip(`加速券+${this.num}`) break } this.node.active = false } //直接领取 clickGetCarSingle() { GameM.audioM.playEffect(AUDIO_TYPE.button) GameM.commonData.updateRedMoney(Number(this.num), RecordTYPE.carLevelup) GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) EffectNode.instance.PlayCoinAnim(1, 20, cc.v2(0, -300)); this.node.active = false console.log("----> clickGetCarSingle") this.checkShowGuide() UiM.Instance.hallNode.getComponent(Main).playCarProEff() } checkShowGuide() { // if (GameM.commonData.maxCarLevel == GameM.commonData.cashCft[0].type_value && UiM.Instance.hallNode) { // UiM.Instance.hallNode.getComponent(Main).checkNewUser() // } let setColor = false if (GameM.commonData.maxCarLevel == 2) { if (GameM.commonData.redSwitch) { // UiM.Instance.guideNode.getComponent(Guide).showMask4(); setColor = true } } else if (GameM.commonData.maxCarLevel == 3) { if (GameM.commonData.redSwitch) { // UiM.Instance.guideNode.getComponent(Guide).showGuide10(); setColor = true } } else if (GameM.commonData.maxCarLevel == GameM.commonData.dailyCashOpenLevel) { setColor = true if (GameM.commonData.redSwitch) { GuideManager.Instance.createFullGuide(cc.find("Canvas"), 2, () => { // UiM.Instance.guideNode.getComponent(Guide).showGuide9(0) }) } } // else if (GameM.commonData.maxCarLevel == GameM.commonData.investOpenLevel) { // //投资引导 // UiM.Instance.hallNode.getComponent(Main).showInvestHand() // setColor = true // } //else if (GameM.commonData.maxCarLevel == GameM.commonData.factoryOpenLevel) { else if (GameM.commonData.maxCarLevel == GameM.commonData.unlockStrikeLv) { //工厂开启 改为 开启西游点击生成金币 //西游 点击武将生成金币引导 放到最新引导模块 if (!GuideMng.Ins.IsUnlockStrike()) { let name = UiM.Instance.hallNode.getComponent(Main).GetRoleSpaceIndex(); console.log("-->StrikeGuideName:" + name); GuideMng.Ins.UpdateGuideStrikeFile(name); GuideMng.Ins.CheckUnlockStrike(); } //航海 //UiM.Instance.guideNode.getComponent(Guide).showFacGuide() //setColor = true } else if (GameM.commonData.maxCarLevel == GameM.commonData.loginRewardOpenLevel) { if (GameM.commonData.redSwitch) { // UiM.Instance.guideNode.getComponent(Guide).showDailyGuide() setColor = true } } else if (GameM.commonData.maxCarLevel == GameM.commonData.trerasureOpenLevel) { setColor = true if (GameM.commonData.redSwitch) { // GuideManager.Instance.createFullGuide(cc.find("Canvas"), 3, () => { // UiM.Instance.guideNode.getComponent(Guide).showTreasureStep1(); // }) } } // else if (GameM.commonData.maxCarLevel == GameM.commonData.richBankUnLockLevel) { // setColor = true // if (GameM.commonData.redSwitch) { // LogUtil.logV("HTTP_TYPE.bankCashRecord", "") // GameM.httpM.sendDatas(HTTP_TYPE.backIsOpenRichBank, {}) // // UiM.Instance.guideNode.getComponent(Guide).bankGuideStep1(); // // to do // // GuideManager.Instance.createFullGuide(cc.find("Canvas"), 3, () => { // // UiM.Instance.guideNode.getComponent(Guide).showTreasureStep1(); // // }) // } // } else if (GameM.commonData.maxCarLevel == GameM.commonData.taskOpenLevel) { setColor = true // UiM.Instance.guideNode.getComponent(Guide).showTask1(); } else { //显示界面 UiM.Instance.displayPanel(); } if (setColor) { UiM.Instance.setPanelCool() UiM.Instance.hallNode.getComponent(Main).setUnlockBtnColor() } //西游 //若解锁新车不进入该界面 getNewCar 此处不会被执行 //第一次合成战斗判断 FightData.Ins.CheckComposeFight(); } //双倍奖励 黄色按钮 clickGetCarDouble() { GameM.audioM.playEffect(AUDIO_TYPE.button) GameM.adM.watchVideo(VIDEO_TYPE.newCarAward) } clickGetTreasureCard() { GameM.audioM.playEffect(AUDIO_TYPE.button) if (GameM.commonData.isVideoTest) { UiM.Instance.giftNode.getComponent(Gift).onGetTicketAdEnd() } else { GameM.adM.watchVideo(VIDEO_TYPE.getTicket) } } onGetTicketAdEnd() { LogUtil.logV(" onGetTicketAdEndt", "start") GameM.commonData.roleData.ticket++ GameM.commonData.updateRoleData() GameM.commonData.updateGold(this.num) GameM.commonData.updateClickVideoTimes() let str = Sciencen_M.instance.format(this.num) EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)); EffectNode.instance.PlayTip(`获得金币${str},夺宝券+1`) UiM.Instance.treasureNode.getComponent(Treasure).onGetTicketAdEnd() this.node.active = false } onGetCarDoubleWatchEnd() { this.btnCarGet.active = true this.btnCarDouble.active = false this.btnCarSingle.active = false this.num = Sciencen_M.instance.addition(this.num, this.num) this.labCarNum.string = this.num if (GameM.commonData.redSwitch) { this.labCarMoney.string = `可兑换${(Number(this.num) * 0.0001).toFixed(2)}元` } else { this.labCarMoney.string = '' } cc.tween(this.labCarNum.node) .delay(0.3) .to(0.2, { scale: 1.5 }) .to(0.2, { scale: 1 }) .start() } //领取奖励 黄色按钮 双倍奖励广告后 出现 clickCarGet() { GameM.audioM.playEffect(AUDIO_TYPE.button) GameM.commonData.updateRedMoney(Number(this.num), RecordTYPE.carLevelup) GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) EffectNode.instance.PlayCoinAnim(1, 20, cc.v2(0, -300)); this.node.active = false console.log("----> clickCarGet") this.checkShowGuide() UiM.Instance.hallNode.getComponent(Main).playCarProEff() } clickBg() { if (this.type == MONEY_TYPE.offlineGold) { GameM.commonData.updateGold(this.num) GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)); this.node.active = false } else if (this.type == MONEY_TYPE.gold) { if (this.adType == VIDEO_TYPE.buyCarMainBtn || this.adType == VIDEO_TYPE.shopBuyCarBtn) { this.adType = null 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) EffectNode.instance.PlayTip(`今日剩余次数:${GameM.commonData.dayBuyCarVideoLimitTimes}`) } } //显示界面 UiM.Instance.displayPanel(); } clickBgClose() { //车辆升级 解锁新车时 无效 if (this.type == MONEY_TYPE.carLvUp || this.type == MONEY_TYPE.getNewCar) { return } this.clickClose() } //关闭按钮 clickClose() { // // test // this.checkShowGuide() LogUtil.logV("gift", "clickClose") GameM.audioM.playEffect(AUDIO_TYPE.button) if (this.type == MONEY_TYPE.offlineGold) { GameM.commonData.updateGold(this.num) GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)); if (DailyData.Instance.checkHasGet() && GameM.commonData.maxCarLevel >= GameM.commonData.loginRewardOpenLevel) { UiM.Instance.onPanel(PANEL_NAME.DailyNode) } else { if (GameM.commonData.loginDays >= 2) { UiM.Instance.hallNode.getComponent(Main).checkShowClubGuideNode() } } } if (this.turntable) { UiM.Instance.turntableNode.getComponent(Turntable).updateCurrentNum() this.clickGetGold() } else if (this.type == MONEY_TYPE.gold) { if (!this.isVideo) { if (this.isAirship) { GameM.commonData.updateAirShipTimes() } GameM.commonData.updateGold(this.num) GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)); } if (this.carSp != null) { let s = this.carSp.getComponent(CarSpace) s.changeType(0) GameM.commonData.updateBagCarData(s.index.toString(), 0) this.scheduleOnce(() => { UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece() }, 0.1) } if (this.adType == VIDEO_TYPE.buyCarMainBtn || this.adType == VIDEO_TYPE.shopBuyCarBtn) { this.adType = null 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) EffectNode.instance.PlayTip(`今日剩余次数:${GameM.commonData.dayBuyCarVideoLimitTimes}`) } } else if (this.type == MONEY_TYPE.popVideo) { GameM.commonData.hasPopVideo = false } else if (this.type == MONEY_TYPE.getNewCar) { //若新车解锁 不进入该界面 则该处不会被执行到 console.log("----> clickClose") this.checkShowGuide() this.node.active = false UiM.Instance.hallNode.getComponent(Main).playCarProEff() return } else if (this.type == MONEY_TYPE.treasureTicket) { LogUtil.logV("gift", "MONEY_TYPE.treasureTicket one") // GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) // EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)); } else if (this.type == MONEY_TYPE.clearCooltime) { LogUtil.logV("gift", "MONEY_TYPE.clearCooltime one") if (this.clearCloseNode.active == false) { return } } else if (this.type == MONEY_TYPE.mainBuyCarGold) { // //引导取经 大富翁 // if (RichData.Ins.richCfg.richmanopen == 1) { // let hasGuide = PlayerPrefs.GetInt("GGuide20", 0) == 1 // if (!hasGuide) { // GuideMng.Ins.CheckRichGuide20(); // } // else { // this.ifPopCoinTipNode() // } // } // else { // this.ifPopCoinTipNode() // } this.ifPopCoinTipNode() } this.node.active = false //显示界面 UiM.Instance.displayPanel(); } ifPopCoinTipNode() { let hasShow = GlobalStorage.Instance.getStorage(STORAGE_KEY.CoinTipTotay, 0) if (!hasShow) { UiM.Instance.onPanel(PANEL_NAME.CoinTipNode) GlobalStorage.Instance.setStorage(STORAGE_KEY.CoinTipTotay, 1, 0) } } // update (dt) {} clickOfflineSingle() { GameM.commonData.updateGold(this.num) GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)) this.node.active = false //显示界面 UiM.Instance.displayPanel(); } clickPopVideo() { GameM.audioM.playEffect(AUDIO_TYPE.button) // if (GameM.commonData.roleData.hangVideoFree == 0) { // GameM.commonData.updateHangVideoFree() // GameM.commonData.updateGold(this.num) // this.node.active = false // GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) // EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)); // GameM.commonData.hasPopVideo = false // } // else { // let percent = 1 / (1 + Math.max(0, GameM.commonData.roleData.hangupVideoTimes * 0.4 - 2)) // 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 GameM.commonData.hasTouch = true if (GameM.commonData.isVideoTest) { UiM.Instance.hallNode.getComponent(Main).onHangUpAdEnd() } else { GameM.adM.watchVideo(VIDEO_TYPE.hangUp) } // } } /** 放弃热气球 */ clickDropAirShip() { GameM.audioM.playEffect(AUDIO_TYPE.button) this.node.active = false UiM.Instance.hallNode.getComponent(Main).dropAirShip() } /** 工厂过热冷却时间减半 */ clickFacReduceTime() { GameM.audioM.playEffect(AUDIO_TYPE.button) this.node.active = false UiM.Instance.onPanel(PANEL_NAME.NativeAdAwardNode, false, () => { UiM.Instance.nativeAdAwardNode.getComponent(NativeADAwardNode).init(1) }) } changeAir = false /** 换一个热气球奖励 */ clickChangeAirShip() { GameM.audioM.playEffect(AUDIO_TYPE.button) this.changeAir = true this.node.active = false UiM.Instance.onPanel(PANEL_NAME.NativeAdAwardNode, false, () => { UiM.Instance.nativeAdAwardNode.getComponent(NativeADAwardNode).init(2) }) } /** 车位金币普通领取 */ clickGet() { let s = this.carSp.getComponent(CarSpace) s.changeType(0) GameM.commonData.updateBagCarData(s.index.toString(), 0) this.scheduleOnce(() => { UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece() }, 0.1) this.node.active = false GameM.commonData.updateGold(this.num) GameM.audioM.playEffect(AUDIO_TYPE.getGold, false) EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300)); } cool = false clickBanner() { GameM.audioM.playEffect(AUDIO_TYPE.button) if (this.cool) { return } this.cool = true this.scheduleOnce(() => { this.cool = false }, 3) MoreGameData.Instance.createNewTask(this.streamData) } }