var battlenet = require('battlenetmanage'); var SDKManage = require('SDKManage'); const { type } = require('../netBattle/net/proto/bytebuffer'); 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 }, // limit hero_limit:{ default:null, type:cc.Label }, gun1_limit:{ default:null, type:cc.Label }, gun2_limit:{ default:null, type:cc.Label }, hero_bar:{ default:null, type:cc.ProgressBar }, gun1_bar:{ default:null, type:cc.ProgressBar }, gun2_bar:{ default:null, type:cc.ProgressBar }, hero_remain:{ default:null, type:cc.Label }, gun1_remain:{ default:null, type:cc.Label }, gun2_remain:{ 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(); } }, setdata(res, itemarr, teamarr, iskillself) { 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) { 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); var total = 0; // infos // hero if(v.hero_stats){ this.heroName.string = v.hero_stats.hero_name; this.hero_reward.string = v.hero_stats.reward_ceg; this.hero_bar.progress = (v.hero_stats.today_get_ceg) / v.hero_stats.ceg_uplimit; this.hero_remain.string = v.hero_stats.ceg_uplimit - (v.hero_stats.today_get_ceg) total+=parseInt(v.hero_stats.reward_ceg); } // weapons if(v.weapons_stats){ if(v.weapons_stats[0]){ //gun1 this.gun1_bar.node.active = true; this.gun1_reward.node.active = true; this.gunt1Name.node.active = true; this.gun1_remain.node.active = true; this.gunt1Name.string = v.weapons_stats[0].weapon_name; this.gun1_reward.string = v.weapons_stats[0].reward_ceg; this.gun1_bar.progress = (v.weapons_stats[0].today_get_ceg) / v.weapons_stats[0].ceg_uplimit; this.gun1_remain.string = v.weapons_stats[0].ceg_uplimit - (v.weapons_stats[0].today_get_ceg) total+=parseInt(v.weapons_stats[0].reward_ceg); } if(v.weapons_stats[1]){ //gun2 this.gun2_bar.node.active = true; this.gunt2Name.node.active = true; this.gun2_reward.node.active = true; this.gun2_remain.node.active = true; this.gunt2Name.string = v.weapons_stats[1].weapon_name; this.gun2_reward.string = v.weapons_stats[1].reward_ceg; this.gun2_bar.progress = (v.weapons_stats[1].today_get_ceg ) / v.weapons_stats[1].ceg_uplimit; this.gun2_remain.string = v.weapons_stats[1].ceg_uplimit - (v.weapons_stats[1].today_get_ceg); total+=parseInt(v.weapons_stats[1].reward_ceg); } } this.total_reward.string = total; }, 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))); }, 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'); }, // update (dt) {}, });