const ItemBase = require( "nx.fx.sv.expand.item" ); const HallowsConst = require("hallows_const"); cc.Class({ extends: ItemBase, properties: { lock_nd:{ default:null, type:cc.Node }, lock_icon:{ default:null, type:cc.Sprite }, lock_name:{ default:null, type:cc.Label }, off_nd:{ default:null, type:cc.Node }, on_nd:{ default:null, type:cc.Node }, off_name:{ default:null, type:cc.Label }, on_name:{ default:null, type:cc.Label }, off_lev:{ default:null, type:cc.Label }, on_lev:{ default:null, type:cc.Label }, off_icon:{ default:null, type:cc.Sprite }, on_icon:{ default:null, type:cc.Sprite }, off_sp:{ default:[], type:cc.SpriteFrame }, on_sp:{ default:[], type:cc.SpriteFrame }, tipNd:{ default:null, type:cc.Node } }, // LIFE-CYCLE CALLBACKS: // onLoad () {}, // 数据重置 rebind: function( _idx, _data, _key ) { this._super( _idx, _data, _key ); // 刷新 this.setData( _data ); }, start () { }, // 聚焦获得 onFocus: function() { if(this.is_lock){ this.on_nd.active = true; this.lock_nd.active = false; return; } this.on_nd.active = true; this.off_nd.active = false; }, // 聚焦失去 outFocus: function() { if(this.is_lock){ this.on_nd.active = false; this.lock_nd.active = true; return; } this.on_nd.active = false; this.off_nd.active = true; }, setData(data){ if(nx.dt.objEmpty(data)){ return false; } this.lock_name.string = data.name; this.off_name.string = data.name; this.on_name.string = data.name; this.on_lev.string = 0; this.off_lev.string = 0; //表示未解锁当前行星武器 if(nx.dt.objEmpty(data.vo)){ this.is_lock = true; this.lock_nd.active = true; this.on_nd.active = false; this.off_nd.active = false; }else{ this.is_lock = false; this.lock_nd.active = false; this.off_nd.active = true; if(data.vo.step){ this.on_lev.string = data.vo.step; this.off_lev.string = data.vo.step; } } if(data.id!=null){ this.lock_icon.spriteFrame = this.off_sp[data.id - 1]; this.off_icon.spriteFrame = this.off_sp[data.id -1]; this.on_icon.spriteFrame = this.on_sp[data.id -1]; } this.rebindTip(); }, rebindTip(){ //紅點處理 let dot = nx.gui.getComponent( this, "tip", "nx.vb.visible" ); if( !dot ) { nx.gui.setActive( dot, "", false ); } else { let key = HallowsConst.TIP_DEFINED[this.mdata.id]; dot.setTarget( nx.mTip, key ); } } // update (dt) {}, });