Files
fc/dev/project/assets/Scripts/mod/pvp/crosschampion/cmp/cmp.cchampion.race.info.js
T
2026-05-23 22:10:14 +08:00

165 lines
6.2 KiB
JavaScript

const ItemLay = require("cmp.common.itemlayout");
const HeroController = require( "hero_controller" );
const data2Icon = require( "bridge.utils.item" );
const BattleController = require( "battle_controller" );
const BridgeComponent = require( "bridge.component" );
cc.Class({
extends: BridgeComponent,
properties: {
nodLeft: { default: null, type: cc.Node },
nodRight: { default: null, type: cc.Node },
nodLParts: { default: null, type: ItemLay },
nodRParts: { default: null, type: ItemLay },
nodLCamp: { default: null, type: cc.Sprite },
nodRCamp: { default: null, type: cc.Sprite },
},
// 根据位置获取敌方英雄数据
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 );
// vo.bid = role_data.bid;
// vo.level = role_data.lev;
// // vo.partner_id = role_data.partner_id;
// // vo.rid = role_data.rid;
// // vo.srv_id = vo.srv_id;
// vo.stars = vo.star;
return vo;
},
setRaceInfo: function( _guessdata ){
let guessinfo = _guessdata;
// console.log( "竞猜相关数据" + JSON.stringify( _guessdata ) );
this.race = _guessdata;
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 arole = this.dealPartners( acamptype, ap_list );
this.nodLParts.rebuild( arole );
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.nodLCamp, "", 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 bformation_config = gdata("formation_data","data_form_data", bcamptype );
let bpaht = cc.path.join( path, "teamform_" + bformation_config.order );
nx.gui.setSpriteFrame( this.nodRCamp, "", 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 brole = this.dealPartners( bcamptype, bp_list );
// if( this.nodLeftParts ){
this.nodRParts.rebuild( brole );
// }
nx.gui.setString( this.nodMyBet, "lname/server", guessinfo.a_srv_id );
nx.gui.setString( this.nodMyBet, "lname/name", guessinfo.a_name );
nx.gui.setString( this.nodMyBet, "lrate/rate", parseFloat( guessinfo.a_bet_ratio / 1000 ) );
nx.gui.setString( this.nodMyBet, "rname/server", guessinfo.b_srv_id );
nx.gui.setString( this.nodMyBet, "rname/name", guessinfo.b_name );
nx.gui.setString( this.nodMyBet, "rrate/rate", parseFloat( guessinfo.b_bet_ratio / 1000 ) );
nx.gui.setActive( this.nodReplay, "", guessinfo.replay_id != 0 );
nx.gui.setActive( this.nodLeft, "ico", guessinfo.ret == 1 );
nx.gui.setActive( this.nodRight, "ico", guessinfo.ret == 2 );
},
onTouchReplay: function(){
let srv_id = nx.bridge.vget( "curServer" ).srv_id;
BattleController.getInstance().sender_20036( this.race.replay_id, srv_id );
},
});