/****************************************************************** * * 联盟创建 * ******************************************************************/ const BridgeComponent = require( "bridge.component" ); const GuildConst = require( "guild_const" ); const GDC = require( "guild_controller" ); const STEP_LEVEL = 1; const STEP_BP = 10000; const MAX_LEVEL = 200; // 审核类型 const GCVT = GuildConst.ApplyJoinType; cc.Class( { extends: BridgeComponent, properties: { edtName: { default: null, type: cc.EditBox }, edtWords: { default: null, type: cc.EditBox }, nodCond: { default: null, type: cc.Node }, nodVerify: { default: null, type: cc.Node }, nodCreate: { default: null, type: cc.Node }, }, // 显示 onEnable: function () { if( nx.dt.numGood( this.verify ) ) { return; } // 消耗 let DATA = game.configs.guild_data.data_const; nx.bridge.setIconS( this.nodCreate, "need/ico", 3 ); nx.gui.setString( this.nodCreate, "need/txt", DATA.create_gold.val ); this.setVerify( GCVT.Auto ); this.setLevel( 1 ); this.setBP( 1 ); }, // 设置申请开关 setVerify: function ( _type ) { this.verify = _type; nx.gui.setActive( this.nodCond, "tog0/ico/off", _type != GCVT.Auto ) nx.gui.setActive( this.nodCond, "tog0/ico/on", _type == GCVT.Auto ) nx.gui.setActive( this.nodCond, "tog1/ico/off", _type != GCVT.Manual ) nx.gui.setActive( this.nodCond, "tog1/ico/on", _type == GCVT.Manual ) let block = ( this.verify == GCVT.Auto ); this.nodVerify.opacity = block ? 180 : 255; nx.gui.setActive( this.nodVerify, "block", block ); }, // 切换申请开关 onTogVerify: function ( _key ) { let type = parseInt( _key ) || GCVT.Auto; this.setVerify( type ); }, // 设置等级 setLevel: function ( _lv ) { this.level = _lv; let txt = ( this.level <= 1 ) ? nx.text.getKey( "GuildNoLimit" ) : this.level; nx.gui.setString( this.nodVerify, "level/edt", txt ); }, // 增减等级 onTogLevel: function ( _key ) { let inc = ( _key == "+" ); let lev = this.level + ( inc ? STEP_LEVEL : -STEP_LEVEL ); if( lev < 1 ) { lev = 1; } if( lev > MAX_LEVEL ) { lev = MAX_LEVEL; } this.setLevel( lev ); }, // 等级编辑 onLevelEditEnd: function( _editor ) { let lev = parseInt( _editor.string ); if( !nx.dt.numGood( lev ) ) { lev = 1; } lev = cc.math.clamp( lev, 1, MAX_LEVEL ); this.setLevel( lev ); }, // 设置战力 setBP: function ( _bp ) { this.bp = _bp; let txt = ( this.bp <= 1 ) ? nx.text.getKey( "GuildNoLimit" ) : this.bp; nx.gui.setString( this.nodVerify, "bp/edt", txt ); }, // 增加战力 onTogBP: function ( _key ) { let inc = ( _key == "+" ); let bp = this.bp + ( inc ? STEP_BP : -STEP_BP ); if( bp < 1 ) { bp = 1; } this.setBP( bp ); }, // 战力编辑 onBPEditEnd: function( _editor ) { let bp = parseInt( _editor.string ); if( !nx.dt.numGood( bp ) ) { bp = 1; } bp = Math.max( 1, bp ); this.setBP( bp ); }, // 点击创建 onTouchCreate: function () { let name = this.edtName.string; if( nx.dt.strEmpty( name ) ) { nx.tbox( "GuildInputNameEmpty" ); return; } let sign = this.edtWords.string; let type = this.verify; let level = ( type == GCVT.Manual ) ? this.level : 1; let bp = ( type == GCVT.Manual ) ? this.bp : 1; GDC.getInstance().reqCreate( name, sign, type, level, bp, ( _ret, _data ) => { if( !_ret ) { nx.tbox( _data ); return; } nx.bridge.createPanel( "WndGuild" ); nx.bridge.closePanel( "WndGuildList" ); } ); }, } );