"use strict";
|
cc._RF.push(module, '53053D2DRNLOr9jUGYxWOaL', 'battle_buff_info_window');
|
// Scripts/mod/battle/view/battle_buff_info_window.js
|
|
"use strict";
|
|
// --------------------------------------------------------------------
|
// @author: xxx@syg.com(必填, 创建模块的人员)
|
// @description:
|
// 这里是描述这个窗体的作用的
|
// <br/>Create: 2019-07-24 14:39:24
|
// --------------------------------------------------------------------
|
var PathTool = require("pathtool");
|
|
var BattleController = require("battle_controller");
|
|
var BattleConst = require("battle_const");
|
|
var BattleBuffInfoItem = require("battle_buff_info_item_panel");
|
|
var BattleEvent = require("battle_event");
|
|
var Dir_Type = {
|
Left: 1,
|
// 左边英雄
|
Right: 2 // 右边英雄
|
|
};
|
var BattleBuffInfoView = cc.Class({
|
"extends": BaseView,
|
ctor: function ctor() {
|
this.prefabPath = PathTool.getPrefabPath("battle", "battle_buff_info_view");
|
this.viewTag = SCENE_TAG.dialogue; //该窗体所属ui层级,全屏ui需要在ui层,非全屏ui在dialogue层,这个要注意
|
|
this.win_type = WinType.Mini; //是否是全屏窗体 WinType.Full, WinType.Big, WinType.Mini, WinType.Tips
|
|
this.ctrl = BattleController.getInstance();
|
this.model = this.ctrl.getModel();
|
},
|
// 初始化一些配置数据,可以用于声明一些变量之类的
|
initConfig: function initConfig() {
|
this.left_item_list = [];
|
this.right_item_list = [];
|
},
|
// 预制体加载完成之后的回调,可以在这里捕获相关节点或者组件
|
openCallBack: function openCallBack() {
|
this.background = this.root_wnd.getChildByName("background");
|
var container = this.root_wnd.getChildByName("container");
|
this.left_name_label = container.getChildByName("left_name_label").getComponent(cc.Label);
|
this.right_name_label = container.getChildByName("right_name_label").getComponent(cc.Label);
|
this.left_role_panel = container.getChildByName("left_role_panel");
|
this.right_role_panel = container.getChildByName("right_role_panel");
|
this.close_btn = container.getChildByName("close_btn");
|
var close_btn_label = this.close_btn.getChildByName("label").getComponent(cc.Label);
|
close_btn_label.string = Utils.TI18N("确 定");
|
},
|
// 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
|
registerEvent: function registerEvent() {
|
this.close_btn.on('click', this._onClickCloseBtn, this);
|
this.background.on('touchend', this._onClickCloseBtn, this); // -- 每回合更新一次
|
|
this.addGlobalEvent(BattleEvent.UPDATE_ROUND_NUM, function () {
|
this.setData();
|
}.bind(this));
|
},
|
// 预制体加载完成之后,添加到对应主节点之后的回调,也就是一个窗体的正式入口,可以设置一些数据了
|
openRootWnd: function openRootWnd(params) {
|
this.left_name = params.left_name || "";
|
this.right_name = params.right_name || "";
|
this.setData(true);
|
},
|
// 关闭窗体回调,需要在这里调用该窗体所属controller的close方法没用于置空该窗体实例对象
|
closeCallBack: function closeCallBack() {
|
if (this.left_item_list) {
|
for (var i = 0; i < this.left_item_list.length; ++i) {
|
if (this.left_item_list[i]) {
|
this.left_item_list[i].deleteMe();
|
this.left_item_list[i] = null;
|
}
|
}
|
|
this.left_item_list = null;
|
}
|
|
if (this.right_item_list) {
|
for (var _i = 0; _i < this.right_item_list.length; ++_i) {
|
if (this.right_item_list[_i]) {
|
this.right_item_list[_i].deleteMe();
|
|
this.right_item_list[_i] = null;
|
}
|
}
|
|
this.right_item_list = null;
|
}
|
|
this.ctrl.openBattleBuffInfoView(false);
|
},
|
setData: function setData(is_init) {
|
var _this = this;
|
|
var all_object = this.ctrl.getModel().getAllObject();
|
if (!all_object || Utils.next(all_object) == null) return; // 取出左右两侧数据
|
|
var left_data = [];
|
var right_data = [];
|
|
for (var k in all_object) {
|
var bRole = all_object[k]; // -- 筛选掉神器
|
|
if (bRole.role_data.object_type == BattleConst.BattleObjectType.Pet || bRole.role_data.object_type == BattleConst.BattleObjectType.Unit) {
|
if (bRole.group == 1) {
|
left_data.push(bRole);
|
} else if (bRole.group == 2) {
|
right_data.push(bRole);
|
}
|
}
|
}
|
|
var start_y = this.left_role_panel.getContentSize().height; // -- 左侧
|
|
this.left_name_label.string = this.left_name;
|
|
for (var _k = 0; _k < this.left_item_list.length; ++_k) {
|
var item = this.left_item_list[_k];
|
item.setVisible(false);
|
}
|
|
var _loop = function _loop(i) {
|
var l_data = left_data[i];
|
|
if (is_init) {
|
Utils.delayRun(_this.left_role_panel, i * 4 / 40, function () {
|
var role_item = this.left_item_list[i];
|
|
if (role_item == null) {
|
role_item = new BattleBuffInfoItem(Dir_Type.Left);
|
this.left_item_list[i] = role_item;
|
role_item.setParent(this.left_role_panel);
|
}
|
|
role_item.setVisible(true);
|
var item_size = cc.size(300, 100);
|
role_item.setPosition(0, start_y - (i + 1) * item_size.height);
|
role_item.setData(l_data);
|
role_item.show();
|
}.bind(_this));
|
} else {
|
var role_item = _this.left_item_list[i];
|
|
if (role_item == null) {
|
role_item = new BattleBuffInfoItem(Dir_Type.Left);
|
_this.left_item_list[i] = role_item;
|
role_item.setParent(_this.left_role_panel);
|
}
|
|
role_item.setVisible(true);
|
var item_size = cc.size(300, 100);
|
role_item.setPosition(0, start_y - (i + 1) * item_size.height);
|
role_item.setData(l_data);
|
role_item.show();
|
}
|
};
|
|
for (var i = 0; i < left_data.length; ++i) {
|
_loop(i);
|
} // -- 右侧
|
|
|
this.right_name_label.string = this.right_name;
|
|
for (var _k2 = 0; _k2 < this.right_item_list.length; ++_k2) {
|
var _item = this.right_item_list[_k2];
|
|
_item.setVisible(false);
|
}
|
|
var _loop2 = function _loop2(_i2) {
|
var r_data = right_data[_i2];
|
|
if (is_init) {
|
Utils.delayRun(_this.right_role_panel, _i2 * 4 / 40, function () {
|
var role_item = this.right_item_list[_i2];
|
|
if (role_item == null) {
|
role_item = new BattleBuffInfoItem(Dir_Type.Right);
|
this.right_item_list[_i2] = role_item;
|
role_item.setParent(this.right_role_panel);
|
}
|
|
role_item.setVisible(true);
|
var item_size = cc.size(300, 100);
|
role_item.setPosition(0, start_y - (_i2 + 1) * item_size.height);
|
role_item.setData(r_data);
|
role_item.show();
|
}.bind(_this));
|
} else {
|
var role_item = _this.right_item_list[_i2];
|
|
if (role_item == null) {
|
role_item = new BattleBuffInfoItem(Dir_Type.Right);
|
_this.right_item_list[_i2] = role_item;
|
role_item.setParent(_this.right_role_panel);
|
}
|
|
role_item.setVisible(true);
|
var item_size = cc.size(300, 100);
|
role_item.setPosition(0, start_y - (_i2 + 1) * item_size.height);
|
role_item.setData(r_data);
|
role_item.show();
|
}
|
};
|
|
for (var _i2 = 0; _i2 < right_data.length; ++_i2) {
|
_loop2(_i2);
|
}
|
},
|
_onClickCloseBtn: function _onClickCloseBtn() {
|
Utils.playButtonSound(2);
|
this.ctrl.openBattleBuffInfoView(false);
|
}
|
});
|
|
cc._RF.pop();
|