author suo
  module FishingJoy { export class FishBtnControl extends BaseUIControl { /**
         * 主场景视图
         */ private _fishBtnView : FishBtnView ; public constructor ( ) { super ( ) ; console . error ( "FishBtnControl constructor" ) ; } /**
         * 初始化
         */ public onInit ( ) { this . _fishBtnView = this . _viewCenter . getView ( FishBtnView ) ; this . _fishBtnView . autoShoot . mouseClickHandler = Handler . create ( this , this . _clickAutoShoot ) ; this . _fishBtnView . frozenShoot . mouseClickHandler = Handler . create ( this , this . _clickFrozenShoot ) ; this . _fishBtnView . aimShoot . mouseClickHandler = Handler . create ( this , this . _clickAimShoot ) ; this . _fishBtnView . gmCheckBox . addEventListener ( egret . TouchEvent . TOUCH_TAP , this . _clickGmCheckBox , this ) ; this . _fishBtnView . gmGroup . addEventListener ( egret . TouchEvent . TOUCH_TAP , this . _clickGmGroup , this ) ; this . _fishBtnView . exitGameBtn . mouseClickHandler = Handler . create ( this , this . _onExitBtnClick ) ; this . _fishBtnView . sceneSwitching . mouseClickHandler = Handler . create ( this , this . _testHandler ) ; this . _fishBtnView . helpBtn . mouseClickHandler = Handler . create ( this , this . _clickHelp ) ; EventManager . registerEvent ( EVENT_ID . PLAY_USE_PORP_EFF , Handler . create ( this , this . setShootEff ) ) ; egret . MainContext . instance . stage . addEventListener ( egret . Event . RESIZE , this . onResize , this ) ; } /**
         * 点击帮助
         */ private _clickHelp ( ) { UICenter . instance . openUI ( commonUI . FishHelp ) ; } /**
         * 切换场景
         */ public dataMy ; private _testHandler ( ) { let mov = UIUtil . creatMovieClip ( "BoomEx_dieEffFrame" ) ; mov . scaleX = uniLib . Global . screenWidth / mov . width * 1.05 ; mov . scaleY = uniLib . Global . screenHeight / mov . height * 1.05 ; mov . x = uniLib . Global . screenWidth / 2 ; mov . y = uniLib . Global . screenHeight / 2 ; mov . blendMode = egret . BlendMode . ADD ; mov . gotoAndPlay ( 1 , - 1 ) ; LayerManager . instance . addToLayer ( mov , LAYER . EFFECT_LOW ) ; } /**
         * 点击退出按钮
         */ private _onExitBtnClick ( ) { game . SoundHand . Instance . playButtonClick ( ) ; egret . MainContext . instance . stage . addEventListener ( egret . TouchEvent . TOUCH_END , this . MenuRecovery , this ) ; this . _fishBtnView . exitGameBtn . visible = false ; uniLib . Global . dispatchEvent ( uniLib . CustomEvent . Show_MenuPanel ) ; } private _clickFrozenShoot ( ) { game . SoundHand . Instance . playButtonClick ( ) ; if ( DataCenter . instance . isSwitchFish ) { GX . Tips . showTips ( "切换鱼潮中,无法开启冰冻道具!" ) ; return ; } if ( ! this . skill ) { let cis = Number ( this . _fishBtnView . frozenQuantity . text ) ; if ( cis <= 0 ) { GX . Tips . showTips ( "没有道具,无法开启!" ) ; return ; } if ( Master . instance . isFrozenShootCooling ) { GX . Tips . showTips ( "道具已使用,无法重复开启!" ) ; return ; } FishingJoyLogic . instance . sendUsePorpMsg ( PROP_TYPE . FREEZE ) ; } else { } } /**
         * 点击自动射击
         */ private _clickAutoShoot ( ) { game . SoundHand . Instance . playButtonClick ( ) ; let battery = FishingJoyLogic . instance . allBattery . get ( Master . instance . uid ) ; if ( battery == null ) { return ; } if ( ! this . skill ) { let isOpen = false ; let config = DataCenter . instance . accessToProps ( 1 ) [ 0 ] ; if ( battery . batteryID < config . needBatteryId ) { GX . Tips . showTips ( "炮台升至" + config . needBatteryId + "才能使用!" ) ; return ; } EventManager . fireEvent ( EVENT_ID . CHANEG_SHOOT_TYPE , [ SHOOT_TYPE . AUTO , ! Master . instance . isAutoShoot ] ) ; } else { EventManager . fireEvent ( EVENT_ID . CHANEG_SHOOT_TYPE , [ SHOOT_TYPE . AUTO , ! Master . instance . isAutoShoot ] ) ; } } /**
         * 关闭
         */ public MenuRecovery ( e ) { if ( e . stageY > 105 ) { uniLib . Global . dispatchEvent ( uniLib . CustomEvent . Remove_MenuPanel ) ; egret . MainContext . instance . stage . removeEventListener ( egret . TouchEvent . TOUCH_END , this . MenuRecovery , this ) ; this . _fishBtnView . exitGameBtn . visible = true ; } } /**
         * 点击瞄准射击
         */ private _clickAimShoot ( ) { game . SoundHand . Instance . playButtonClick ( ) ; let battery = FishingJoyLogic . instance . allBattery . get ( Master . instance . uid ) ; if ( ! battery ) { return ; } if ( ! this . skill ) { let isOpen = false ; let config = DataCenter . instance . accessToProps ( 3 ) [ 0 ] ; if ( ! Master . instance . isAimShoot && battery . batteryID < config . needBatteryId ) { GX . Tips . showTips ( "炮台升至" + config . needBatteryId + "才能使用!" ) ; return ; } if ( Master . instance . isAimShoot == true ) { game . SoundHand . Instance . playAimStart ( ) ; } EventManager . fireEvent ( EVENT_ID . CHANEG_SHOOT_TYPE , [ SHOOT_TYPE . AIM , ! Master . instance . isAimShoot ] ) ; } else { EventManager . fireEvent ( EVENT_ID . CHANEG_SHOOT_TYPE , [ SHOOT_TYPE . AIM , ! Master . instance . isAimShoot ] ) ; } } /**
         * 设置瞄准效果
         */ public setShootEff ( isShow , shootType ) { let mov = null ; if ( shootType == SHOOT_TYPE . AIM ) { mov = this . _fishBtnView . aimShootEff ; } else if ( shootType == SHOOT_TYPE . AUTO ) { mov = this . _fishBtnView . autoShootEff ; } else if ( shootType == SHOOT_TYPE . FREEZE ) { mov = this . _fishBtnView . freezeEff ; } if ( isShow ) { if ( ! mov . isPlaying ) { mov . gotoAndPlay ( 1 , - 1 ) ; } } else { mov . stop ( ) ; } mov . visible = isShow ; } /**
         * 点击急速射击
         */ public _clickFastShoot ( ) { game . SoundHand . Instance . playButtonClick ( ) ; let battery = FishingJoyLogic . instance . allBattery . get ( Master . instance . uid ) ; let isOpen = false ; let config = DataCenter . instance . accessToProps ( 2 ) [ 0 ] ; let duration = config . useTime * 1000 ; let coolingTime = config . coolTime * 1000 ; if ( battery . batteryID < config . needBatteryId ) { GX . Tips . showTips ( "炮台升至" + config . needBatteryId + "才能使用!" ) ; return ; } if ( Master . instance . isFastShootCooling ) { GX . Tips . showTips ( "道具正在冷却,无法开启!" ) ; return ; } if ( duration != 0 && coolingTime != 0 ) { if ( Master . instance . isFastShoot ) { GX . Tips . showTips ( "道具已使用,无法重复开启!" ) ; return ; } } else { isOpen = ! Master . instance . isFastShoot ; } if ( ! Master . instance . isFastShoot ) { if ( duration != 0 && coolingTime != 0 ) { let back1 = UICenter . instance . getManager ( commonUI . FishMainScene ) . getView ( FishingJoy . FishBtnView ) . BtnGroup ; let a = new SkillCDEffect ( back1 , 39.5 , 38.75 , 60 , 60 , duration , coolingTime , SHOOT_TYPE . FAST ) ; } } EventManager . fireEvent ( EVENT_ID . CHANEG_SHOOT_TYPE , [ SHOOT_TYPE . FAST , isOpen ] ) ; } /**
         * 点击冰冻
         */ public _clickFreezeShoot ( ) { if ( GlobeVars . isFreeze ) { return ; } EventManager . fireEvent ( EVENT_ID . CHANEG_SHOOT_TYPE , [ SHOOT_TYPE . FREEZE , true ] ) ; } /**
         * GM点击
         */ private _clickGmCheckBox ( ) { this . _fishBtnView . gmGroup . visible = this . _fishBtnView . gmCheckBox . selected ; } public skill : boolean = false ; /**
         * GM点击
         */ private _clickGmGroup ( e ) { let target = e . target ; if ( target . name == "3" ) { this . _fishBtnView . goldPoolLabel . visible = target . selected ; } if ( target . name == "5" ) { this . skill = target . selected ; } if ( target . selected ) GM . instance . open ( Number ( target . name ) ) ; else GM . instance . close ( Number ( target . name ) ) ; } /**
         * 显示时
         */ public onShow ( ) { } onResize ( ) { this . _fishBtnView . width = uniLib . Global . screenWidth ; } /**
         * 释放
         */ public dispose ( ) { EventManager . unregisterEvent ( EVENT_ID . PLAY_USE_PORP_EFF , this , this . setShootEff ) ; this . _fishBtnView . gmCheckBox . removeEventListener ( egret . TouchEvent . TOUCH_TAP , this . _clickGmCheckBox , this ) ; this . _fishBtnView . gmGroup . removeEventListener ( egret . TouchEvent . TOUCH_TAP , this . _clickGmGroup , this ) ; egret . MainContext . instance . stage . removeEventListener ( egret . TouchEvent . TOUCH_END , this . MenuRecovery , this ) ; egret . MainContext . instance . stage . removeEventListener ( egret . Event . RESIZE , this . onResize , this ) ; this . _fishBtnView = null ; super . dispose ( ) ; } } }