Files
fc/dev/project/assets/Scripts/mod/rank/cmps/cmp.rank.arena.js
T

149 lines
4.1 KiB
JavaScript
Raw Normal View History

2026-05-23 22:10:14 +08:00
const SVCItem = require("nx.fx.sv.expand.item");
const RankController = require("rank_controller");
const RankConstant = require("rank_constant");
const ChatController = require("chat_controller");
const RoleController = require("role_controller");
/**********
*
* 各不同类型排行列表单个ui数据显示
*/
cc.Class({
extends: SVCItem,
properties: {
rankBg: {
default : null,
type : cc.Node,
},
rankIcon: {
default : null,
type : cc.Node,
},
playerInfo: {
default : null,
type : cc.Node,
},
player_name : {
default : null,
type : cc.Node,
},
player_header : {
default : null,
type : cc.Node,
},
nodWorship: {
default : null,
type : cc.Node,
}
},
// 数据重置
rebind: function (_idx, _data, _key) {
this._super(_idx, _data, _key);
this.freshInfo();
},
// 刷新具体信息
freshInfo:function(){
if(!this.mdata){
return;
}
this.setRankicon( this.mdata.rank );
this.setLstHeadIcon( this.mdata );
nx.gui.setString( this.player_name, "", nx.text.getKey(this.mdata.name) );
if( this.nodWorship ){
// 处理未膜拜与膜拜后效果
nx.gui.setString( this.nodWorship, "power" ,this.mdata.worship );
nx.gui.setString( this.nodWorship, "score/txt" , this.mdata.score );
let btn = nx.gui.getComponent( this.nodWorship, "mk", cc.Button );
if( btn ){
btn.interactable = this.mdata.worship_status == 0;
}
}else{
nx.gui.setString( nx.gui.find( this.playerInfo, "power" ),"",this.mdata.score );
}
},
// 设置前三名显示效果
setRankicon : function( _index ){
//前三
let index = _index;
if( index < 4 ){
nx.gui.setActive( this, "rank_" + index, true );
nx.gui.setActive( this.rankIcon, "icon_" + index, true );
}else{
nx.gui.setActive( this, "rank_4", true );
nx.gui.setActive( this.rankIcon, "icon_4" , true );
nx.gui.setString( nx.gui.find( this.rankIcon, "txt" ), "", index );
}
},
// 膜拜点击
setLstHeadIcon : function( _faceid ){
nx.bridge.setIcon( this.player_header, "avatar/mask/img", _faceid.face, "resDB/empty/avatar" );
let cfg = game.configs.avatar_data.data_avatar[ _faceid.avatar_bid ];
let icon = cfg ? cfg.base_id : 1000;
nx.bridge.setAvatarFrame( this.player_header, "avatar/frame", icon );
},
//打开玩家信息
openChatMessage: function() {
let model = RankController.getInstance();
let type = model.getListType();
if( type == RankConstant.RankType.union ){
return;
}
let roleVo = RoleController.getInstance().getRoleVo();
let rid = this.mdata.rid || this.mdata.r_rid;
var srv_id = this.mdata.srv_id || this.mdata.r_srvid;
if( rid && srv_id && roleVo.rid == rid && roleVo.srv_id == srv_id ) {
nx.tbox( nx.text.getKey( "lab_rank_item_tip_1" ) );
return
}
if( this.mdata.is_robot && this.mdata.is_robot == 1 ) {
nx.tbox( nx.text.getKey( "lab_rank_item_tip_2" ) );
return
}
if( this.mdata ) {
let model = ChatController.getInstance();
let vo = { rid: rid, srv_id: srv_id };
model.openFriendInfo( vo );
}
},
onTouchWorship: function(){
if( this.mdata.worship_status > 0 ){
nx.tbox( nx.text.getKey( "lab_arena_loop_rank_worshiped" ) );
return;
}
let RC = RoleController.getInstance();
if( RC ){
RC.sender10316( this.mdata.rid, this.mdata.srv_id, this.mdata.rank );
}
}
});