Files
fc/dev/project/assets/Scripts/mod/pve/planesafk/cmp/cmp.planesafk.item.map.js
T

176 lines
4.4 KiB
JavaScript
Raw Normal View History

2026-05-23 22:10:14 +08:00
const ItemBase = require( "nx.fx.sv.expand.item" );
const PathTool = require("pathtool");
const PlanesafkController = require("planesafk_controller");
const PlanesafkEvent = require("planesafk_event");
cc.Class({
extends: ItemBase,
properties: {
normal:{
default:null,
type:cc.Node
},
alive:{
default:null,
type:cc.Node
},
name_txt:{
default:null,
type:cc.Node
},
evt_icon:{
default:null,
type:cc.Node
},
nameNd:{
default:null,
type:cc.Node
},
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
},
// 数据重置
rebind: function( _idx, _data, _key ) {
this._super( _idx, _data, _key );
// 刷新
this.setData( _data );
},
setEmpty(is_reset = false){
this.alive.active = is_reset;
this.name_txt.active = is_reset;
this.evt_icon.active = is_reset;
this.nameNd.active = is_reset;
},
onFocus(){
},
outFocus(){
},
setData(data){
if(nx.dt.objEmpty(data)){
return false;
}
this.setEmpty(true);
this.data = data;
//判断是否是玩家当前层
let cur_pos = PlanesafkController.getInstance().getModel().getRolePos();
if(cur_pos[0] == data.line && cur_pos[1] == data.index){
gcore.GlobalEvent.fire(PlanesafkEvent.Planesafk_Create_Role_Event,this.data.line,this.data.index)
this.updateEvtInfo(false)
}else{
this.updateEvtInfo(true)
}
if(data.is_hide == 1){
this.setEmpty();
}
if(data.is_walk == 1){
this.setEmpty();
this.alive.active = true;
if(cur_pos[0] == (data.line+1)){
gcore.GlobalEvent.fire(PlanesafkEvent.Planesafk_Create_Role_Event,this.data.line,this.data.index)
}
}
},
updateEvtInfo(status){
if (status) {
this.evt_cfg = gdata("planes_data","data_evt_info",this.data.evt_id);
if (! this.evt_cfg )return;
//設置一下圖標
if(this.evt_cfg.res_2[0]){
let res_path = cc.js.formatStr("prefab/pve/icons/%s",this.evt_cfg.res_2[0]);
nx.gui.setSpriteFrame(this.evt_icon,"",res_path);
}
var line = PlanesafkController.getInstance().getModel().getRolePos()[0]
if ((this.data.is_hide == 1) || (this.data.line > line + 2)) {
this.hideEvtInfo()
return
}
//选中效果
var line = PlanesafkController.getInstance().getModel().getRolePos()[0]
if (this.data.line > line) {
this.showSelectEvtInfo();
}else{
this.name_txt.active = false;
}
}
else
{
this.hideEvtInfo()
}
},
checkClickEvt:function(){
let myPos = PlanesafkController.getInstance().getModel().getRolePos();
let is_allow = true;
//行限制
if(this.data.line >= (myPos[0] + 2)){
is_allow = false;
}else if(this.data.line == (myPos[0] + 1)){ //相鄰位限制
if(this.data.index == 1){
if(myPos[1] == 4){
is_allow = false;
}
}else if(this.data.index == 5){
if(myPos[1] == 2){
is_allow = false;
}
}else if(this.data.index == 2){
if(myPos[1] == 5){
is_allow = false;
}
}else if(this.data.index == 4){
if(myPos[1] == 1){
is_allow = false;
}
}
}else{
is_allow = false;
}
return is_allow;
},
hideEvtInfo:function(){
this.setEmpty();
this.alive.active = true;
},
//显示选中的事件
showSelectEvtInfo(){
//名字
nx.gui.setString(this.name_txt,"",this.evt_cfg.name);
},
onClickEvt(){
if(this.data.is_hide == 1)return;
if(!this.checkClickEvt())return;
if (! this.evt_cfg)return;
PlanesafkController.getInstance().onHandlePlanesEvtById(this.evt_cfg.type, this.data)
}
// update (dt) {},
});