// 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 AdM from "../manager/AdM"; import GameM, { VIDEO_TYPE, AUDIO_TYPE } from "../manager/GameM"; import UiM, { PANEL_NAME } from "../manager/UiM"; import EffectNode from "./EffectNode"; import TaskItem from "../prefabs/TaskItem"; import { RecordTYPE } from "../datas/CommonData"; import Sciencen_M from "../utils/Sciencen_M"; import Main from "../Main"; import SwitchM from "../manager/SwitchM"; import CashOutData from "../datas/CashOutData"; const { ccclass, property } = cc._decorator; @ccclass export default class RewardNode extends cc.Component { @property(cc.Node) btn_close: cc.Node = null; @property(cc.Node) par: cc.Node = null; @property(cc.Node) redNumNode: cc.Node = null; @property(cc.Label) redMoneyTxt: cc.Label = null; @property(cc.Node) goldNumNode: cc.Node = null; @property(cc.Label) goldTxt: cc.Label = null; @property(cc.Label) myRedTxt: cc.Label = null; @property(cc.Label) myMoneyTxt: cc.Label = null; //任务与成就领取 @property(cc.Node) taskNode: cc.Node = null; @property(cc.Node) taskSingleBtn: cc.Node = null; //账号等级提升奖励 @property(cc.Node) userLvUpNode: cc.Node = null; @property(cc.Label) userLvTxt: cc.Label = null; @property(cc.Node) userLvUpSingleBtn: cc.Node = null; @property(cc.Node) lyRedMoney: cc.Node = null; taskItem: TaskItem; start() { } onEnable() { GameM.audioM.playEffect(AUDIO_TYPE.open_interface) AdM.destroyNative() } onClickBtnClose() { if (this.userLvUpNode.active) { AdM.createInter(10) } this.userLvUpNode.active = false; this.taskNode.active = false; this.node.active = false this.redNumNode.active = false; this.goldNumNode.active = false; //显示界面 UiM.Instance.displayPanel(); } onEnter() { this.myRedTxt.string = GameM.commonData.redMoney.toString(); if (GameM.commonData.redSwitch) { this.myMoneyTxt.string = '≈' + (GameM.commonData.redMoney * 0.0001).toFixed(3) + '元'; } else { this.myMoneyTxt.string = '' } this.lyRedMoney.active = GameM.commonData.redSwitch } //账号等级提升奖励 EnterUserLvUpPanel() { this.btn_close.active = false; this.taskNode.active = false; this.node.active = true this.node.x = 0 this.par.scale = 0; cc.tween(this.par).to(0.3, { scale: 1 }, { easing: "backOut" }).start(); this.userLvUpNode.active = false; this.redNumNode.active = true; this.goldNumNode.active = false; this.redMoneyTxt.string = Sciencen_M.instance.format(GameM.commonData.roleCft[GameM.commonData.roleData.lv - 1].reward_num.toString()); this.onEnter(); this.userLvUpNode.active = true; this.userLvTxt.string = GameM.commonData.roleData.lv.toString(); this.userLvUpSingleBtn.active = false; this.unschedule(this.userTweenCall) let delayTime = 0 if (SwitchM.forceMakeMoney) { delayTime = 2 } this.scheduleOnce(this.userTweenCall, delayTime) } userTweenCall() { this.userLvUpSingleBtn.active = true; this.userLvUpSingleBtn.opacity = 0; cc.tween(this.userLvUpSingleBtn).to(0.5, { opacity: 255 }).start(); } ExitUserLvUpPanel() { this.onClickBtnClose(); this.unschedule(this.userTweenCall); if (GameM.commonData.roleData.lv == CashOutData.Instance.cashCft[0].type_value) { UiM.Instance.hallNode.getComponent(Main).checkNewUser() } } //任务 成就领取 EnterTaskPanel(taskItem: TaskItem) { this.taskItem = taskItem; this.btn_close.active = false; this.userLvUpNode.active = false; this.node.x = 0 this.node.active = true this.par.scale = 0; cc.tween(this.par).to(0.3, { scale: 1 }, { easing: "backOut" }).start(); this.redNumNode.active = true; this.goldNumNode.active = false; this.redMoneyTxt.string = Sciencen_M.instance.format(taskItem.data.rewadr_num.toString()); this.onEnter(); this.taskNode.active = true; this.taskSingleBtn.active = false; let delayTime = 0 if (SwitchM.forceMakeMoney) { delayTime = 2 } this.scheduleOnce(this.taskTweenCall, delayTime) } taskTweenCall() { this.taskSingleBtn.active = true; this.taskSingleBtn.opacity = 0; cc.tween(this.taskSingleBtn).to(0.5, { opacity: 255 }).start(); } ExitTaskPanel() { this.onClickBtnClose(); this.unschedule(this.taskTweenCall); } //-------------------用户等级提升 BtnAdUserlvUpClick() { AdM.Instance.watchVideo(VIDEO_TYPE.userLvUpAd); } BtnAdUserLvUpEnd() { GameM.commonData.updateRedMoney(Number(GameM.commonData.roleCft[GameM.commonData.roleData.lv - 1].reward_num) + 300, RecordTYPE.roleLevelup); EffectNode.instance.PlayCoinAnim(1, 20, cc.v2(0, -300)); this.ExitUserLvUpPanel(); EffectNode.instance.PlayTip("感谢您的观看,额外奖励已发放"); } BtnSingleUserLvUpClick() { GameM.commonData.updateRedMoney(Number(GameM.commonData.roleCft[GameM.commonData.roleData.lv - 1].reward_num), RecordTYPE.roleLevelup); EffectNode.instance.PlayCoinAnim(1, 20, cc.v2(0, -300)); this.ExitUserLvUpPanel(); } //--------------------任务 成就 BtnAdTaskClick() { AdM.Instance.watchVideo(VIDEO_TYPE.taskRwardAd); } BtnAdTaskEnd() { this.taskItem.AdGet(); this.onClickBtnClose(); } BtnSingleTaskClick() { this.taskItem.Get(); this.onClickBtnClose(); } }