pubgv3/assets/scripts/game/GameOverUINew.js
guoqing.zhu d88f2ebe56 update
2022-05-30 13:02:41 +08:00

356 lines
7.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
},
// 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
}
},
// 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) {
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.hero_bar.node.active = true;
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;
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.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;
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.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[0].ceg_uplimit;
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)));
},
// 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) {},
});