331 lines
12 KiB
JavaScript
331 lines
12 KiB
JavaScript
|
|
const BridgeWindow = require( "bridge.window" );
|
||
|
|
const data2Icon = require( "bridge.utils.item" );
|
||
|
|
const HeroController = require( "hero_controller" );
|
||
|
|
const PartnerConst = require( "partner_const" );
|
||
|
|
const HeroConst = require( "hero_const" );
|
||
|
|
const ElitematchEvent = require( "elitematch_event" );
|
||
|
|
const RoleController = require( "role_controller" );
|
||
|
|
const BattleConst = require( "battle_const" );
|
||
|
|
|
||
|
|
cc.Class({
|
||
|
|
|
||
|
|
extends: BridgeWindow,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
|
||
|
|
nodStatus: { default: null, type: cc.Node, displayName: "匹配狀態顯示" },
|
||
|
|
nodOther: { default: null, type: cc.Node, displayName: "敵方節點" },
|
||
|
|
nodMine : { default: null, type: cc.Node, displayName: "我方節點" },
|
||
|
|
nodMyInfo : { default: null, type: cc.Node, displayName: "我方信息" },
|
||
|
|
nodGoto : { default: null, type: cc.Node, displayName: "出击状态" },
|
||
|
|
},
|
||
|
|
|
||
|
|
|
||
|
|
// 重载:参数打开
|
||
|
|
onOpenConfigs: function( _params ) {
|
||
|
|
|
||
|
|
this.type = _params.type;
|
||
|
|
this.mod = _params.mod;
|
||
|
|
|
||
|
|
this.mod.sender24920( this.type );
|
||
|
|
this.state = _params.state;
|
||
|
|
if( !this.mod ){
|
||
|
|
this.delayClose();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
nx.gui.hideAllChildren( this.nodMine );
|
||
|
|
nx.gui.hideAllChildren( this.nodOther, "matched/teams" );
|
||
|
|
nx.gui.setActive( this, "panel/close", true );
|
||
|
|
this.cfg = this.mod.getCfg();
|
||
|
|
|
||
|
|
this.ranklist = [];
|
||
|
|
// 视图监听
|
||
|
|
this.vbind( [
|
||
|
|
[ "rankMatching", this.freshInfo.bind( this ) ]
|
||
|
|
] );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onLoad: function(){
|
||
|
|
|
||
|
|
|
||
|
|
this.bindGEvent( ElitematchEvent.Update_Elite_Fun_Form2, this.freshMatchForm.bind( this ) );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 重载:关闭前
|
||
|
|
onPreClosed: function() {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
freshInfo: function( _data ){
|
||
|
|
|
||
|
|
// console.log( "顯示當前的匹配狀態" + JSON.stringify( _data ) );
|
||
|
|
let self = this;
|
||
|
|
let cmp = nx.gui.getComponent( this.nodOther, "", cc.Animation );
|
||
|
|
this.ranklist = _data.rand_list;
|
||
|
|
if( this.tweenAct ){
|
||
|
|
this.tweenAct.stop();
|
||
|
|
}
|
||
|
|
if( this.tweenActTime ){
|
||
|
|
this.tweenActTime.stop();
|
||
|
|
}
|
||
|
|
nx.gui.setString( this.nodGoto, "txt", nx.dt.arrNEmpty( _data.rand_list ) ? nx.text.getKey( "FigureConfirm" ) : nx.text.getKey( "RankMatchingBtn" ) );
|
||
|
|
let role = RoleController.getInstance().getRoleVo();
|
||
|
|
let myelitelev = gdata( this.cfg[0], "data_elite_level" )[ role.arena_elite_lev ];
|
||
|
|
let myname = role.name;
|
||
|
|
let sid = role.srv_id;
|
||
|
|
let ssid = sid.split( "_" );
|
||
|
|
|
||
|
|
let show = "[" + nx.text.format( "Srever", ssid[1] ) + "]" + myelitelev.name;
|
||
|
|
|
||
|
|
nx.gui.setString( this.nodMyInfo, "name", myname );
|
||
|
|
nx.gui.setString( this.nodMyInfo, "info", show );
|
||
|
|
|
||
|
|
let path = this.mod.dealUI( role.arena_elite_lev );
|
||
|
|
nx.gui.setSpriteFrame( this.nodMyInfo, "levico", path );
|
||
|
|
nx.gui.setActive( this.nodOther, "matched", nx.dt.arrNEmpty( this.ranklist ) );
|
||
|
|
nx.gui.setActive( this.nodOther, "matching", nx.dt.arrEmpty( this.ranklist ) );
|
||
|
|
nx.gui.setActive( this.nodStatus, "matching", _data.is_match == 1 );
|
||
|
|
nx.gui.setActive( this.nodStatus, "matched", nx.dt.arrNEmpty( this.ranklist ) );
|
||
|
|
let nod = nx.gui.find( this.nodStatus, "matching" );
|
||
|
|
if( _data.is_match == 1 ){
|
||
|
|
|
||
|
|
nx.gui.hideAllChildren( nod, "dot" );
|
||
|
|
let chd = nx.gui.find( nod, "dot" ).children;
|
||
|
|
this.tweenAct = cc.tween( nod )
|
||
|
|
.delay( 0.5 )
|
||
|
|
.call( ()=>{
|
||
|
|
nx.tween.fadeIn( chd[0], 0.01 );
|
||
|
|
} )
|
||
|
|
.delay( 0.5 )
|
||
|
|
.call( ()=>{
|
||
|
|
nx.tween.fadeIn( chd[1], 0.01 );
|
||
|
|
} )
|
||
|
|
.delay( 0.5 )
|
||
|
|
.call( ()=>{
|
||
|
|
nx.tween.fadeIn( chd[2], 0.01 );
|
||
|
|
} )
|
||
|
|
.delay( 1 )
|
||
|
|
.call( ()=>{
|
||
|
|
nx.tween.fadeOut( chd[0], 0.01 );
|
||
|
|
nx.tween.fadeOut( chd[1], 0.01 );
|
||
|
|
nx.tween.fadeOut( chd[2], 0.01 );
|
||
|
|
} )
|
||
|
|
.union()
|
||
|
|
.repeatForever()
|
||
|
|
.start();
|
||
|
|
if( cmp ){
|
||
|
|
cmp.play( 'def' );
|
||
|
|
}
|
||
|
|
nx.gui.setActive( this, "panel/ops/fight/cannot", true );
|
||
|
|
|
||
|
|
}else{
|
||
|
|
let nod = nx.gui.find( this.nodStatus, "matched" );
|
||
|
|
let time = _data.to_combat_time - _data.match_cd_time;
|
||
|
|
nx.gui.setString( nod, "time", time );
|
||
|
|
this.tweenActTime = cc.tween( nod )
|
||
|
|
.delay( 1 )
|
||
|
|
.call( ()=>{
|
||
|
|
time--;
|
||
|
|
if( time <= 0 ){
|
||
|
|
self.tweenActTime.stop();
|
||
|
|
nx.gui.setString( nod, "time", 0 );
|
||
|
|
}
|
||
|
|
nx.gui.setString( nod, "time", time );
|
||
|
|
} )
|
||
|
|
.union()
|
||
|
|
.repeatForever()
|
||
|
|
.start();
|
||
|
|
nx.gui.setActive( this, "panel/ops/fight/cannot", false );
|
||
|
|
|
||
|
|
// nx.gui.setCdTxt( this.nodStatus, "matched/time", _data.to_combat_time - _data.match_cd_time );
|
||
|
|
}
|
||
|
|
nx.gui.setActive( this, "panel/ops/form/tip", nx.dt.arrNEmpty( this.ranklist ) );
|
||
|
|
nx.gui.setActive( this, "panel/ops/fight/tip", nx.dt.arrNEmpty( this.ranklist ) );
|
||
|
|
if( nx.dt.arrNEmpty( this.ranklist ) ){
|
||
|
|
this.freshOther( _data );
|
||
|
|
nx.gui.setActive( this, "panel/close", false );
|
||
|
|
if( cmp ){
|
||
|
|
cmp.play( 'goin' );
|
||
|
|
|
||
|
|
nx.audio.playSFX( "audios/effects/del1" );
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onTouchMatch: function( ){
|
||
|
|
|
||
|
|
nx.dt.arrEmpty( this.ranklist ) ? this.mod.sender24902() : this.mod.sender24903();
|
||
|
|
nx.dt.arrEmpty( this.ranklist ) ? "" : this.close();
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
freshOther: function( _data ){
|
||
|
|
|
||
|
|
if( !_data ){
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
/***
|
||
|
|
* [24901]:{"day_combat_count":0,"match_cd_time":1709543023,
|
||
|
|
* "to_combat_time":1709543083,"is_match":0,
|
||
|
|
* "rand_list":[
|
||
|
|
* {"end_time":1709629423,"rid":1024,"srv_id":"fx_1","name":"安翔的小号1",
|
||
|
|
* "gname":"321","power":1585481,"lev":90,"sex":0,"face":26303,
|
||
|
|
* "look_id":110405,"score":1000,"elite_lev":1,
|
||
|
|
* "defense":[
|
||
|
|
* {"type":1,
|
||
|
|
* "defense_info":[
|
||
|
|
* {"order":1,"formation_type":1,
|
||
|
|
* "partner_infos":[
|
||
|
|
* {"pos":5,"bid":30404,"lev":100,"star":5,"power":12577,"extra":[{"key":5,"val":0}]},
|
||
|
|
* {"pos":4,"bid":20502,"lev":340,"star":13,"power":515477,"extra":[{"key":5,"val":0}]},
|
||
|
|
* {"pos":3,"bid":20509,"lev":340,"star":13,"power":497160,"extra":[{"key":5,"val":0}]},
|
||
|
|
* {"pos":2,"bid":10401,"lev":100,"star":5,"power":12278,"extra":[{"key":5,"val":0}]},
|
||
|
|
* {"pos":1,"bid":10505,"lev":340,"star":13,"power":547989,"extra":[{"key":5,"val":0}]}
|
||
|
|
* ]
|
||
|
|
* }
|
||
|
|
* ]},
|
||
|
|
* {"type":2,
|
||
|
|
* "defense_info":[{"order":1,"formation_type":1,
|
||
|
|
* "partner_infos":[
|
||
|
|
* {"pos":5,"bid":30404,"lev":100,"star":5,"power":12577,"extra":[{"key":5,"val":0}]},
|
||
|
|
* {"pos":4,"bid":20502,"lev":340,"star":13,"power":515477,"extra":[{"key":5,"val":0}]},
|
||
|
|
* {"pos":3,"bid":20509,"lev":340,"star":13,"power":497160,"extra":[{"key":5,"val":0}]},
|
||
|
|
* {"pos":2,"bid":10401,"lev":100,"star":5,"power":12278,"extra":[{"key":5,"val":0}]},
|
||
|
|
* {"pos":1,"bid":10505,"lev":340,"star":13,"power":547989,"extra":[{"key":5,"val":0}
|
||
|
|
* ]}]}]}],"face_update_time":0,"face_file":""}]}
|
||
|
|
|
||
|
|
*/
|
||
|
|
// let type = this.type == BattleConst.Fight_Type.EliteMatchWar ? 1 : 2;
|
||
|
|
let nod = nx.gui.find( this.nodOther, "matched" );
|
||
|
|
let info = _data.rand_list[0];
|
||
|
|
let sid = info.srv_id.split( "_" );
|
||
|
|
let cfg = gdata( this.cfg[0], "data_elite_level" )[info.elite_lev];
|
||
|
|
nx.gui.setString( nod, "name", info.name );
|
||
|
|
|
||
|
|
nx.gui.setString( nod, "info", "["+ nx.text.format( "Srever", sid[1] ) + "]" + cfg.name );
|
||
|
|
|
||
|
|
let path = this.mod.dealUI( info.elite_lev );
|
||
|
|
nx.gui.setSpriteFrame( nod, "levico", path );
|
||
|
|
|
||
|
|
let match_cd_time = _data.match_cd_time;
|
||
|
|
let dteam = nx.gui.find( nod, "teams" ).children;
|
||
|
|
// let cd = match_cd_time -
|
||
|
|
if( nx.dt.arrNEmpty( info.defense ) ){
|
||
|
|
|
||
|
|
for (let d = 0; d < info.defense.length; d++) {
|
||
|
|
let dnod = dteam[d];
|
||
|
|
if( info.defense[d].type <= this.type ){
|
||
|
|
nx.gui.setActive( dnod, "", info.defense[d].type == this.type );
|
||
|
|
let defence = info.defense[d].defense_info[0] ? info.defense[d].defense_info[0].partner_infos : [];
|
||
|
|
// for (let i in info.defense ) {
|
||
|
|
// let inffoo = info.defense[i];
|
||
|
|
nx.gui.hideAllChildren( dnod, "plist" );
|
||
|
|
nx.gui.setString( dnod, "power/txt", info.power );
|
||
|
|
// }
|
||
|
|
if( nx.dt.arrNEmpty( defence ) ){
|
||
|
|
|
||
|
|
nx.gui.gocChildren( dnod, "plist", defence.length );
|
||
|
|
let chd = nx.gui.find( dnod, "plist" ).children;
|
||
|
|
for (let i = 0; i < chd.length; i++) {
|
||
|
|
let nod = chd[i];
|
||
|
|
let info = defence[i];
|
||
|
|
let partner = data2Icon.data2Icon( info.bid );
|
||
|
|
partner.level = info.lev;
|
||
|
|
partner.stars = info.star;
|
||
|
|
|
||
|
|
// info.item_id = cfgs[info.bid].item_id;
|
||
|
|
// info.level = info.lev;
|
||
|
|
// info.stars = info.star;
|
||
|
|
|
||
|
|
let cmp = nx.gui.getComponent( nod, "", "cmp.partner.com" );
|
||
|
|
if( cmp ){
|
||
|
|
|
||
|
|
cmp.setData( partner );
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
freshMatchForm: function( _data ){
|
||
|
|
|
||
|
|
// console.log( "夥伴信息顯示" + JSON.stringify( _data ) );
|
||
|
|
|
||
|
|
/***
|
||
|
|
* {"type":0,"formations":
|
||
|
|
* [{"order":1,"formation_type":1,
|
||
|
|
* "pos_info":[{"pos":5,"id":1109},
|
||
|
|
* {"pos":4,"id":1092},
|
||
|
|
* {"pos":3,"id":1099},
|
||
|
|
* {"pos":2,"id":1087},
|
||
|
|
* {"pos":1,"id":1108}],"hallows_id":0}]}
|
||
|
|
*/
|
||
|
|
if( !_data ){
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if( this.type == _data.type ){
|
||
|
|
let formation = _data.formations;
|
||
|
|
let chd = this.nodMine.children;
|
||
|
|
// nx.gui.setActive( chd[this.type-1], "", true );
|
||
|
|
|
||
|
|
for (let i = 0; i < formation.length; i++) {
|
||
|
|
let form = formation[i];
|
||
|
|
let tnod = chd[i];
|
||
|
|
let nod = nx.gui.find( tnod, "plist" );
|
||
|
|
let power = 0;
|
||
|
|
nx.gui.gocChildren( nod, "", form.pos_info.length );
|
||
|
|
nx.gui.setActive( tnod, "", true );
|
||
|
|
for (let c = 0; c < nod.children.length; c++) {
|
||
|
|
let ttnod = nod.children[c];
|
||
|
|
|
||
|
|
if( form.pos_info[c] ){
|
||
|
|
let inffo = HeroController.getInstance().getModel().getHeroById( form.pos_info[c].id );
|
||
|
|
power += inffo.power;
|
||
|
|
let cmp = nx.gui.getComponent( ttnod, "", "cmp.partner.com" );
|
||
|
|
if( cmp ){
|
||
|
|
cmp.setData( inffo );
|
||
|
|
}
|
||
|
|
nx.gui.setString( tnod, "power/txt", power );
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onTouchClose: function(){
|
||
|
|
|
||
|
|
this.mod.sender24900();
|
||
|
|
this.close();
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
onTouchForm: function(){
|
||
|
|
let type = this.state.is_king != 0 && this.state.state == 3 ? 2 : 1;
|
||
|
|
HeroController.getInstance().openFormGoFightPanel( true, PartnerConst.Fun_Form.EliteMatch, { need_hide_top : true, state : type }, HeroConst.FormShowType.eFormSave );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
});
|