pubgv3/assets/scripts/game/GameOverUINew.js
2022-05-26 11:46:36 +08:00

240 lines
5.5 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.

// Learn cc.Class:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
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,
},
},
// 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);
},
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) {},
});