"use strict"; cc._RF.push(module, 'a630fuYOCREXL+gXK5YpRRE', 'cmp.act.seven'); // Scripts/mod/acts/sevengoal/cmp/cmp.act.seven.js "use strict"; /****************************************************************** * * 七日周期任务 * ******************************************************************/ var ActPopup = require("act.popup.base"); var PathTool = require("pathtool"); var NxExpand = require("nx.fx.sv.expand"); var ItemLay = require("cmp.common.itemlayout"); var TipsController = require("tips_controller"); var SevenMod = require("act.seven.mod"); var NxSpine = require("nx.fx.spine"); var FxTog = require("nx.fx.togs"); cc.Class({ "extends": ActPopup, properties: { titles: { "default": [], type: [cc.Node] }, list: { "default": null, type: NxExpand }, expBar: { "default": null, type: cc.ProgressBar }, expIco: { "default": null, type: cc.Node }, expLev: { "default": null, type: cc.Node }, expScore: { "default": null, type: cc.Node }, curList: { "default": null, type: ItemLay }, nextList: { "default": null, type: ItemLay }, daysTogs: { "default": null, type: cc.Node // type:FxTog }, togs: { "default": null, type: FxTog }, lastTime: { "default": null, type: cc.Node }, roleSp: { "default": null, type: NxSpine } }, // 初始化 onLoad: function onLoad() { this.mod = SevenMod.getInstance(); this.goals_data = game.configs.day_goals_new_data; this.task_index = 0; this.cur_day = 0; this.select_day = 0; this.togs.posTog = this.onTogMenu.bind(this); // 活动监听 this.mod.vbind(this, [["sevenGoalData", this.freshInfos.bind(this)]]); }, onTogMenu: function onTogMenu(_index) { if (_index >= this.cur_day) { nx.tbox("Locked"); return this.togs.togTo(_index - 1); } this.select_day = _index + 1; var data = this.mod.vget("sevenGoalData"); this.setTaskList(this.select_day, data.list); }, onOpenConfigs: function onOpenConfigs(_params) { var _this = this; this._super(_params); this.mod.send13604(); this.mod.send13607(); var cds = this.daysTogs.children; for (var i = 0; i < cds.length; i++) { var tog = cds[i]; if (tog) { nx.gui.setString(tog, "off/txt", cc.js.formatStr(nx.text.getKey("action_str16"), i + 1)); nx.gui.setString(tog, "on/txt", cc.js.formatStr(nx.text.getKey("action_str16"), i + 1)); } } this.scheduleOnce(function () { var res_path1 = PathTool.getSpinePath("H30059", "show", false); _this.roleSp.load(res_path1, function (_e) { if (!_e) { _this.roleSp.action("action1", true); } else { _this.roleSp.stop(); } }); }, 0.2); }, onPreClosed: function onPreClosed() { this.list.rebuild([]); this.curList.rebuild([]); this.nextList.rebuild([]); // 活动监听解除 if (this.mod) { this.mod.vunbind(this); } }, onSelectTaskType: function onSelectTaskType(_index) { var idx = Number(_index); if (idx == this.task_index) return; this.task_index = idx; var data = this.mod.vget("sevenGoalData"); this.setTaskList(this.cur_day, data.list); }, freshInfos: function freshInfos(data) { if (nx.dt.objEmpty(data)) return; var lev = this.mod.getLev(); var exp = this.mod.getExp(); this.period = data.period; //判断一下第几期 nx.gui.setActive(this.titles[0], "", this.period % 2 == 0); nx.gui.setActive(this.titles[1], "", this.period % 2 == 1); this.cur_day = data.cur_day; this.select_day = this.cur_day; this.togs.togTo(data.cur_day - 1); var cds = this.daysTogs.children; for (var i = 0; i < cds.length; i++) { if (i < data.cur_day) { //已解鎖 nx.gui.setActive(cds[i], "off/lock", false); } } // let tog = this.daysTogs.children[data.cur_day - 1]; // if(tog){ // nx.gui.setActive(tog,"on",true); // } var cfg = this.goals_data.data_make_lev_list[this.period]; nx.gui.setString(this.expLev, "", cc.js.formatStr(nx.text.getKey("LvNumber"), lev)); if (!cfg) return; var max_exp = cfg[lev + 1] ? cfg[lev + 1].exp : cfg[lev].exp; nx.gui.setString(this.expScore, "", cc.js.formatStr("%s/%s", exp, max_exp)); //计算进度条,每次都从0开始 var last_exp = 0; if (cfg[lev - 1]) { last_exp = cfg[lev - 1].exp; } this.expBar.progress = (exp - last_exp) / (max_exp - last_exp); //获取积分图标 var item_id = this.goals_data.data_circle_exp_item[this.period].item_id; nx.bridge.setIcon(this.expIco, "", item_id); //设置当前和下级奖励 this.setLevReward(lev); //设置任务 this.setTaskList(this.cur_day, data.list); //設置時間 nx.gui.setCdTxt(this.lastTime, "", data.end_time - client.socket.getTime()); }, setLevReward: function setLevReward(lev) { var cur_awards = []; var next_awards = []; var cfg = this.goals_data.data_make_lev_list[this.period]; if (!cfg) return; cur_awards = cfg[lev].reward; if (cfg[lev + 1]) { next_awards = cfg[lev + 1].reward; } this.curList.rebuild(cur_awards); this.nextList.rebuild(next_awards); }, setTaskList: function setTaskList(curDay, tasks) { if (nx.dt.arrEmpty(tasks)) return; //需要区分任务和累充任务 0 1 var cfg = {}; if (this.task_index == 0) { var groups = this.goals_data.data_group_list[this.period]; for (var gid in groups) { if (groups[gid].day == curDay) { cfg[gid] = groups[gid]; } } } else { cfg = this.goals_data.data_charge_list[this.period]; } if (nx.dt.objEmpty(cfg)) return; var list1 = []; var list2 = []; var list3 = []; for (var i = 0; i < tasks.length; i++) { if (cfg[tasks[i].id]) { tasks[i].cfgs = cfg[tasks[i].id]; if (tasks[i].finish == 1) { list1.push(tasks[i]); } else if (tasks[i].finish == 0) { list2.push(tasks[i]); } else if (tasks[i].finish == 2) { list3.push(tasks[i]); } } } var list = list1.concat(list2.concat(list3)); this.list.rebuild(list); }, onClickRule: function onClickRule() { var TC = TipsController.getInstance(); if (TC) { var key = this.period % 2 == 0 ? "tips" : "tips_1"; var config = this.goals_data.data_constant[key]; TC.showTextPanel(null, config.desc); } }, onClickLevAward: function onClickLevAward() { nx.bridge.createPanel("WndActSevenGoalAward", { mod: this.mod, period: this.period }); } }); cc._RF.pop();