var battlenet = require('battlenetmanage'); var SDKManage = require('SDKManage'); cc.Class({ extends: cc.Component, properties: { nd_mvp: { default: null, type: cc.Node, }, nd_sNode: { default: null, type: cc.Node, }, lb_gzname: { default: null, type: cc.Label, }, sp_bg: { default: null, type: cc.Node, }, nd_watch: { default: null, type: cc.Node, }, btn_watch: { default: null, type: cc.Node, }, nd_win: { default: null, type: cc.Node, }, nd_lose: { default: null, type: cc.Node, }, nd_jiesuan: { default: null, type: cc.Node, }, lb_rank: { default: null, type: cc.Label, }, lb_killcount: { default: null, type: cc.Label, }, lb_killcount2: { default: null, type: cc.Label, }, lb_dmg: { default: null, type: cc.Label, }, spine_hero: { default: null, type: sp.Skeleton, }, listnode: { default: null, type: cc.Node, }, lb_des: { default: null, type: cc.Label, }, nd_team: { default: null, type: cc.Node, }, heroName:{ default:null, type:cc.Label }, gunt1Name:{ default:null, type:cc.Label }, gunt2Name:{ default:null, type:cc.Label }, hero_reward:{ default:null, type:cc.Label }, gun1_reward:{ default:null, type:cc.Label }, gun2_reward:{ default:null, type:cc.Label }, total_reward:{ default:null, type:cc.Label } }, // LIFE-CYCLE CALLBACKS: // onLoad () {}, onDestroy() { cc.Notifier.off('onWatchWar', this); }, start() { cc.Notifier.on('onWatchWar', this, this.onWatchWar.bind(this)); }, onWatchWar(res) { this.lb_gzname.string = res.name; this.sp_bg.active = false; this.nd_watch.active = true; this.btn_watch.active = false; cc.gameMgr.uic.hidenode.active = false; cc.gameMgr.uic.shownode.active = false; }, initData() {}, dogameover(res) { if (res.game_over) { this.btnNext(); } console.log('SecondResult======', res); }, setdata(res, itemarr, teamarr, iskillself) { console.log(`gameover res---${JSON.stringify(res)}`); this.rankmun = res.team_rank; this.nd_win.active = false; this.nd_lose.active = false; this.nd_watch.active = false; if (res.watchable) { this.btn_watch.active = true; } else { this.btn_watch.active = false; } if (res.victory) { //玩家胜利 this.nd_win.active = true; } else { this.nd_lose.active = true; } this.nd_jiesuan.active = false; this.showplayerinfo(res.player_stats); this.lb_rank.string = res.team_rank; }, refreshself(v) { console.log(`game over data-----${v}`) this.lb_killcount.string = v.kills; this.lb_killcount2.string = v.kills; this.lb_dmg.string = v.damage_amount; var skinres = cc.skinid; // v.skin[0].skin_id cc.loader.loadRes( 'spine/heropic/pic_hero' + skinres, sp.SkeletonData, function (err, sp) { this.spine_hero.skeletonData = sp; this.spine_hero._updateSkeletonData(); this.spine_hero.setAnimation(0, 'animation', true); }.bind(this) ); this.lb_des.string = this.getTitleDesc(this.rankmun, v.kills); // infos // hero if(v.hero_stats){ this.heroName.string = v.hero_stats.hero_name; this.hero_reward = v.hero_stats.reward_ceg; } // weapons if(v.weapons_stats){ if(v.weapons_stats[0]){ //gun1 } if(v.weapons_stats[1]){ //gun2 } } }, showplayerinfo(v) { for (var i = 0; i < 4; i++) { var nd = this.listnode.getChildByName('item' + i); if (i < v.length) { nd.active = true; nd.getChildByName('name').getComponent(cc.Label).string = v[i].nickname; nd.getChildByName('killer').getComponent(cc.Label).string = v[i].kills; nd.getChildByName('dps').getComponent(cc.Label).string = v[i].damage_amount; nd.getChildByName('time').getComponent(cc.Label).string = Math.floor(v[i].time_alive / 1000) + 's'; nd.getChildByName('addhp').getComponent(cc.Label).string = v[i].heal_amount; if (v[i].account_id == SDKManage.account_id) { this.refreshself(v[i]); nd.getChildByName('btn_good').active = false; } } else { nd.active = false; } } }, getTitleDesc(_rankN, _killNum) { let str = 'Winner winner, chicken dinner'; if (_rankN == 1) { str = 'Winner winner, chicken dinner'; this.nd_sNode.active = true; this.nd_mvp.active = true; } else { if (_killNum >= 0 && _killNum <= 3) { str = "I swear I'll never fall into a box again!"; } else if (_killNum >= 4 && _killNum <= 7) { str = 'Pity! The next game will definitely win!'; } else { str = 'One step away from win!'; } } return str; }, callteaminfo() { this.nd_team.x = -512; this.nd_team.stopAllActions(); this.nd_team.runAction(cc.moveTo(0.3, cc.v2(512, 0))); }, hideteaminfo() { this.nd_team.x = 512; this.nd_team.stopAllActions(); this.nd_team.runAction(cc.moveTo(0.3, cc.v2(-512, 0))); }, // showViewTips(_allTeamPlayer) //是否显示观战tips 队友仍在战斗 快来观战 // { // let num = 0; // let teamNum = _allTeamPlayer.length; // for (let i = 0; i < teamNum; i++) { // if (!_allTeamPlayer[i].dead) { // num++; // } // } // let tipsNode = this.m_loseNode.getChildByName("tips_team"); // if (num > 0) { // tipsNode.active = true; // } // }, // updateLeftPlayer(_num) { // let leftPlayerNode = this.m_loseNode.getChildByName("leftPlayerNum"); // let leftPlayerCom = leftPlayerNode.getComponent(cc.Label); // leftPlayerCom.string = "当前仍在场" + _num + "人"; // }, btnConfirm() { //立即结算 this.node.active = false; }, btnNext() { //下一步 this.nd_jiesuan.active = true; // 退出语音房间 if (cc.sys.os == cc.sys.OS_ANDROID) { jsb.reflection.callStaticMethod( 'org/cocos2dx/javascript/AppActivity', 'leaveRoom', '()V' ); } else if (cc.sys.os == cc.sys.OS_IOS) { jsb.reflection.callStaticMethod('AppController', 'leaveRoom'); } }, btnView() { //观战 battlenet.sendWatch(); }, test() { cc.director.loadScene('test'); }, onclickover() { cc.director.loadScene('MainScene'); cc.Notifier.emit("refreshBaseInfo"); }, // update (dt) {}, });