156 lines
4.2 KiB
JavaScript
156 lines
4.2 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'a6e133jc+lN14LrIt+apYAN', 'cmp.planesafk.item.map');
|
|
// Scripts/mod/pve/planesafk/cmp/cmp.planesafk.item.map.js
|
|
|
|
"use strict";
|
|
|
|
var ItemBase = require("nx.fx.sv.expand.item");
|
|
var PathTool = require("pathtool");
|
|
var PlanesafkController = require("planesafk_controller");
|
|
var 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: function onLoad() {},
|
|
// 数据重置
|
|
rebind: function rebind(_idx, _data, _key) {
|
|
this._super(_idx, _data, _key);
|
|
|
|
// 刷新
|
|
this.setData(_data);
|
|
},
|
|
setEmpty: function setEmpty(is_reset) {
|
|
if (is_reset === void 0) {
|
|
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: function onFocus() {},
|
|
outFocus: function outFocus() {},
|
|
setData: function setData(data) {
|
|
if (nx.dt.objEmpty(data)) {
|
|
return false;
|
|
}
|
|
this.setEmpty(true);
|
|
this.data = data;
|
|
|
|
//判断是否是玩家当前层
|
|
var 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: function 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]) {
|
|
var 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 checkClickEvt() {
|
|
var myPos = PlanesafkController.getInstance().getModel().getRolePos();
|
|
var 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 hideEvtInfo() {
|
|
this.setEmpty();
|
|
this.alive.active = true;
|
|
},
|
|
//显示选中的事件
|
|
showSelectEvtInfo: function showSelectEvtInfo() {
|
|
//名字
|
|
nx.gui.setString(this.name_txt, "", this.evt_cfg.name);
|
|
},
|
|
onClickEvt: function 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) {},
|
|
});
|
|
|
|
cc._RF.pop(); |