const ItemBase = require( "nx.fx.sv.expand.item" ); const StoneDungeonController = require("stone_dungeon_controller"); const RoleController = require("role_controller"); const ItemLay = require("cmp.common.itemlayout") cc.Class({ extends: ItemBase, properties: { item_list:{ default:null, type:ItemLay }, diff_bg:{ default:null, type:cc.Sprite }, diff_text:{ default:null, type:cc.Label }, textClear:{ default:null, type:cc.RichText }, textNumber:{ default:null, type:cc.Label }, btnClear:{ default:null, type:cc.Node }, cost_node:{ default:null, type:cc.Node }, cost_num:{ default:null, type:cc.Label }, btnChange:{ default:null, type:cc.Node }, textChange:{ default:null, type:cc.Label }, recommend:{ default:null, type:cc.Node } }, // LIFE-CYCLE CALLBACKS: onLoad () { this.role_vo = RoleController.getInstance().getRoleVo(); this.ctrl = StoneDungeonController.getInstance(); this.model = this.ctrl.getModel(); }, // 数据重置 rebind: function( _idx, _data, _key ) { this._super( _idx, _data, _key ); // 刷新 this.setData( _data ); }, setData(data){ if(nx.dt.objEmpty(data)){ return false; } this.dungeonData = data.info; this.expend = data.tab.expend this.free_count = data.tab.count this.title_pos = data.tab.title_pos this.setChangeData(data.info); }, setChangeData:function(){ if(this.dungeonData.title_name!=""){ this.diff_text.string = this.dungeonData.title_name; }else{ this.diff_text.string = ""; } if(this.title_pos == this.dungeonData.difficulty){ this.recommend.active = true; }else{ this.recommend.active = false; } let nod = nx.gui.find( this, "bottom/plot" ); if( nx.bridge.plot && nx.bridge.plot.isDoing() ){ if( this.dungeonData.difficulty == 1 && this.dungeonData.class_type == 1 ){ nod.getComponent( "cmp.plot.trigger" ).pID = "challenge"; nod.getComponent( "cmp.plot.trigger" ).regist(); nx.gui.setActive( nod, "", true ); } }else{ nx.gui.setActive( nod, "", false ); } this.cost_node.active = false; this.btnChange.active = false; this.btnClear.active = false; this.textNumber.string = cc.js.formatStr(nx.text.getKey("lab_stone_dungeon_open_fighr_level"), this.dungeonData.power || 0); this.textNumber.node.active = true; let is_first = 1; let clearance = this.model.getPassClearanceID(this.dungeonData.id); nx.gui.setLocked(this.btnChange,"",false); // this.btnChange.y = -35; nx.bridge.setIconS( this.cost_node, "ico", 3 ); if(clearance && clearance.status == 1){//已经通关的 if(this.role_vo.max_power >= this.dungeonData.power){ this.textNumber.node.active = false; this.btnClear.active = true; if(this.free_count == 0){ this.textClear.string = nx.text.getKey("btn_stone_dungeon_quickfight"); this.cost_node.active = true; this.cost_num.string = this.expend; }else{ this.cost_node.active = false; this.textClear.string = nx.text.getKey("btn_stone_dungeon_quickfight"); } this.model.setCurChangeSweep(this.dungeonData.id); }else{ this.btnClear.active = false; this.btnChange.active = true; // this.btnChange.y = -15; this.textChange.string = nx.text.getKey("lab_stone_dungeon_no_open"); nx.gui.setLocked(this.btnChange,"",true); } is_first = null; }else{ this.btnClear.active = false; if(this.role_vo.max_power >= this.dungeonData.power){ this.textNumber.node.active = false; this.btnChange.active = true; var status = false; if(this.role_vo.lev < this.dungeonData.lev_limit){ var str = cc.js.formatStr(nx.text.getKey("lab_stone_dungeon_open_level_haveval"),this.dungeonData.lev_limit); this.textChange.string = str; status = true; }else{ if(this.free_count == 0){//scale=0.25 this.textChange.string = nx.text.getKey("btn_stone_dungeon_fight"); this.cost_node.active = true; this.cost_num.string = this.expend; // let item_res = PathTool.queryIconPath(3); // cc.loader.loadRes(item_res,cc.SpriteFrame,(err,obj)=>{ // if(!err){ // this.textChange.addSpriteFrame = obj; // } // }); }else{ this.cost_node.active = false; this.textChange.string = nx.text.getKey("btn_stone_dungeon_fight"); } } nx.gui.setLocked(this.btnChange,"",!!status); }else{ this.btnChange.active = true; // this.btnChange.y = -15; var str = nx.text.getKey("lab_stone_dungeon_no_open_have_color") if(this.role_vo.lev < this.dungeonData.lev_limit){ str = cc.js.formatStr(nx.text.getKey("lab_stone_dungeon_open_level_haveval"),this.dungeonData.lev_limit) } this.textChange.string = str; nx.gui.setLocked(this.btnChange,"",true); } } cc.loader.loadRes(PathTool.getIconPath("dungeon",this.dungeonData.pis_str),cc.SpriteFrame, (err,resObject)=>{ this.diff_bg.spriteFrame = resObject; }); this.data_list = []; // 首通奖励 this.firstAward(is_first); // 展示奖励 this.showAward(is_first); }, firstAward:function(is_first){ if(!is_first)return; if(this.dungeonData.first_items[0]){ this.data_list.push({bid:this.dungeonData.first_items[0][0], num:this.dungeonData.first_items[0][1]}) } }, showAward:function(is_first){ var _flag = is_first && 1 || 0; if(!this.dungeonData.first_items[0]){ _flag = 0; is_first = null; } for(var i in this.dungeonData.show_items){ this.data_list.push({bid:this.dungeonData.show_items[i][0],num:this.dungeonData.show_items[i][1]}); } this.item_list.rebuild(this.data_list); }, onDisable(){ this.item_list.rebuild([]) }, onClickClear(){ this.ctrl.send13032(this.dungeonData.id); }, onClickChange(){ if(this.role_vo.lev < this.dungeonData.lev_limit){ nx.tbox(nx.text.getKey("lab_stone_dungeon_open_level")+this.dungeonData.lev_limit); }else{ this.ctrl.send13031(this.dungeonData.id); } } // update (dt) {}, });