"use strict"; cc._RF.push(module, '6a02f6GGlxCpYi+xjb/QmY5', 'cmp.guild.active.wnd'); // Scripts/mod/guild/active/cmps/cmp.guild.active.wnd.js "use strict"; /****************************************************************** * * 联盟活跃 * ******************************************************************/ var BridgeWindow = require("bridge.window"); var ItemLayout = require("cmp.item.layout"); var GuildEvent = require("guild_event"); var GuildController = require("guild_controller"); var FID = require("bridge.function.ids"); cc.Class({ "extends": BridgeWindow, properties: { nodBase: { "default": null, type: cc.Node }, nodList: { "default": null, type: cc.Node }, nodLvUp: { "default": null, type: cc.Node }, nodRewards: { "default": null, type: ItemLayout } }, // 显示 onEnable: function onEnable() { this.ctrl = GuildController.getInstance(); this.model = this.ctrl.getModel(); this.finishs = []; // 监听 this.bindGEvent(GuildEvent.UpdateMyInfoEvent, this.updateMyInfo.bind(this)); this.bindGEvent(GuildEvent.UpdataGuildGoalBasicData, this.updateBase.bind(this)); this.bindGEvent(GuildEvent.UpdataGuildGoalTaskData, this.updateTaskList.bind(this)); this.bindGEvent(GuildEvent.UpdataGuildGoalSingleTaskData, this.updateTask.bind(this)); // 信息请求 this.ctrl.reqActBaseInfo(); this.ctrl.reqActTaskInfo(); }, // 关闭 onDisable: function onDisable() { // 监听解除 this.unbindGEvents(); }, // 联盟信息更新 updateMyInfo: function updateMyInfo(_key, _val) { console.log("updateMyInfo:", _key, _val); if (_key == "vitality") { nx.gui.setString(this.nodBase, "vitality/txt", _val); } }, // 活跃信息更新 updateBase: function updateBase(_data) { // 工会活跃等级 var gifo = this.model.getMyGuildInfo(); nx.gui.setString(this.nodBase, "vitality/txt", gifo.vitality); // 个人活跃等级 var txt = nx.text.format("LvNumber", _data.lev); nx.gui.setString(this.nodBase, "level/txt", txt); nx.gui.setString(this.nodBase, "today/txt", _data.day_exp); nx.gui.setString(this.nodBase, "week/txt", _data.week_exp); // 进度 var DATA = game.configs.guild_quest_data.data_lev_data; var prog = nx.gui.getComponent(this.nodBase, "prog", cc.ProgressBar); var self = this; var attrs = function attrs(_fat, _tat) { for (var i = 0; i < 2; ++i) { var node = nx.gui.find(self.nodBase, "props/p" + (i + 1)); var from = _fat[i]; if (nx.dt.arrEmpty(from)) { node.active = false; continue; } node.active = true; nx.bridge.attrs.setAttribute(nx.gui.find(node, "from"), from); if (_tat) { var to = _tat[i]; if (nx.dt.arrEmpty(to)) { nx.gui.setActive(node, "arrow", false); nx.gui.setActive(node, "to", false); continue; } nx.gui.setActive(node, "arrow", true); nx.gui.setActive(node, "to", true); nx.bridge.attrs.setAttribute(nx.gui.find(node, "to"), to); } } }; if (_data.lev + 1 >= game.configs.guild_quest_data.data_lev_data_length) { prog.progress = 1; attrs(DATA[_data.lev].attr); nx.gui.setActive(this.nodLvUp, "", false); } else { prog.progress = Math.floor(_data.exp / DATA[_data.lev].exp * 100) / 100; attrs(DATA[_data.lev].attr, DATA[_data.lev + 1].attr); if (_data.exp >= DATA[_data.lev].exp) { nx.gui.setActive(this.nodLvUp, "", true); this.nodRewards.rebuild(DATA[_data.lev + 1].items); } else { nx.gui.setActive(this.nodLvUp, "", false); } } }, // 活跃任务列表更新 updateTaskList: function updateTaskList(_data) { var DATA = game.configs.guild_quest_data.data_task_data; var tasks = []; for (var i in _data.list) { var tk = nx.dt.objClone(_data.list[i]); for (var k in DATA) { var cfg = DATA[k]; if (cfg && cfg.id == tk.id) { tk.cfgs = cfg; tasks.push(tk); if (parseInt(tk.cfgs.show_jump) == FID.GuildDonate && !nx.dt.arrMember(this.finishs, parseInt(tk.cfgs.show_jump)) && tk.finish == 2) { this.finishs.push(FID.GuildDonate); } } } } tasks.sort(function (_a, _b) { return _a.finish - _b.finish; }); var self = this; // 任务设置 var setask = function setask(_node, _task) { _node.task = _task; // 日常/周长 nx.gui.setActive(_node, "type/day", _task.cfgs.type == 1); nx.gui.setActive(_node, "type/week", _task.cfgs.type == 2); // 信息 nx.gui.setString(_node, "name", nx.text.getKey(_task.cfgs.name)); nx.gui.setString(_node, "exp/txt", "+" + _task.cfgs.exp); // 进度 var txt = _task.value + "/" + _task.target_val; nx.gui.setString(_node, "progress/txt", txt); // 操作 nx.gui.setActive(_node, "ops/done", _task.finish == 2); nx.gui.setActive(_node, "ops/goto", _task.finish == 0); var btn = nx.gui.getComponent(_node, "ops/goto", cc.Button); btn.interactable = !nx.dt.arrMember(self.finishs, parseInt(_task.cfgs.show_jump)) && _task.finish == 0; nx.gui.setOutlineColor(_node, "ops/goto/txt", !nx.dt.arrMember(self.finishs, parseInt(_task.cfgs.show_jump)) && _task.finish == 0 ? new cc.color("#236491") : cc.Color.BLACK); }; var chds = this.nodList.children; nx.gui.gocChildren(this.nodList, "", tasks.length, chds[0]); for (var _i = 0; _i < tasks.length; ++_i) { setask(chds[_i], tasks[_i]); } }, // 活跃单任务更新 updateTask: function updateTask(_data) { if (!_data || nx.dt.arrEmpty(_data.list)) { return; } var chds = this.nodList.children; for (var i = 0; i < _data.list.length; ++i) { var info = _data.list[i]; var idsss = parseInt(game.configs.guild_quest_data.data_task_data[info.id].show_jump); if (idsss == FID.GuildDonate) { if (!nx.dt.arrMember(this.finishs, idsss)) { this.finishs.push(FID.GuildDonate); } } for (var k = 0; k < chds[k]; ++k) { var node = chds[k]; if (node && node.task && node.task.id == info.id) { node.task.finish = info.finish; node.task.target_val = info.target_val; node.task.value = info.value; // 进度 var txt = info.value + "/" + info.target_val; nx.gui.setString(node, "progress/txt", txt); // 操作 nx.gui.setActive(node, "ops/done", info.finish == 2); nx.gui.setActive(node, "ops/goto", info.finish == 0); var btn = nx.gui.getComponent(node, "ops/goto", cc.Button); btn.interactable = !nx.dt.arrMember(this.finishs, parseInt(node.task.cfgs.show_jump)) && node.task.finish == 0; nx.gui.setOutlineColor(node, "ops/goto/txt", !nx.dt.arrMember(this.finishs, parseInt(node.task.cfgs.show_jump)) && node.task.finish == 0 ? new cc.color("#236491") : cc.Color.BLACK); break; } } } }, // 点击前往 onTouchGoto: function onTouchGoto(_btn) { var task = _btn.parent.parent.task; if (task && task.cfgs) { var ret = nx.bridge.jumper.jump2Window(task.cfgs.show_jump); // if( ret ) { nx.bridge.closePanel("WndGuildActive"); // } } }, // 点击领取 onTouchGet: function onTouchGet() { this.ctrl.reqActLevelUp(function (_ret, _data) { if (!_ret) { nx.tbox(_data); return; } }); } }); cc._RF.pop();