312 lines
10 KiB
JavaScript
312 lines
10 KiB
JavaScript
const ArenaConst = require( "arena_const" );
|
|
const ArenaEvent = require( "arena_event" );
|
|
const MenuPage = require( "cmp.com.menu.page" );
|
|
const CrossChampionController = require("crosschampion_controller");
|
|
const HeroController = require( "hero_controller" );
|
|
const ItemLay = require("cmp.common.itemlayout");
|
|
const data2Icon = require( "bridge.utils.item" );
|
|
const BattleController = require( "battle_controller" );
|
|
|
|
|
|
|
|
cc.Class({
|
|
|
|
extends: MenuPage,
|
|
|
|
|
|
properties: {
|
|
|
|
nodRace: { default: null, type: cc.Node },
|
|
nodEmpty: { default: null, type: cc.Node },
|
|
nodLeft: { default: null, type: cc.Node },
|
|
nodRight: { default: null, type: cc.Node },
|
|
nodLeftParts : { default: null, type: ItemLay },
|
|
nodRightParts : { default: null, type: ItemLay },
|
|
nodLeftCamp: { default: null, type: cc.Sprite },
|
|
nodRightCamp: { default: null, type: cc.Sprite },
|
|
nodStageTime: { default: null, type: cc.Node },
|
|
nodReplay: { default: null, type: cc.Node },
|
|
},
|
|
|
|
onLoad: function(){
|
|
|
|
this.bindGEvent( ArenaEvent.UpdateMyMatchInfoEvent, this.freshInfo.bind( this ) );
|
|
// this.bindGEvent( ArenaEvent.UpdateChampionBaseInfoEvent, this.freshMyRace.bind( this ));
|
|
nx.gui.setActive( this.nodEmpty, "", false );
|
|
nx.gui.setActive( this.nodRace, "", false );
|
|
},
|
|
|
|
onEnable: function() {
|
|
|
|
|
|
// 视图监听
|
|
this.vbind( [
|
|
[ "CChampion", this.freshMyRace.bind( this ) ]
|
|
] );
|
|
|
|
|
|
|
|
// this.nodMenus.posTog = this.onTogMenu.bind( this );
|
|
|
|
this.setEmpty();
|
|
|
|
},
|
|
|
|
// 隐藏
|
|
onDisable: function() {
|
|
|
|
// 视图监听解除
|
|
this.vunbind();
|
|
// 事件监听释放
|
|
// this.unbindGEvents();
|
|
nx.gui.setActive( this.nodEmpty, "", false );
|
|
// nx.gui.setActive( this.nodRace, "", false );
|
|
},
|
|
|
|
// 重载:关闭前
|
|
onPreClosed: function () {
|
|
|
|
},
|
|
|
|
|
|
freshMyRace: function( _race ){
|
|
|
|
if( !_race ){
|
|
return;
|
|
}
|
|
let baseInfo = _race;
|
|
|
|
this.stepinfo = baseInfo;
|
|
let desc = "";
|
|
let show = baseInfo.step == ArenaConst.champion_step.unopened ;
|
|
if( show ){
|
|
desc = nx.text.getKey( "champion_str34" ); // 冠軍賽未開啓
|
|
|
|
}
|
|
|
|
let rdesc = nx.text.getKey( "champion_str" + ( 18 + baseInfo.round_status ) );
|
|
nx.gui.setString( this.nodStageTime, "stage", rdesc );
|
|
nx.gui.setActive( this.nodEmpty, "bg/stime", true );
|
|
nx.gui.setString( this.nodEmpty, "bg/state", desc );
|
|
let nod = nx.gui.find( this.nodEmpty, "bg" );
|
|
|
|
if( ( baseInfo.start_time - Math.floor( cc.sys.now() / 1000 ) ) >= 0 ){
|
|
nx.gui.setCdTxt( nod, "stime/time", ( baseInfo.start_time - Math.floor( cc.sys.now() / 1000 ) ), ()=>{
|
|
nx.gui.setActive( nod, "stime", false );
|
|
} );
|
|
}
|
|
|
|
|
|
|
|
nx.gui.setActive( this.nodStageTime, "", baseInfo.step_status != ArenaConst.champion_step_status.over );
|
|
|
|
if( baseInfo.round_status == ArenaConst.champion_round_status.fight ){
|
|
CrossChampionController.getInstance().sender26202();
|
|
nx.gui.setCdTxt( this.nodStageTime, "txt", baseInfo.round_status_time, ()=>{
|
|
|
|
} );
|
|
}else{
|
|
nx.gui.setCdTxt( this.nodStageTime, "txt", baseInfo.round_status_time, ()=>{
|
|
CrossChampionController.getInstance().sender26202();
|
|
} );
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
setEmpty: function(){
|
|
|
|
|
|
let cct = CrossChampionController.getInstance();
|
|
|
|
cct.sender26200();
|
|
cct.sender26202();
|
|
|
|
},
|
|
|
|
|
|
// 根据位置获取敌方英雄数据
|
|
getRoleDataByIndex:function( index, role_list ){
|
|
for (var k in role_list) {
|
|
var v = role_list[k]
|
|
if (v.pos == index) {
|
|
return v
|
|
}
|
|
}
|
|
},
|
|
|
|
|
|
dealPartners: function( _ctype, _plst, _left ){
|
|
|
|
let formation_config = gdata("formation_data","data_form_data", _ctype );
|
|
let partner_ids = [];
|
|
let role_datas = [];
|
|
for (var i = 1; i <= 9;i++) {
|
|
let role_data =null;
|
|
let key = null;
|
|
//阵法和实际位置的映射转换
|
|
for(let j=0;j<formation_config.pos.length;j++){
|
|
let pos_val = formation_config.pos[j];
|
|
if(pos_val[1] == i){
|
|
key = pos_val[0];
|
|
}
|
|
}
|
|
let role_info = this.getRoleDataByIndex( key, _plst );
|
|
|
|
//位置上没有英雄就选择置空
|
|
let role_vo = null;
|
|
|
|
|
|
|
|
if (role_info) {
|
|
if( _left ){
|
|
role_data = HeroController.getInstance().getModel().getHeroInfoByBidStar(role_info.bid, role_info.star);
|
|
partner_ids.push(role_data);
|
|
role_vo = role_data;
|
|
}else{
|
|
role_info.is_master = true;
|
|
role_info.rid = role_info.rid || 0;
|
|
role_info.srv_id = role_info.srv_id || "";
|
|
role_vo = this.createHeroVo(role_info);
|
|
}
|
|
|
|
}
|
|
role_datas.push(role_vo);
|
|
|
|
}
|
|
return role_datas;
|
|
},
|
|
|
|
createHeroVo(role_data){
|
|
|
|
role_data.updateHeroVo = ""
|
|
let vof = data2Icon.data2Icon( role_data.bid );
|
|
vof.level = role_data.lev;
|
|
vof.stars = role_data.star;
|
|
let vo = data2Icon.data2Icon( vof );
|
|
|
|
return vo;
|
|
},
|
|
|
|
|
|
// 待定 使用綁定值或者 傳入相關數據的方法
|
|
freshInfo: function( _guessdata ){
|
|
|
|
let guessinfo = _guessdata;
|
|
if( guessinfo.step != 0 ){
|
|
let acamptype = guessinfo.a_formation_type; // 陣型顯示
|
|
let bcamptype = guessinfo.b_formation_type; // 陣型顯示
|
|
let ap_list = guessinfo.a_plist; // 夥伴列表
|
|
let bp_list = guessinfo.b_plist; // 夥伴列表
|
|
let aframe = guessinfo.a_avatar_id == 0 ? 1000 : guessinfo.a_avatar_id; // 頭像框
|
|
let bframe = guessinfo.b_avatar_id == 0 ? 1000 : guessinfo.b_avatar_id; // 頭像框
|
|
let apower = guessinfo.a_power; // 戰力
|
|
let bpower = guessinfo.b_power; // 戰力
|
|
|
|
let path = "prefab/pvp/ui";
|
|
|
|
let aformation_config = gdata("formation_data","data_form_data", acamptype );
|
|
let apaht = cc.path.join( path, "teamform_" + aformation_config.order );
|
|
|
|
nx.gui.setSpriteFrame( this.nodLeftCamp, "", apaht );
|
|
|
|
|
|
let cmp = nx.gui.getComponent( this.nodLeft, "bg/info/avatar", "cmp.common.header" );
|
|
if( cmp ){
|
|
cmp.setHeadRes( guessinfo.a_face );
|
|
cmp.setFrameRes( aframe );
|
|
}
|
|
nx.gui.setString( this.nodLeft, "bg/info/power", apower );
|
|
nx.gui.setString( this.nodLeft, "bg/info/lev", nx.text.format( "LvNumber", guessinfo.a_lev ) );
|
|
nx.gui.setString( this.nodLeft, "bg/info/nbg/server", guessinfo.a_srv_id );
|
|
nx.gui.setString( this.nodLeft, "bg/info/nbg/name", guessinfo.a_name );
|
|
let arole = this.dealPartners( acamptype, ap_list, true );
|
|
|
|
if( this.nodLeftParts ){
|
|
this.nodLeftParts.rebuild( arole );
|
|
}
|
|
|
|
let bformation_config = gdata("formation_data","data_form_data", bcamptype );
|
|
|
|
let bpaht = cc.path.join( path, "teamform_" + bformation_config.order );
|
|
|
|
nx.gui.setSpriteFrame( this.nodRightCamp, "", bpaht );
|
|
|
|
|
|
// nx.gui.setSpriteFrame( this.nodRight, "bg/info/ctype", cc.path.join( path, "teamform_" + bcamptype ) );
|
|
let bcmp = nx.gui.getComponent( this.nodRight, "bg/info/avatar", "cmp.common.header" );
|
|
if( bcmp ){
|
|
bcmp.setHeadRes( guessinfo.b_face );
|
|
bcmp.setFrameRes( bframe );
|
|
}
|
|
nx.gui.setString( this.nodRight, "bg/info/power", bpower );
|
|
nx.gui.setString( this.nodRight, "bg/info/lev", nx.text.format( "LvNumber", guessinfo.b_lev ) );
|
|
nx.gui.setString( this.nodRight, "bg/info/name", guessinfo.b_name );
|
|
|
|
let sprites = nx.gui.find( this.nodLeft, "wings" );
|
|
this.freshRp( bcamptype, bp_list );
|
|
for ( let i = 0; i < guessinfo.a_sprites.length; i++ ) {
|
|
let sprite = guessinfo.a_sprites[i];
|
|
if( sprite ){
|
|
let sid = sprite.item_bid;
|
|
if( sid > 0 ){
|
|
let nod = sprites.children[i];
|
|
let ifg = gdata( "item_data","data_unit9", sid );
|
|
nx.bridge.setIcon( nod, "icon", ifg.imageid );
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
this.race = _guessdata;
|
|
let desc = nx.text.getKey( "champion_str35" );
|
|
if( this.stepinfo.step == ArenaConst.champion_step.unopened ){
|
|
nx.gui.setActive( this.nodEmpty, "bg/stime", true );
|
|
}else{
|
|
nx.gui.setActive( this.nodEmpty, "bg/stime", false );
|
|
nx.gui.setString( this.nodEmpty, "bg/state", desc );
|
|
}
|
|
|
|
|
|
nx.gui.setActive( this.nodRace, "", guessinfo.step != 0 ); // 顯示對戰相關數據
|
|
nx.gui.setActive( this.nodEmpty, "", guessinfo.step == 0 || this.stepinfo.step == ArenaConst.champion_step.unopened );
|
|
nx.gui.setActive( this.nodReplay, "", guessinfo.replay_id != 0 );
|
|
if( this.stepinfo.step_status == ArenaConst.champion_step_status.over ){
|
|
|
|
nx.gui.setActive( this.nodLeft, "ico", guessinfo.ret == 1 );
|
|
nx.gui.setActive( this.nodRight, "ico", guessinfo.ret == 2 );
|
|
}
|
|
|
|
if( this.race.replay_id != 0 && this.stepinfo.round_status == ArenaConst.champion_round_status.fight && this.stepinfo.flag != 0 ){
|
|
this.onTouchReplay();
|
|
}
|
|
|
|
},
|
|
|
|
freshRp: function( bcamptype, bp_list ){
|
|
|
|
let brole = this.dealPartners( bcamptype, bp_list );
|
|
if( this.nodRightParts ){
|
|
this.nodRightParts.rebuild( brole );
|
|
}
|
|
},
|
|
|
|
onTouchReplay: function(){
|
|
|
|
let srv_id = nx.bridge.vget( "curServer" ).srv_id;
|
|
BattleController.getInstance().sender_20036( this.race.replay_id, srv_id );
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|