"use strict"; cc._RF.push(module, 'a89d5ET34hNHoqrHBKwvMPO', 'cmp.hallows.wnd.tips'); // Scripts/mod/partner/hallows/cmp/cmp.hallows.wnd.tips.js "use strict"; /****************************************************************** * * 行星武器奖励弹窗 * ******************************************************************/ var BridgeWindow = require("bridge.window"); var FxSpine = require("nx.fx.spine"); var HallowsConst = require("hallows_const"); var HallowsEvent = require("hallows_event"); var HallowsController = require("hallows_controller"); cc.Class({ "extends": BridgeWindow, properties: { spAnim: { "default": null, type: FxSpine }, nodRewards: { "default": null, type: cc.Node }, nodGet: { "default": null, type: cc.Node }, old_step: { "default": null, type: cc.Label }, cur_step: { "default": null, type: cc.Label }, item_list: { "default": [], type: [cc.Node] }, attr_list: { "default": [], type: [cc.Node] }, skill_item: { "default": null, type: cc.Prefab }, arrow: { "default": null, type: cc.Node }, tag_ico: { "default": null, type: cc.Node } }, // 重载:参数打开 onOpenConfigs: function onOpenConfigs(_params) { if (_params.type == 1) { this.nodGet.active = true; } else if (_params.type == 2) { this.nodRewards.active = true; } if (!_params.data) return; this.ctrl = HallowsController.getInstance(); this.model = this.ctrl.getModel(); // // 动画流程 this.doAnimation(_params); }, // dealShow: function(){ // if( !nx.dt.arrEmpty( this.specials ) ){ // let bid = this.specials.splice(0, 1); // deal( bid ); // }else{ // this.showRewards(); // } // }, // showRewards : function(){ // nx.gui.setActive( this.nodRewards, "", false ); // this.doAnimation(); // }, // showGet : function(){ // nx.gui.setActive( this.nodGet, "", false ); // this.doAnimation(); // }, // 动画流程 doAnimation: function doAnimation(_params) { var _this = this; // 隐藏操作 // this.hideOps(); this.spAnim.action("action", false, function (_key, _name) { if (_key == "reward") { if (_params.type == 1) { _this.nodGet.active = true; _this.arrow.active = false; var vo = _this.model.getHallowsById(_params.data.id); if (!vo) return; var hallows_skill = gdata("hallows_data", "data_skill_up", Utils.getNorKey(_params.data.id, vo.skill_lev)); if (hallows_skill) { var config = gskilldata("data_get_skill", hallows_skill.skill_bid); _this.skill_icon = cc.instantiate(_this.skill_item); _this.skill_icon.parent = _this.nodGet; _this.skill_icon.position = cc.v2(0, 50); var cmp = _this.skill_icon.getComponent("cmp.skill.base"); cmp.rebind(0, config.bid, ""); } _this.step_config = gdata("hallows_data", "data_info", Utils.getNorKey(_params.data.id, _params.data.step)); if (_this.step_config) { // this.hallows_name.string = this.step_config.name; var attr_list = _this.step_config.attr; if (attr_list) { for (var j in attr_list) { if (j > 2) break; var attr_key = attr_list[j][0]; var attr_val = attr_list[j][1]; var attr_name = game.configs.attr_data.data_key_to_name[attr_key]; if (attr_name) { var name = nx.gui.getComponent(_this.attr_list[parseInt(j)], "name", cc.Label); name.string = attr_name; var val = nx.gui.getComponent(_this.attr_list[parseInt(j)], "lev_name", cc.Label); val.string = attr_val; } } } // this.updateHallowsBaseInfo() } nx.gui.setSpriteFrame(_this.tag_ico, "", cc.js.formatStr("prefab/partner/hallows/ui/%s", _params.data.id)); } else if (_params.type == 2) { _this.nodRewards.active = true; var id = _params.data; if (id) { _this.data = _this.model.getHallowsById(id); _this.data_config = game.configs.hallows_data.data_base[id]; if (_this.data && _this.data_config) { _this.setStepBaseInfo(); _this.setStepAttrInfo(); } } } // 操作展示 // this.freshAndDelayShowOps(); return; } // 第二阶段 if (_key == "complete") { _this.spAnim.action("action2", true); return; } }); }, setStepBaseInfo: function setStepBaseInfo() { if (nx.dt.objEmpty(this.data) || nx.dt.objEmpty(this.data_config)) { return; } // this.hallows_name.string = this.data_config.name; this.old_step.string = "Lv." + (this.data.step - 1); this.cur_step.string = "Lv." + this.data.step; }, setStepAttrInfo: function setStepAttrInfo() { if (nx.dt.objEmpty(this.data)) return; var vo = this.data; var old_config = gdata("hallows_data", "data_info", Utils.getNorKey(vo.id, vo.step - 1)); var cur_config = gdata("hallows_data", "data_info", Utils.getNorKey(vo.id, vo.step)); if (nx.dt.objEmpty(old_config) || nx.dt.objEmpty(cur_config)) return; for (var i in old_config.attr) { if (i > 1) break; var attr_key = old_config.attr[i][0]; var attr_val = old_config.attr[i][1]; var attr_name = game.configs.attr_data.data_key_to_name[attr_key]; if (attr_name) { var object = this.item_list[parseInt(i)]; var title = nx.gui.getComponent(object, "title", cc.Label); title.string = attr_name; var last_lev = nx.gui.getComponent(object, "last_lev", cc.Label); last_lev.string = attr_val; } } for (var j in cur_config.attr) { if (j > 1) break; var attr_key = cur_config.attr[j][0]; var attr_val = cur_config.attr[j][1]; var attr_name = game.configs.attr_data.data_key_to_name[attr_key]; if (attr_name) { var object = this.item_list[parseInt(j)]; var _title = nx.gui.getComponent(object, "title", cc.Label); _title.string = attr_name; var now_lev = nx.gui.getComponent(object, "cur_lev", cc.Label); now_lev.string = attr_val; if (old_config.attr[j] == null) { var _title2 = nx.gui.getComponent(object, "title", cc.Label); _title2.string = attr_name; var _last_lev = nx.gui.getComponent(object, "last_lev", cc.Label); _last_lev.string = 0; } } } }, // ================================================== // 不同的操作栏处理 // ================================================== // 操作展示 freshAndDelayShowOps: function freshAndDelayShowOps() { var _this2 = this; // 辨别展示节点 var optype = false; if (nx.dt.objNEmpty(this.params)) { this.nodOps.children.forEach(function (_node) { _node.active = _node.name == _this2.params.op; }); optype = true; switch (this.params.op) { // 召唤面板 case "summon": { this.freshSummonOps(this.params); } break; // 无法识别 default: { optype = false; nx.error("无效道具展示操作类型:", this.params.op); } break; } } // 延迟关闭 var node = optype ? this.nodOps : this.nodTouch; this.scheduleOnce(function () { node.active = true; nx.tween.fadeIn(node, "", 0.5); }, 0.5); } }); cc._RF.pop();