Files
fc/dev/project/library/imports/24/24ae3078-372d-477c-a6f7-2bafc6fe4285.js
T
2026-05-24 10:21:26 +08:00

135 lines
4.4 KiB
JavaScript

"use strict";
cc._RF.push(module, '24ae3B4Ny1HfKb3K6/G/kKF', 'cmp.battledrama.formselect');
// Scripts/mod/battle_drama/cmp/form/cmp.battledrama.formselect.js
"use strict";
var BridgeWindow = require("bridge.window");
var PathTool = require("pathtool");
var HeroController = require("hero_controller");
var RoleController = require("role_controller");
cc.Class({
"extends": BridgeWindow,
properties: {
form_item: {
"default": null,
type: cc.Node
},
form_content: {
"default": null,
type: cc.Node
},
form_name: {
"default": null,
type: cc.Label
}
},
// LIFE-CYCLE CALLBACKS:
onLoad: function onLoad() {
this.controller = HeroController.getInstance();
this.role_vo = RoleController.getInstance().getRoleVo();
},
start: function start() {
this.formaiton_cfg = game.configs.formation_data.data_form_data;
this.item_cfgs = [];
for (var from_i in this.formaiton_cfg) {
this.item_cfgs.push(this.formaiton_cfg[from_i]);
}
this.item_cfgs.sort(function (conf1, conf2) {
return conf1.order - conf2.order;
});
this.form_items = {};
this.cur_select_item = null;
this.new_select_type = null;
for (var from_i = 0; from_i < 6; from_i++) {
if (!this.form_items[from_i]) {
this.form_items[from_i] = cc.instantiate(this.form_item);
this.form_content.addChild(this.form_items[from_i]);
this.form_items[from_i].y = 30;
this.form_items[from_i].form_tag = from_i;
this.form_items[from_i].on(cc.Node.EventType.TOUCH_END, this.onClickFromItem, this);
}
}
// this.form_name.string = this.item_cfgs[ this.cur_form_type - 1 ].name;
this.updageWidget();
},
onOpenConfigs: function onOpenConfigs(params) {
this.cur_form_type = params.formation_type;
this.selent_cb = params.callback;
},
onPreClosed: function onPreClosed() {
nx.bridge.NodeChidrenDestroy(this.form_content);
},
updageWidget: function updageWidget() {
for (var from_i = 0; from_i < this.item_cfgs.length; from_i++) {
var form_cfg_item = this.item_cfgs[from_i];
var item_nd = this.form_items[from_i];
// 锁
var lock_nd = nx.gui.find(item_nd, "form_lock");
var is_lock = false;
if (form_cfg_item.need_lev > this.role_vo.lev) {
lock_nd.active = true;
is_lock = true;
} else {
lock_nd.active = false;
}
var form_select_icon_nd = nx.gui.find(item_nd, "form_select_icon");
if (this.cur_form_type == form_cfg_item.type) {
form_select_icon_nd.active = true;
this.cur_select_item = item_nd;
} else {
form_select_icon_nd.active = false;
}
// frame_icon
var form_icon_path = cc.path.join("prefab/battle/battledrama/ui", "teamform_" + form_cfg_item.order);
nx.gui.setSpriteFrame(item_nd, "form_icon", form_icon_path);
var nameNd = nx.gui.find(item_nd, "namebg");
nx.gui.setString(nameNd, "name", form_cfg_item.name);
// 开启文本
var lock_lv = nx.gui.getComponent(item_nd, "form_lv", cc.Label);
if (lock_lv) {
var str = cc.js.formatStr("Lv%s %s", form_cfg_item.need_lev, nx.text.getKey("btn_unlock"));
lock_lv.string = str;
if (is_lock) {
lock_lv.node.active = true;
} else {
lock_lv.node.active = false;
}
}
}
},
onClickFromItem: function onClickFromItem(event) {
var select_cgf = this.item_cfgs[event.target.form_tag];
if (select_cgf.type === this.new_select_type) return;
if (select_cgf.need_lev > this.role_vo.lev) {
// nx.tbox(nx.text.getKey("btn_lvUnlock")+" "+select_cgf.need_lev);
return;
}
var form_select_icon_nd = nx.gui.find(this.cur_select_item, "form_select_icon");
form_select_icon_nd.active = false;
this.cur_select_item = event.target;
var form_select_icon_nd = nx.gui.find(this.cur_select_item, "form_select_icon");
form_select_icon_nd.active = true;
//名称
// this.form_name.string = select_cgf.name;
this.new_select_type = select_cgf.type;
},
onClickConfirmBtn: function onClickConfirmBtn() {
this.controller.openFormationSelectPanel(false);
if (this.new_select_type !== null && this.new_select_type !== this.cur_form_type) {
if (this.selent_cb) {
this.selent_cb(this.new_select_type);
}
}
}
// update (dt) {},
});
cc._RF.pop();