"use strict"; cc._RF.push(module, 'e028axnUFVNtrA4GCHXHmmC', 'cmp.battledrama.special'); // Scripts/mod/battle_drama/cmp/cmp.battledrama.special.js "use strict"; var BridgeCmp = require("bridge.component"); var BTD = require("battle_drama_controller"); var PathTool = require("pathtool"); cc.Class({ "extends": BridgeCmp, properties: { togNd: { "default": [], type: [cc.Node] }, expBar: { "default": null, type: cc.ProgressBar }, fabItem: { "default": null, type: cc.Prefab } }, // LIFE-CYCLE CALLBACKS: // onLoad () {}, start: function start() {}, onEnable: function onEnable() { this.barList = [0, 0.2, 0.5, 0.8]; this.reawrdTags = {}; this.updateSpecialAward(); }, onDisable: function onDisable() {}, onHideSpecial: function onHideSpecial() { this.node.active = false; }, updateSpecialAward: function updateSpecialAward() { var pass_status = nx.bridge.vget("SpecialPass"); //判斷是否所有獎勵已領取 var pass_num = 0; for (var i in pass_status) { pass_num++; } if (pass_num >= 3) { this.onHideSpecial(); return; } var drama_data = BTD.getInstance().getModel().getDramaData(); // 当前剧情副本数据 var max_dun_id = drama_data.max_dun_id; // 遍历出整个列表 var idx = 0; var barPro = 0; for (var key in game.configs.dungeon_data.data_drama_special_reward) { var config = game.configs.dungeon_data.data_drama_special_reward[key]; if (config) { var target_config = game.configs.dungeon_data.data_drama_dungeon_info[config.limit_id]; if (target_config) { var nd = this.togNd[idx]; var tog = nx.gui.getComponent(nd, "", cc.Toggle); var tag = nx.gui.find(nd, "tag"); if (tag) { nx.bridge.NodeChidrenDestroy(tag); var item = cc.instantiate(this.fabItem); item.parent = tag; var cmp = nx.gui.getComponent(item, "", "cmp.item.base"); if (cmp) { cmp.rebind(idx, config.special_items[0], ""); } } if (max_dun_id >= config.limit_id) { //可领取 tog.isChecked = true; var is_received = pass_status[config.id]; //已领取 if (is_received) { this.setLockStatus(nd, 0); nx.gui.setString(nd, "desc", nx.text.getKey("Got")); } else { this.setLockStatus(nd, 1); nx.gui.setString(nd, "desc", cc.js.formatStr("%s", nx.text.getKey("CanGet"))); } barPro++; } else if (max_dun_id < config.limit_id) { //未完成 tog.isChecked = false; nx.gui.setString(nd, "desc", cc.js.formatStr("%s", target_config.name)); } this.reawrdTags[idx] = config.id; } idx++; } } this.expBar.progress = this.barList[barPro]; }, setLockStatus: function setLockStatus(nd, status) { var cmp = nx.gui.getComponent(nd, "eft", "nx.fx.spine"); if (!cmp) { return nx.gui.setActive(nd, "eft", false); } nx.gui.setActive(nd, "eft", true); if (status == 0) { cmp.stop(); } else if (status == 1) { var res_path = PathTool.getSpinePath("E80030", null, false); cmp.load(res_path, function (_e) { if (!_e) { cmp.action("action", true); } else { cmp.stop(); } }); } }, touchReflect: function touchReflect(_index) { if (!this.reawrdTags[_index]) return; BTD.getInstance().send13009(1, this.reawrdTags[_index]); } // update (dt) {}, }); cc._RF.pop();