const BridgeCmp = require("bridge.component"); const BTD = require("battle_drama_controller"); const 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 () { }, onEnable(){ this.barList = [0,0.2,0.5,0.8]; this.reawrdTags = {}; this.updateSpecialAward(); }, onDisable(){ }, onHideSpecial(){ this.node.active = false; }, updateSpecialAward(){ let pass_status = nx.bridge.vget("SpecialPass"); //判斷是否所有獎勵已領取 let pass_num = 0; for(let i in pass_status){ pass_num++; } if(pass_num >= 3){ this.onHideSpecial(); return; } let drama_data = BTD.getInstance().getModel().getDramaData(); // 当前剧情副本数据 let max_dun_id = drama_data.max_dun_id; // 遍历出整个列表 let idx = 0; let 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) { let nd = this.togNd[idx]; let tog = nx.gui.getComponent(nd,"",cc.Toggle); let tag = nx.gui.find(nd,"tag"); if(tag){ nx.bridge.NodeChidrenDestroy(tag); let item = cc.instantiate(this.fabItem); item.parent = tag; let 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; let 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(nd,status){ let 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){ let res_path = PathTool.getSpinePath( "E80030",null, false ); cmp.load( res_path, ( _e ) => { if( !_e ) { cmp.action( "action", true ); } else { cmp.stop(); } } ); } }, touchReflect(_index) { if(!this.reawrdTags[_index])return; BTD.getInstance().send13009( 1, this.reawrdTags[_index] ); }, // update (dt) {}, });