/****************************************************************** * Copyright(C) 2019 - 2020 Nx Studio * * 主界面 --- 主题入口图标 * * ******************************************************************/ const Trigger = require( "cmp.plot.trigger" ); const NxVisible = require( "nx.vb.visible" ); const CLocker = require( "bridge.condition.locker" ); const NxSpine = require( "nx.fx.spine" ); cc.Class( { extends: cc.Component, properties: { trigger: { default: null, type: Trigger }, locker: { default: null, type: CLocker }, tip: { default: null, type: NxVisible }, spEffect: { default: null, type: NxSpine }, }, // 设置 setTheme: function( _data ) { this.theme = _data || {}; // 置空 if( nx.dt.objEmpty( this.theme ) ) { nx.gui.setActive( this, "on", false ); nx.gui.setActive( this, "off", false ); return; } // 主题图标 let path = cc.path.join( "resDB/acts/icons", this.theme.icon ); nx.gui.setSpriteFrame( this, "on/img", path ); nx.gui.setSpriteFrame( this, "off/img", path ); // 主题名 nx.gui.setString( this, "on/txt", nx.text.getKey( this.theme.name ) ); // 提示 let key = nx.bridge.acts.getThemeTipKey( this.theme.theme_id ); if( this.tip && nx.dt.strNEmpty( key ) ) { this.tip.setTarget( nx.mTip, key ); } // 特效提示 if( nx.dt.strEmpty( this.theme.effect ) ) { this.spEffect.stop(); } else { path = cc.path.join( "resDB/effects", this.theme.effect, "action" ); this.spEffect.play( path, "action", ()=> { }, true ); } // 条件锁 if( this.locker ) { this.locker.setCondition( this.theme.source || 0 ); } }, // 时间刷新 tick: function() { if( !this.theme || nx.gui.isActive( this, "off" ) ) { return; } // 无限时 if( !nx.dt.numPositive( this.theme.end_time, false ) ) { nx.gui.setActive( this, 'on/cd', false ); return; } // 已过期 let tm = nx.bridge.time.cdSimple( this.theme.end_time ); if( nx.dt.strEmpty( tm ) ) { nx.gui.setActive( this, 'on/cd', false ); return; } // 正常 nx.gui.setActive( this, 'on/cd', true ); nx.gui.setString( this, "on/cd/txt", tm ); }, // 点击 onTouch: function() { // 无效主题 if( nx.dt.objEmpty( this.theme ) || nx.dt.arrEmpty( this.theme.theme_holiday_list ) ) { return; } // 如果只有一个活动,直接打开 if( this.theme.theme_holiday_list.length == 1 ) { let ainfo = this.theme.theme_holiday_list[ 0 ]; nx.bridge.jumper.jump2ActPage( ainfo.camp_id ); } else { // 跳转主题页 nx.bridge.jumper.jump2ActTheme( this.theme.theme_id ); } }, } );