// 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 CashOutData from "../datas/CashOutData"; import { HTTP_TYPE } from "../datas/CommonData"; import { FightData, FightRole } from "../datas/FightData"; import AdM from "../manager/AdM"; import { GameController } from "../manager/GameController"; import GameM, { AUDIO_TYPE } from "../manager/GameM"; import GuideMng from "../manager/GuideMng"; import HttpM from "../manager/HttpM"; import BasePanel from "../uiFrames/BasePanel"; import UIMng, { PanelType } from "../uiFrames/UIMng"; import LogUtil from "../utils/LogUtil"; import Random from "../utils/Random"; import { Utils } from "../utils/Utils"; const { ccclass, property } = cc._decorator; @ccclass export default class FightRoleBPanel extends BasePanel { //武将战斗触发选择界面 @property(cc.Node) panelNode: cc.Node = null; @property(cc.Node) title_new: cc.Node = null; @property(cc.Node) title_old: cc.Node = null; @property(cc.Sprite) roleImg: cc.Sprite = null; @property(cc.Label) txtName: cc.Label = null; @property(cc.Node) rewards: cc.Node = null; @property(cc.Label) rewardTxt: cc.Label = null; //@property(cc.Widget) //widget: cc.Widget = null; //private roleNum = 0; private fightRole: FightRole = null; private curRole: any = null; private curRoleSer: any = null; private curRoleLv: number = 1; //private isInit: boolean = false; OnEnter(param: any) { this.Init(param); this.panelNode.scale = 0; this.node.active = true; cc.tween(this.panelNode).to(0.2, { scale: 1 }, { easing: "backOut" }) .call(() => { //this.widget.updateAlignment(); if (this.fightRole.fightType == 1) GuideMng.Ins.CheckFightGuide4(); }) .start(); this.node.setSiblingIndex(this.node.parent.childrenCount - 1); if (this.fightRole.fightType == 1) { // AdM.onSendEvent(`fight_new_open_${this.fightRole.lv}`, `${this.fightRole.name}`, 'fight_new_open') } } OnExit() { this.roleImg.spriteFrame = null; this.node.active = false; } Init(param: any) { this.fightRole = param; this.roleImg.node.scale = 0.8; this.UpdateRoleInfo(); } UpdateRoleInfo() { //console.log("FightRoleCount: " + FightData.Ins.composeFightRoles.length); this.curRoleLv = this.fightRole.lv; this.title_new.active = this.fightRole.fightType == 1; this.title_old.active = this.fightRole.fightType == 2 || this.fightRole.fightType == 3; this.rewards.active = this.fightRole.fightType == 1; this.curRole = GameM.commonData.fightRoleCfg[this.curRoleLv.toString()]; cc.loader.loadRes('carPic/side/side_' + this.curRoleLv, cc.SpriteFrame, (err, asset) => { this.roleImg.spriteFrame = asset; }); this.txtName.string = "Lv" + this.curRoleLv + this.fightRole.name; //this.txtLv.string = "Lv" + this.curRoleLv; let cfg = CashOutData.Instance.cashCft; let len = cfg.length; for (var i = 0; i < len; i++) { if (cfg[i].type_value == this.curRoleLv) { this.rewardTxt.string = cfg[i].moneyshow.split('~')[1]; break; } } } async Click_ChallengeBtn() { console.log("fight type:" + this.fightRole.fightType + " buff bag id:" + this.curRole.buffbag_id + " buff id:" + this.fightRole.buffId); //let tempDate = new Date(); //let startTime = tempDate.getTime(); //let totalMin = 0; let cfg = GameM.commonData.fightRoleCfg[this.curRoleLv.toString()]; FightData.Ins.flawTimes = cfg.flawclicktimes; FightData.Ins.flawDuration = cfg.flawduration; FightData.Ins.flawRate = cfg.flawrate; FightData.Ins.flawNum = cfg.flawnum; await Utils.loadResPromise('prefabs/TransitNode') GameController.Ins.PlayTransitAniForHttp(); //判断战斗类型 12为请求战斗 3 为大富翁触发战斗(大富翁战斗不需要请求服务器) if (this.fightRole.fightType == 3) { GameController.Ins.PlayCloseTransitAniForHttp(() => { this.fightRole.fightId = ""; this.OnExit(); UIMng.Ins.AsyncGetPanel(PanelType.FightPanel, (panel) => { panel.OnEnter(this.fightRole); }); //UIMng.Ins.GetPanel(PanelType.FightPanel).OnEnter(this.fightRole); }); } else { HttpM.Instance.SendData(HTTP_TYPE.beginBattle, { battleType: this.fightRole.fightType, bossCode: this.curRoleLv.toString(), version: GameM.commonData.version }, (res) => { LogUtil.logV("-->BeginBattle:", JSON.stringify(res)); //console.log("-->BeginBattle:"+JSON.stringify(res)) //totalMin = ((new Date()).getTime() - startTime) / 1000; //console.log("---->BeginTime:" + totalMin); if (res.data != null) { GameController.Ins.PlayCloseTransitAniForHttp(() => { this.fightRole.fightId = res.data; this.OnExit(); UIMng.Ins.AsyncGetPanel(PanelType.FightPanel, (panel) => { panel.OnEnter(this.fightRole); }); //UIMng.Ins.GetPanel(PanelType.FightPanel).OnEnter(this.fightRole); }); } }); } GameM.audioM.playEffect(AUDIO_TYPE.button); } Click_CloseBtn() { this.OnExit(); GameM.audioM.playEffect(AUDIO_TYPE.button); } }