author suo
  module FishingJoy { export class FishingJoyLogic { /**
         * 在屏幕内的鱼字典(key：servelID value：鱼)
         */ public inViewFishes : Dictionary = new Dictionary ( ) ; /**
         * 在屏幕内的子弹字典(场景内所有的子弹 跟表现绑定 key：servelID value：子弹)
         */ public inViewBullets : Dictionary = new Dictionary ( ) ; /**
         * 所有的玩家炮台 key:玩家uid value:battery
         */ public allBattery : SimpleMap < gameObject . Battery > = new SimpleMap < gameObject . Battery > ( ) ; /**
         * 单例
         */ private static _instance : FishingJoyLogic = null ; /**
         * 玩家炮台
         */ public masterBattery : gameObject . Battery = null ; /**
         * 碰撞标记 偶数帧 奇数帧
         */ private _colliderFlag : number = 0 ; /**
         * 子弹分组字典
         */ private _bulletGroupDic : Dictionary = new Dictionary ( ) ; /**
         * 鱼分组字典
         */ private _fishGroupDic : Dictionary = new Dictionary ( ) ; private winAnim0 : egret . MovieClip ; private winAnim1 : egret . MovieClip ; /**
         * 记录每帧打中鱼列表
         */ private hitFishList : Cmd . HitFish [ ] = [ ] ; /**
         * 记录上一次玩家赢得特效
         */ private _lastMasterWinEff : gameObject . MasterWinEff ; /**
         * 金币延迟回收句柄
         */ private _coinTweenDelayHandler : Handler [ ] = [ ] ; /**
         * 延迟回收完毕
         */ public coinDelayTweenComplete : boolean = false ; /**
         * 延迟金币回收
         */ public coinTweenDelayHandlerRun ( ) { let len = this . _coinTweenDelayHandler . length ; for ( let i = 0 ; i < len ; i ++ ) { let handler = this . _coinTweenDelayHandler [ i ] ; handler . run ( ) ; } this . _coinTweenDelayHandler . length = 0 ; this . coinDelayTweenComplete = true ; } public constructor ( ) { } /**
         * 从字典移除子弹
         */ public removeBulletInMap ( servelID ) { if ( ! this . inViewBullets . remove ( servelID ) ) { } } /**
         * 从字典移除鱼
         */ public removeFishInMap ( servelID ) { if ( ! this . inViewFishes . remove ( servelID ) ) { console . assert ( false , "不存在该鱼！" ) ; } } /**
         * 从字典添加鱼
         */ public addFishInMap ( servelID , fish ) { if ( this . inViewFishes . isExist ( servelID ) ) { console . assert ( false , "已经存在该鱼！" ) ; } else { this . inViewFishes . set ( servelID , fish ) ; } } /**
         * 从字典添加子弹
         */ public addBulletInMap ( servelID , bullet ) { if ( this . inViewBullets . isExist ( servelID ) ) { console . assert ( false , "已经存在该子弹！" ) ; } else { this . inViewBullets . set ( servelID , bullet ) ; } } /**
         * 获得单例
         */ public static get instance ( ) : FishingJoyLogic { if ( this . _instance == null ) { this . _instance = new FishingJoyLogic ( ) ; } return this . _instance ; } /**
         * 初始化
         */ public initFishingJoyLogic ( ) { NineGridSplitScreenTool . initValue ( ) ; EventManager . registerEvent ( EVENT_ID . ADD_BATTERY_IN_MAP , Handler . create ( this , this . _addBatteryInMap ) ) ; EventManager . registerEvent ( EVENT_ID . REMOVE_BATTERY_IN_MAP , Handler . create ( this , this . _removeBatteryInMap ) ) ; EventManager . registerEvent ( EVENT_ID . FISH_DIE_ACTION , Handler . create ( this , this . _fishDieAction ) ) ; game . Action . deadFishEvent . add ( this . _deadFishCmd , this ) ; game . Action . spawnFishEvent . add ( this . _spawnFishEvent , this ) ; game . Action . changeSceneEvent . add ( this . changeScene , this ) ; GX . PokerEvent . Instance . roomDataUpdateEvent . add ( this . _roomDataUpdateEvent , this ) ; game . Action . sendBulletEvent . add ( this . _firBullet , this ) ; game . Action . hitFishEvent . add ( this . _hitFishCmd , this ) ; game . Action . actionEvent . add ( this . _receptionOfProps , this ) ; GX . PokerEvent . Instance . moneyUpdate . add ( this . _addScore , this ) ; FishingJoy . Laya . timer . frameLoop ( 1 , this , this . _checkHit ) ; } /**
         * 两颗子弹命中同一条鱼 要返钱
         */ private _addScore ( rev ) { let update = rev . update ; if ( ! update || ! ( update instanceof Array ) ) return ; for ( let item of update ) { let battery = this . allBattery . get ( item . uid ) ; if ( battery ) { if ( item . num ) { let addNum = item . num - battery . money ; if ( item . uid == uniLib . NetMgr . UID ) { let mainUser = game . PokerFunction . MainUser ; if ( mainUser ) { mainUser . point = battery . curMoneyTF ; } } battery . updateGold ( addNum ) ; battery . money = item . num ; } if ( item . changeNum ) { battery . money += item . changeNum ; battery . updateGold ( item . changeNum ) ; } } } } /**
         * 接收道具
         */ private _receptionOfProps ( rev ) { if ( rev . act . op == Cmd . Operation . UseItem ) { let view = UICenter . instance . getManager ( commonUI . FishMainScene ) . getView ( FishBtnView ) ; let sizeMy = 18 ; let config ; let duration ; let coolingTime ; let a ; let back1 = UICenter . instance . getManager ( commonUI . FishMainScene ) . getView ( FishingJoy . FishBtnView ) . BtnGroup ; if ( rev . act . uid == Master . instance . uid ) { if ( rev . act . id ) { if ( rev . act . chipsLeft > 99 ) { sizeMy = 12 ; } if ( rev . act . id == 4 ) { EventManager . fireEvent ( EVENT_ID . FREEZE_FISH_OPERA , [ GlobeVars . FreezeTime , Master . instance . masterBattery , uniLib . Global . screenWidth / 2 , uniLib . Global . screenHeight / 2 ] ) ; view . frozenQuantity . text = ( rev . act . chipsLeft ) . toString ( ) ; view . frozenQuantity . size = sizeMy ; config = DataCenter . instance . accessToProps ( 4 ) [ 0 ] ; duration = config . useTime ; coolingTime = config . coolTime ; a = new SkillCDEffect ( back1 , 39.5 , 36 + 168.68 , 60 , 60 , duration , coolingTime , SHOOT_TYPE . FREEZE ) ; } else if ( rev . act . id == 1 ) { EventManager . fireEvent ( EVENT_ID . CHANEG_SHOOT_TYPE , [ SHOOT_TYPE . AUTO , true ] ) ; view . autoQuantity . text = ( rev . act . chipsLeft ) . toString ( ) ; view . autoQuantity . size = sizeMy ; config = DataCenter . instance . accessToProps ( 1 ) [ 0 ] ; duration = config . useTime ; coolingTime = config . coolTime ; a = new SkillCDEffect ( back1 , 39.5 , 37.75 + 83 , 60 , 60 , duration , coolingTime , SHOOT_TYPE . AUTO ) ; } else if ( rev . act . id == 3 ) { EventManager . fireEvent ( EVENT_ID . CHANEG_SHOOT_TYPE , [ SHOOT_TYPE . AIM , true ] ) ; view . aimQuantity . text = ( rev . act . chipsLeft ) . toString ( ) ; view . aimQuantity . size = sizeMy ; config = DataCenter . instance . accessToProps ( 3 ) [ 0 ] ; duration = config . useTime ; coolingTime = config . coolTime ; a = new SkillCDEffect ( back1 , 39.5 , 38.75 , 60 , 60 , duration , coolingTime , SHOOT_TYPE . AIM ) ; } } } else { if ( rev . act . id == 4 ) { let battery = this . allBattery . get ( rev . act . uid ) ; if ( battery ) { config = DataCenter . instance . accessToProps ( 4 ) [ 0 ] ; duration = config . useTime ; coolingTime = config . coolTime ; EventManager . fireEvent ( EVENT_ID . FREEZE_FISH_OPERA , [ GlobeVars . FreezeTime , battery , uniLib . Global . screenWidth / 2 , uniLib . Global . screenHeight / 2 ] ) ; a = new SkillCDEffect ( back1 , 39.5 , 36 + 168.68 , 60 , 60 , duration , coolingTime , SHOOT_TYPE . FREEZE ) ; } } } } } /**
         * 鱼击中协议
         */ private _hitFishCmd ( rev ) { for ( let hitFish of rev . list ) { let list = hitFish . list ; if ( ! list || ! ( list instanceof Array ) ) continue ; if ( hitFish . hitType == GAMEOBJECT_SIGN . GLOBE_FISH ) { for ( let item of list ) { let fish = this . inViewFishes . get ( item . id ) ; if ( fish && fish . isAlive ) { fish . state ++ ; if ( hitFish . addOdds ) { fish . updateState ( fish . state , hitFish . addOdds ) ; } else { console . assert ( false , "协议有误" ) ; } } } } else if ( hitFish . hitType == GAMEOBJECT_SIGN . MERMAID ) { for ( let item of list ) { let fish = this . inViewFishes . get ( item . id ) ; let uid = hitFish . uid ; let score = item . score ; let battery = this . allBattery . get ( uid ) ; if ( battery ) { battery . money += score ; if ( fish && fish . isAlive ) { let data = < gameObject . IMermaidHeartEff > { } ; data . targetBattery = battery ; data . score = score ; let [ x , y ] = UIUtil . localToGlobal ( fish ) ; data . bornX = x ; data . bornY = y ; gameObject . GameObjectFactory . instance . creatGameObject ( GAMEOBJECT_SIGN . MERMAID_HEART_EFF , data , LAYER . EFFECT_LOW ) ; let revs = new Cmd . DeadFish ( ) ; revs . uid = uid ; let bulletOdds = DataCenter . instance . getBatterIdByIndex ( hitFish . bulletIndex - 1 ) ; if ( ! bulletOdds ) { continue ; } let odds = score / bulletOdds ; this . _coinDozer ( score , odds , revs ) ; game . SoundHand . Instance . playGoldCoin ( ) ; } else { battery . updateGold ( score ) ; } } } } } } /**
         * 预生成鱼
         */ /**
         * 发送地电流协议(suo)
         */ /**
         * 播放死亡 随机电鱼特效(suo)
         */ private _playDieElectricEff ( fishAry , eletricEel ) { let fishMap = FishingJoy . FishingJoyLogic . instance . inViewFishes ; let fishListLen = fishAry . length ; for ( let i = 0 ; i < fishListLen ; i ++ ) { let fish = fishAry [ i ] ; if ( fish && fish . isAlive ) { if ( UIUtil . inAimView ( fish . x , fish . y ) ) { let line = Pool . getItemByCreateFun ( Pool . ElectricEffLine , Handler . create ( this , this . _creatElectricEff , [ "electricLine" , 0.6 ] ) ) ; line . x = eletricEel . x ; line . y = eletricEel . y ; let scale = Math . sqrt ( ( fish . x - eletricEel . x ) * ( fish . x - eletricEel . x ) + ( fish . y - eletricEel . y ) * ( fish . y - eletricEel . y ) ) / ( line . width - 70 ) ; if ( scale < 0.1 ) { scale = 0.1 ; } let rotation = GX . getRadianByPoint ( { x : eletricEel . x , y : eletricEel . y } , { x : fish . x , y : fish . y } ) ; line . rotation = rotation - 90 ; FishingJoy . LayerManager . instance . addToLayer ( line , LAYER . ElectricEFF ) ; UIUtil . playAndAutoRemove ( line , 2 , Handler . create ( Pool , Pool . recover , [ Pool . ElectricEffLine , line ] , true ) ) ; egret . Tween . get ( line ) . set ( { scaleX : 0.1 } ) . to ( { scaleX : scale } , MathUtil . random ( 100 , 300 ) ) . call ( ( ) => { let burst = Pool . getItemByCreateFun ( Pool . ElectricEffBurst , Handler . create ( this , this . _creatElectricEff , [ "electricBrust" , 0.3 ] ) ) ; burst . x = fish . x ; burst . y = fish . y ; UIUtil . playAndAutoRemove ( burst , 2 , Handler . create ( Pool , Pool . recover , [ Pool . ElectricEffBurst , burst ] , true ) ) ; FishingJoy . LayerManager . instance . addToLayer ( burst , LAYER . ElectricEFF ) ; } ) ; } } } let [ x , y ] = UIUtil . localToGlobal ( eletricEel . eletricEff ) ; eletricEel . eletricEff . x = x ; eletricEel . eletricEff . y = y ; LayerManager . instance . addToLayer ( eletricEel . eletricEff , LAYER . ElectricEFF_BURST ) ; } /**
         * 创建特效
         */ private _creatElectricEff ( groupName , scale = 0.3 ) { let mov = UIUtil . creatMovieClip ( groupName ) ; if ( groupName == "electricBrust" ) { mov . scaleX = mov . scaleY = scale ; } else if ( groupName == "electricLine" ) { mov . scaleY = scale ; } return mov ; } private _roomDataUpdateEvent ( rev ) { this . destroyBullets ( ) ; this . _destroyFishes ( ) ; DataCenter . instance . sceneId = rev . roomData . sceneId ; this . changeScene ( null , null , true , false ) ; let spawnFish = new Cmd . SpawnFishCmd_S ( ) ; spawnFish . fishlist = rev . roomData . fishlist ; this . _spawnFishEvent ( spawnFish , true ) ; let bullet = rev . roomData . bulletinfo ; let serverNow = game . GameTime . serverNow ( ) ; FishingJoy . Laya . timer . once ( 300 , this , ( ) => { if ( bullet ) { for ( let item of bullet ) { if ( serverNow - item . fireTime < 4000 ) this . _firBullet ( item , true ) ; } } } ) ; let seatList = game . RoomData . Instance . seatList ; for ( let item of seatList ) { item . lockChanged . call ( item ) ; } } /**
         * 玩家信息更新(gepan)
         */ /**
         *退潮(ssq)
         */ public changeScene ( rev , sceneId ? , revert ? , isPlayTween = true ) { if ( rev ) { DataCenter . instance . isSwitchFish = true ; OperationManager . instance . leaveQuickly ( ) ; DataCenter . instance . sceneId = rev . sceneId ; EventManager . fireEvent ( EVENT_ID . EBB_TIDE ) ; } else { if ( GlobeVars . isFreeze ) { GlobeVars . isDelayEbb = true ; GlobeVars . delayEbbHandler = Handler . create ( this , this . _showEbbEff , [ rev , sceneId , revert , isPlayTween ] , true ) ; return ; } } this . _showEbbEff ( rev , sceneId , revert , isPlayTween ) ; } /**
         * 显示退潮效果(ssq)
         */ private _showEbbEff ( rev , sceneId ? , revert ? , isPlayTween ? ) { let revertImage = "bg" + DataCenter . instance . sceneId + "_jpg" ; let view = UICenter . instance . getManager ( commonUI . FishMainScene ) . getView ( FishMainSceneView ) ; let back0 = view . backGround0 ; if ( ! isPlayTween ) { back0 . source = revert ? revertImage : "bg" + sceneId + "_jpg" ; return ; } let back1 = view . backGrounds1 ; let sprayGroup = view . sprayGroups ; let bgScale = 1.05 ; let bgOffsetX = 1280 * ( bgScale - 1 ) ; LayerManager . instance . addToLayer ( sprayGroup , LAYER . Wave ) ; LayerManager . instance . addToLayer ( back1 , LAYER . back ) ; view . stopMoveBg ( ) ; back1 . rotation = back0 . rotation ; back0 . x = uniLib . Global . screenWidth / 2 ; back0 . y = back1 . y ; let data ; if ( rev || sceneId ) { data = rev ? DataCenter . instance . sceneId : sceneId ; } let jianbianImages = view . jianbianImages ; jianbianImages . source = rev ? "jianbian_png" : "jianbian1_png" ; if ( rev ) { back1 . x = uniLib . Global . screenWidth * bgScale * 1.5 - 40 ; sprayGroup . x = uniLib . Global . screenWidth + 16 + bgOffsetX ; jianbianImages . x = - 90 - bgOffsetX ; } else { back1 . x = - uniLib . Global . screenWidth * bgScale * 0.5 ; sprayGroup . x = - uniLib . Global . screenWidth - 16 - bgOffsetX ; jianbianImages . x = 177 + bgOffsetX ; } if ( isPlayTween && sceneId ) { game . SoundHand . Instance . playGoldTide ( ) ; game . SoundHand . Instance . playBgMusic ( ) ; } else if ( isPlayTween ) { game . SoundHand . Instance . playChangeTheSpecialBackground ( ) ; game . SoundHand . Instance . playBgMusic ( ) ; } egret . Tween . removeTweens ( back0 ) ; egret . Tween . removeTweens ( back1 ) ; egret . Tween . removeTweens ( sprayGroup ) ; let langhuaString = rev ? "langbo" : "langbo1" ; sprayGroup . removeChildren ( ) ; let ebbTideMov = Pool . getItemByCreateFun ( langhuaString , Handler . create ( UIUtil , UIUtil . creatMovieClip , [ langhuaString ] ) ) ; sprayGroup . addChild ( ebbTideMov ) ; sprayGroup . addChild ( jianbianImages ) ; ebbTideMov . y = 360 ; ebbTideMov . gotoAndPlay ( 1 , - 1 ) ; ebbTideMov . x = rev ? - bgOffsetX + 50 : uniLib . Global . screenWidth + bgOffsetX ; GlobeVars . ebbTideMov = ebbTideMov ; GlobeVars . isGoldEbb = true ; back1 . source = data ? "bg" + data + "_jpg" : "bg" + DataCenter . instance . sceneId + "_jpg" ; egret . Tween . get ( back0 ) . to ( { x : rev ? - uniLib . Global . screenWidth * bgScale * 0.5 : uniLib . Global . screenWidth * bgScale * 1.5 } , uniLib . Global . screenWidth * 1.6 ) . call ( ( ) => { back0 . source = data ? "bg" + data + "_jpg" : "bg" + DataCenter . instance . sceneId + "_jpg" ; back0 . x = uniLib . Global . screenWidth * bgScale * 0.5 ; } ) ; egret . Tween . get ( back1 ) . to ( { x : uniLib . Global . screenWidth * bgScale / 2 } , uniLib . Global . screenWidth * 1.6 ) . call ( ( ) => { back1 . x = uniLib . Global . screenWidth ; back1 . source = "" ; } ) ; egret . Tween . get ( sprayGroup ) . to ( { x : rev ? - uniLib . Global . screenWidth - 16 - bgOffsetX : uniLib . Global . screenWidth + 16 + bgOffsetX } , 3.2 * ( uniLib . Global . screenWidth + 16 ) ) . call ( ( ) => { ebbTideMov . stop ( ) ; sprayGroup . removeChild ( ebbTideMov ) ; Pool . recover ( langhuaString , ebbTideMov ) ; LayerManager . instance . removeFromLayer ( sprayGroup ) ; LayerManager . instance . removeFromLayer ( back1 ) ; GlobeVars . isGoldEbb = false ; if ( GlobeVars . isDelayEbb ) { GlobeVars . isDelayEbb = false ; } view . startMoveBg ( ) ; } ) ; let cmd = new Cmd . GameTimeSyncCmd_CS ( ) ; game . PokerFunction . tcpSend ( cmd ) ; } /**
         *免费游戏获取金币(ssq)
         */ public freeAccessToQuotas ( uid , x , y , score ) { let TextNew = Pool . getItemByClass ( Pool . jumpCoinTextsFree , eui . BitmapLabel ) ; TextNew . alpha = 1 ; if ( uid == Master . instance . uid ) { TextNew . font = "coinFont_fish_fnt" ; UIUtil . traGoldLabel ( TextNew ) ; } else { TextNew . font = "coinFont_fishS_fnt" ; } TextNew . text = "+" + GX . GoldFormat ( score , true , true , false ) ; LayerManager . instance . addToLayer ( TextNew , LAYER . EFFECT_LOW ) ; TextNew . x = x ; TextNew . y = y > uniLib . Global . screenHeight / 2 ? y - 80 : y + 80 ; game . Timer . setTimeout ( ( ) => { egret . Tween . get ( TextNew ) . to ( { alpha : 0 } , 2000 ) . call ( ( ) => { Pool . recover ( Pool . jumpCoinTextsFree , TextNew ) ; LayerManager . instance . removeFromLayer ( TextNew ) ; } ) ; } , this , 1000 ) ; } /**
         * 发射子弹(suo)
         */ private _firBullet ( bulletInfo , isResconnect = false ) { let battery = FishingJoyLogic . instance . allBattery . get ( bulletInfo . uid ) ; if ( battery == null ) { return ; } let serverNow = game . GameTime . serverNow ( ) ; if ( serverNow - bulletInfo . fireTime < 1000 ) { bulletInfo . fireTime = serverNow ; } bulletInfo . angle = bulletInfo . angle < 0 ? bulletInfo . angle + 360 : bulletInfo . angle ; bulletInfo . angle = bulletInfo . angle > 360 ? bulletInfo . angle - 360 : bulletInfo . angle ; if ( ! isResconnect ) { if ( bulletInfo . uid == uniLib . NetMgr . UID ) { if ( bulletInfo . id < 0 ) { } else { battery . money -= bulletInfo . cost ; battery . updateGold ( - bulletInfo . cost ) ; } } else { battery . money -= bulletInfo . cost ; battery . updateGold ( - bulletInfo . cost ) ; } } if ( battery . isAimShoot ) { this . _fire ( battery , bulletInfo , battery . curRotation ) ; } else { let bulletRotation = bulletInfo . angle ; if ( bulletInfo . uid == uniLib . NetMgr . UID ) { if ( bulletInfo . id < 0 ) { battery . setTweenRotation ( bulletRotation , Handler . create ( this , this . _fire , [ battery , bulletInfo , bulletRotation ] , true ) ) ; } else { FishingJoy . Laya . timer . once ( 150 , this , this . _fire , [ battery , bulletInfo , bulletRotation ] ) ; } } else { battery . setTweenRotation ( bulletRotation , Handler . create ( this , this . _fire , [ battery , bulletInfo , bulletRotation ] , true ) ) ; } } } /**
         * 发射(suo)
         */ private _fire ( battery , bulletInfo , bulletRotation ) { let startPoint = Point . create ( 0 , 0 ) ; let fishLayer = LayerManager . instance . getLayer ( LAYER . Fish ) ; battery . firePoint . localToGlobal ( 0 , 0 , startPoint ) ; fishLayer . globalToLocal ( startPoint . x , startPoint . y , startPoint ) ; let vars = < gameObject . IBulletVars > { } ; vars . bornX = startPoint . x ; vars . bornY = startPoint . y ; Point . release ( startPoint ) ; vars . rotation = bulletRotation ; vars . servelID = bulletInfo . id ; vars . battery = battery ; if ( Master . instance . uid == bulletInfo . uid ) { if ( battery . fireBulletNum == 1 ) { vars . sign = GAMEOBJECT_SIGN . BULLET_SELF ; } else if ( battery . fireBulletNum == 2 ) { vars . sign = GAMEOBJECT_SIGN . BULLET_SELF_2 ; } else if ( battery . fireBulletNum == 3 ) { vars . sign = GAMEOBJECT_SIGN . BULLET_SELF_3 ; } if ( bulletInfo . id < 0 ) { vars . isReal = false ; vars . isVisible = true ; battery . sendBulletEffect ( ) ; game . SoundHand . Instance . playLowSpeedGun ( ) ; } else { vars . isReal = true ; vars . isVisible = false ; } } else { if ( battery . fireBulletNum == 1 ) { vars . sign = GAMEOBJECT_SIGN . BULLET_OTHER ; } else if ( battery . fireBulletNum == 2 ) { vars . sign = GAMEOBJECT_SIGN . BULLET_OTHER_2 ; } else if ( battery . fireBulletNum == 3 ) { vars . sign = GAMEOBJECT_SIGN . BULLET_OTHER_3 ; } battery . sendBulletEffect ( ) ; vars . isReal = true ; vars . isVisible = true ; } if ( battery . isAimShoot ) { let fish = FishingJoy . FishingJoyLogic . instance . inViewFishes . get ( battery . targetFishId ) ; vars . targetFish = fish ; vars . bornTime = bulletInfo . fireTime ; } else { vars . bornTime = bulletInfo . fireTime + 150 ; } vars . operation = [ < gameObject . IOperation > { type : battery . isAimShoot ? OPERATION_TYPE . BulletTrack : OPERATION_TYPE . BULLET , rotation : bulletRotation , } ] ; vars . playerUID = bulletInfo . uid ; gameObject . GameObjectFactory . instance . creatGameObject ( vars . sign , vars , LAYER . Bullet ) ; } /**
         * 打死鱼
         */ private _deadFishCmd ( rev ) { if ( rev . list == null || ! ( rev . list instanceof Array ) ) return ; for ( let item of rev . list ) { this . _deadFish ( item ) ; } } /**
         * 打死鱼(suo)
         */ private _deadFish ( deadInfo ) { let bullet = this . inViewBullets . get ( deadInfo . bid ) ; if ( bullet ) { let bornX = bullet . x ; let bornY = bullet . y ; gameObject . GameObjectFactory . instance . recoverGameObject ( bullet ) ; let data = < gameObject . IGameObjectVars > { } ; data . bornX = bornX ; data . bornY = bornY ; let fishingNet = gameObject . GameObjectFactory . instance . creatGameObject ( GAMEOBJECT_SIGN . FishingNet_Green , data , LAYER . FishingNet ) ; } let bulletOdds = DataCenter . instance . getBatterIdByIndex ( deadInfo . bulletIndex - 1 ) ; if ( ! bulletOdds ) { console . assert ( false , "协议有误" ) ; return ; } let scoreSum = 0 ; let oddsSum = 0 ; let deadFishAry = [ ] ; let fishMap = this . inViewFishes ; let fishList = deadInfo . list ; let skill = 0 ; let fishType = 0 ; let battery = this . allBattery . get ( deadInfo . uid ) ; if ( battery ) { for ( let i = 0 ; i < fishList . length ; i ++ ) { battery . money += fishList [ i ] . score ; } } for ( let i = 0 ; i < fishList . length ; i ++ ) { let fish = fishMap . get ( fishList [ i ] . id ) ; if ( fish && fish . isAlive ) { if ( fish . skillID == 1 || fish . skillID == 3 ) { skill = fish . skillID ; } if ( fish . fishType == 1 ) { fishType = 1 ; } let score = fishList [ i ] . score ; fish . score = score ; scoreSum += score ; let odds = score / bulletOdds ; fish . odds = odds ; fish . items = fishList [ i ] . items ; oddsSum += odds ; deadFishAry . push ( fish ) ; } else { let battery = this . allBattery . get ( deadInfo . uid ) ; if ( battery ) { battery . updateGold ( fishList [ i ] . score ) ; } } } this . _checkDeadType ( deadInfo . deadType , deadFishAry . slice ( ) , deadInfo . uid , scoreSum ) ; if ( deadInfo . deadType == GAMEOBJECT_SIGN . BOOM_EX_FISH ) { } else { for ( let i = 0 ; i < deadFishAry . length ; i ++ ) { let fish = deadFishAry [ i ] ; this . _fishDieAction ( fish , deadInfo . uid ) ; } } if ( ! game . Config . fluencyModel ) { FishingJoy . Laya . timer . once ( 2000 , null , ( scoreSum , oddsSum , rev , skill ) => { if ( fishType != 1 ) { this . _getMedal ( scoreSum , oddsSum , deadInfo , skill ) ; } this . _coinDozer ( scoreSum , oddsSum , deadInfo ) ; } , [ scoreSum , oddsSum , deadInfo , skill ] , false ) ; } if ( deadInfo . uid == uniLib . NetMgr . UID && scoreSum > DataCenter . instance . noticeTriggers ) { let cmd = new Cmd . ClientSettleFinishCmd_C ( ) ; game . PokerFunction . tcpSend ( cmd ) ; } if ( deadInfo . uid == Master . instance . uid ) { game . SoundHand . Instance . playCatch ( ) ; game . SoundHand . Instance . playCatchS ( oddsSum ) ; } } /**
         * 鱼的死亡动作(suo)
         */ private _fishDieAction ( fish , playerID , isBoomEx = false ) { fish . isAlive = false ; fish . unregisterOperation ( ) ; let [ fishX , fishY ] = UIUtil . localToGlobal ( fish ) ; if ( fish . sign == GAMEOBJECT_SIGN . ELECTRIC_EEL ) { FishingJoy . Laya . timer . once ( 1500 , this , this . _fishDieActionEnd , [ fish , fishX , fishY , playerID , isBoomEx ] , false ) ; } else { fish . playDieAction ( Handler . create ( this , this . _fishDieActionEnd , [ fish , fishX , fishY , playerID , isBoomEx ] , true ) ) ; } } /**
        * 道具掉落(ssq)
        */ private thePropsFall ( xJd , yJd , playerUID , propId , propNum ) { let view = UICenter . instance . getManager ( commonUI . FishMainScene ) . getView ( FishBtnView ) ; let battery = this . allBattery . get ( playerUID ) ; if ( battery == null ) { return ; } let imageMy = Pool . getItemByClass ( Pool . commonIMG , eui . Image ) ; let pont ; if ( propId == 1 ) { imageMy . source = "fishZD2" ; } else if ( propId == 3 ) { imageMy . source = "fishMZ2" ; } else if ( propId == 4 ) { imageMy . source = "fishBD2" ; } else { return ; } LayerManager . instance . addToLayer ( imageMy , LAYER . EFFECT_LOW ) ; imageMy . x = xJd ; imageMy . y = yJd ; imageMy . scaleX = 1 ; imageMy . scaleY = 1 ; imageMy . width = 79 ; imageMy . height = 79 ; imageMy . anchorOffsetX = imageMy . width / 2 ; imageMy . anchorOffsetY = imageMy . height / 2 ; if ( playerUID == Master . instance . uid ) { if ( propId == 1 ) { pont = UIUtil . localToGlobal ( view . skin [ "autoShoot" ] ) ; } else if ( propId == 3 ) { pont = UIUtil . localToGlobal ( view . skin [ "aimShoot" ] ) ; } else if ( propId == 4 ) { pont = UIUtil . localToGlobal ( view . skin [ "frozenShoot" ] ) ; } } else { pont = UIUtil . localToGlobal ( battery . focus ) ; } egret . Tween . get ( imageMy ) . to ( { y : yJd - 100 } , 200 ) . to ( { y : yJd } , 400 , egret . Ease . backInOut ) . wait ( 200 ) . to ( { x : pont [ 0 ] + imageMy . width / 2 , y : pont [ 1 ] + imageMy . height / 2 , scaleX : 0.2 , scaleY : 0.2 } , 500 ) . call ( ( imageMy ) => { if ( playerUID == Master . instance . uid ) { if ( propId == 4 ) { view . frozenQuantity . text = propNum . toString ( ) ; this . increaseOfProps ( view . frozenQuantity , propNum ) ; } else if ( propId == 1 ) { view . autoQuantity . text = propNum . toString ( ) ; this . increaseOfProps ( view . autoQuantity , propNum ) ; } else if ( propId == 3 ) { view . aimQuantity . text = propNum . toString ( ) ; this . increaseOfProps ( view . aimQuantity , propNum ) ; } } Pool . recover ( Pool . commonIMG , imageMy ) ; LayerManager . instance . removeFromLayer ( imageMy , LAYER . EFFECT_LOW ) ; } , null , [ imageMy ] ) ; } /**
         * 道具数量增加动画
         */ private increaseOfProps ( item , num ) { item . text = num . toString ( ) ; item . anchorOffsetX = item . textWidth / 2 ; item . anchorOffsetY = item . textHeight / 2 ; egret . Tween . get ( item ) . to ( { scaleX : 1.7 , scaleY : 1.7 } , 350 , egret . Ease . backOut ) . wait ( 100 ) . to ( { scaleX : 1 , scaleY : 1 } , 200 ) ; } /**
         * 检测死亡类型
         */ private _checkDeadType ( deadType , fishAry , playerID , scoreSum ) { if ( deadType == GAMEOBJECT_SIGN . ELECTRIC_EEL ) { let eletricEel = null ; for ( let i = 0 ; i < fishAry . length ; i ++ ) { let fish = fishAry [ i ] ; if ( fish . sign == GAMEOBJECT_SIGN . ELECTRIC_EEL ) { eletricEel = fish as gameObject . ElectricEel ; break ; } } if ( eletricEel ) { fishAry . remove ( eletricEel ) ; this . _playDieElectricEff ( fishAry , eletricEel ) ; } } else if ( deadType == GAMEOBJECT_SIGN . BOOM_EX_FISH ) { let boomExFish = null ; for ( let i = 0 ; i < fishAry . length ; i ++ ) { let fish = fishAry [ i ] ; if ( fish . sign == GAMEOBJECT_SIGN . BOOM_EX_FISH ) { boomExFish = fish as gameObject . BoomFishEx ; this . _fishDieAction ( fish , playerID ) ; break ; } } if ( boomExFish ) { fishAry . remove ( boomExFish ) ; let data = < gameObject . IBoomEffVars > { } ; data . boomFishEx = boomExFish ; data . deadFishList = fishAry ; data . playerID = playerID ; data . scoreSum = scoreSum ; gameObject . GameObjectFactory . instance . creatGameObject ( GAMEOBJECT_SIGN . BOOM_EX_EFF , data , LAYER . EFFECT_MEDIUM ) ; } } } /**
         * 鱼死亡动作结束
         */ private _fishDieActionEnd ( fish , x , y , playerUID , isBoomEx = false ) { if ( fish . items && fish . items . length ) { this . thePropsFall ( x , y , playerUID , fish . items [ 0 ] . id , fish . items [ 0 ] . num ) ; } this . _checkSpecialFish ( x , y , fish , playerUID ) ; if ( fish . sign != GAMEOBJECT_SIGN . MERMAID && fish . sign != GAMEOBJECT_SIGN . DRAGON ) { this . showGoldAni ( x , y , fish , playerUID , isBoomEx ) ; } gameObject . GameObjectFactory . instance . recoverGameObject ( fish ) ; } /**
         * 检测是否特殊鱼
         */ private _checkSpecialFish ( fishX , fishY , fish , playerUID ) { if ( fish . sign == GAMEOBJECT_SIGN . BOOM_FISH ) { this . _showBurst ( fishX , fishY ) ; } else if ( fish . sign == GAMEOBJECT_SIGN . MERMAID ) { let data = < gameObject . IMermaidEffVars > { } ; data . targetBattery = FishingJoyLogic . instance . allBattery . get ( playerUID ) ; if ( data . targetBattery && data . targetBattery . user ) { this . freePromptCloses ( ) ; game . SoundHand . Instance . playMermaidCapture ( ) ; data . bornX = uniLib . Global . screenWidth / 2 ; data . bornY = uniLib . Global . screenHeight / 2 + 50 ; data . score = fish . score ; data . playerNickName = data . targetBattery . user . nickName ; gameObject . GameObjectFactory . instance . creatGameObject ( GAMEOBJECT_SIGN . MERMAID_EFF , data , LAYER . EFFECT_BIG ) ; } } else if ( fish . sign == GAMEOBJECT_SIGN . DRAGON ) { let data = < gameObject . IDragonEffVars > { } ; data . targetBattery = FishingJoyLogic . instance . allBattery . get ( playerUID ) ; if ( data . targetBattery && data . targetBattery . user ) { this . freePromptCloses ( ) ; game . SoundHand . Instance . playGoldenDragonCapture ( ) ; data . bornX = uniLib . Global . screenWidth / 2 ; data . bornY = uniLib . Global . screenHeight / 2 + 50 ; data . score = fish . score ; data . playerNickName = data . targetBattery . user . nickName ; gameObject . GameObjectFactory . instance . creatGameObject ( GAMEOBJECT_SIGN . DRAGON_EFF , data , LAYER . EFFECT_BIG ) ; } } } /**
         * 爆炸鱼特效
         */ private _showBurst ( bornX , bornY ) { let mov = Pool . getItemByCreateFun ( Pool . Boom , Handler . create ( UIUtil , UIUtil . creatMovieClip , [ "Bomb" ] , true ) ) ; mov . y = bornY ; mov . x = bornX ; mov . gotoAndPlay ( 1 , 1 ) ; LayerManager . instance . addToLayer ( mov , LAYER . EFFECT_LOW ) ; game . SoundHand . Instance . playBlast ( ) ; mov . once ( egret . Event . COMPLETE , ( e ) => { LayerManager . instance . removeFromLayer ( mov ) ; Pool . recover ( Pool . Boom , e . target ) ; } , null ) ; } /**
         * 金色灰色爆炸
         */ private _creatGoldBurst ( isSelf ) { if ( isSelf ) { let mov = UIUtil . creatMovieClip ( "by_BurstGold" ) ; mov . name = "by_BurstGold" ; mov . blendMode = egret . BlendMode . ADD ; mov . frameRate = 10 ; return mov ; } else { let mov = UIUtil . creatMovieClip ( "by_BurstGray" ) ; mov . name = "by_BurstGray" ; mov . blendMode = egret . BlendMode . ADD ; mov . frameRate = 10 ; mov . alpha = 0.7 ; return mov ; } } /**
         * 显示金币动画
         */ public showGoldAni ( x , y , fish , uid , isBoomEx ) { let battery = this . allBattery . get ( uid ) ; if ( battery == null || battery . user == null ) return ; let odds = fish . odds ; let score = fish . score ; this . _showGoldLabel ( battery , score , x , y ) ; let burstMovBG ; let burstMovCoin ; if ( odds >= 30 && odds <= 60 ) { if ( uid == Master . instance . uid ) { burstMovBG = Pool . getItemByCreateFun ( Pool . by_BurstGold , Handler . create ( this , this . _creatGoldBurst , [ true ] , true ) ) ; burstMovBG . scaleX = burstMovBG . scaleY = 1 ; burstMovCoin = Pool . getItemByCreateFun ( Pool . by_BurstMoneyGold_S , Handler . create ( UIUtil , UIUtil . creatMovieClip , [ "by_BurstMoneyGold_S" ] , true ) ) ; burstMovCoin . name = "by_BurstMoneyGold_S" ; burstMovCoin . scaleX = burstMovCoin . scaleY = 0.8 ; game . SoundHand . Instance . playCoinSound ( ) ; } else { burstMovBG = Pool . getItemByCreateFun ( Pool . by_BurstGray , Handler . create ( this , this . _creatGoldBurst , [ false ] , true ) ) ; burstMovBG . scaleX = burstMovBG . scaleY = 1 ; burstMovCoin = Pool . getItemByCreateFun ( Pool . by_BurstMoneyGray_S , Handler . create ( UIUtil , UIUtil . creatMovieClip , [ "by_BurstMoneyGray_S" ] , true ) ) ; burstMovCoin . scaleX = burstMovCoin . scaleY = 0.8 ; burstMovCoin . name = "by_BurstMoneyGray_S" ; } } else if ( odds > 60 ) { if ( uid == Master . instance . uid ) { burstMovBG = Pool . getItemByCreateFun ( Pool . by_BurstGold , Handler . create ( this , this . _creatGoldBurst , [ true ] , true ) ) ; burstMovBG . scaleX = burstMovBG . scaleY = 2.5 ; game . SoundHand . Instance . playCoinSound ( ) ; } else { burstMovBG = Pool . getItemByCreateFun ( Pool . by_BurstGray , Handler . create ( this , this . _creatGoldBurst , [ false ] , true ) ) ; burstMovBG . scaleX = burstMovBG . scaleY = 2.5 ; } } if ( burstMovCoin ) { burstMovCoin . x = x ; burstMovCoin . y = y ; burstMovCoin . gotoAndPlay ( 1 , 1 ) ; LayerManager . instance . addToLayer ( burstMovCoin , LAYER . EFFECT_LOW ) ; burstMovCoin . once ( egret . MovieClipEvent . COMPLETE , ( e ) => { let mov = e . target ; if ( mov . name == "by_BurstMoneyGold_S" ) { Pool . recover ( Pool . by_BurstMoneyGold_S , mov ) ; } else if ( mov . name == "by_BurstMoneyGray_S" ) { Pool . recover ( Pool . by_BurstMoneyGray_S , mov ) ; } else if ( mov . name == "by_BurstMoneyGold_B" ) { Pool . recover ( Pool . by_BurstMoneyGold_B , mov ) ; } else { Pool . recover ( Pool . by_BurstMoneyGray_B , mov ) ; } LayerManager . instance . removeFromLayer ( mov , LAYER . EFFECT_LOW ) ; } , null ) ; } if ( burstMovBG ) { if ( ! game . Config . fluencyModel ) ShakeTool . Instance . shakeObj ( GX . GameLayerManager . sceneLayer . parent , 1 , 15 , 15 ) ; burstMovBG . x = x ; burstMovBG . y = y ; burstMovBG . gotoAndPlay ( 1 , 1 ) ; LayerManager . instance . addToLayer ( burstMovBG , LAYER . EFFECT_LOW ) ; burstMovBG . once ( egret . MovieClipEvent . COMPLETE , ( e ) => { let mov = e . target ; if ( mov . name == "by_BurstGold" ) { Pool . recover ( Pool . by_BurstGold , mov ) ; } else { Pool . recover ( Pool . by_BurstGray , mov ) ; } LayerManager . instance . removeFromLayer ( mov ) ; } , null ) ; this . _showGoldTween ( battery , x , y , odds , true , score , isBoomEx ) ; } else { this . _showGoldTween ( battery , x , y , odds , false , score , isBoomEx ) ; } } /**
         * +多少金币的艺术字
         */ private _showGoldLabel ( battery , score , startX , startY ) { let TextNew ; if ( battery . user && battery . user . uid == Master . instance . uid ) { game . SoundHand . Instance . playGoldCoin ( ) ; TextNew = Pool . getItemByClass ( Pool . jumpCoinText , eui . BitmapLabel ) ; TextNew . font = "flutters1_fnt" ; TextNew . name = "jumpCoinText" ; } else { TextNew = Pool . getItemByClass ( Pool . jumpCoinTexts , eui . BitmapLabel ) ; TextNew . alpha = 0.7 ; TextNew . font = "flutters2_fnt" ; TextNew . name = "jumpCoinTexts" ; } TextNew . text = "+" + GX . GoldFormat ( score , true , true , false ) ; TextNew . scaleX = 0.8 ; TextNew . scaleY = 0.8 ; TextNew . x = startX - ( TextNew . textWidth / 2 ) ; TextNew . y = startY - 25 ; LayerManager . instance . addToLayer ( TextNew , LAYER . EFFECT_LOW ) ; FishingJoy . Laya . timer . once ( 1000 , this , ( TextNew ) => { TextNew . scaleY = TextNew . scaleX = 1 ; if ( TextNew . name == "jumpCoinText" ) { Pool . recover ( Pool . jumpCoinText , TextNew ) ; } else if ( TextNew . name == "jumpCoinTexts" ) { Pool . recover ( Pool . jumpCoinTexts , TextNew ) ; } else { console . assert ( false , "逻辑有误" ) ; } LayerManager . instance . removeFromLayer ( TextNew ) ; } , [ TextNew ] ) ; } /**
         * 金币动画表现
         */ private _showGoldTween ( battery , startX , startY , odds , isBurstTween , score , isBoomEx ) { let radius = 0 ; let coinNum ; if ( odds > 0 && odds <= 5 ) { coinNum = 2 ; } else if ( odds > 5 && odds <= 10 ) { coinNum = 3 ; } else if ( odds > 10 && odds < 30 ) { coinNum = 5 ; } else if ( odds >= 30 && odds <= 60 ) { coinNum = 12 ; radius = 80 ; } else if ( odds > 60 && odds <= 90 ) { coinNum = 15 ; radius = 120 ; } else if ( odds > 90 ) { coinNum = 30 ; radius = 120 ; } else { console . assert ( false , "逻辑有误！" ) ; } let [ endX , endY ] = UIUtil . localToGlobal ( battery . coinImg ) ; let seat = game . GameConstant . SeatPositonList [ game . GameConstant . GetClientNoBySeatId ( battery . seatdata . seatId ) - 1 ] ; let time = GX . getDistanceByPoint ( { x : startX , y : startY } , { x : seat . x , y : seat . y } ) * 1.5 ; if ( time < 200 ) { time = 200 ; } for ( var i = 0 ; i < coinNum ; ++ i ) { let mov ; if ( battery . user . uid == Master . instance . uid ) { mov = Pool . getItemByCreateFun ( Pool . commonGold , Handler . create ( GlobeVars , GlobeVars . creatCommonCoin , null , true ) ) ; mov . name = "commonGold" ; } else { mov = Pool . getItemByCreateFun ( Pool . commonGrayGold , Handler . create ( GlobeVars , GlobeVars . creatCommonGrayCoin , null , true ) ) ; mov . name = "commonGrayGold" ; mov . alpha = 0.9 ; mov . scaleX = mov . scaleY = 0.6 ; } mov . gotoAndPlay ( 1 , - 1 ) ; LayerManager . instance . addToLayer ( mov , LAYER . EFFECT_LOW ) ; if ( isBurstTween ) { this . _goldBurstTween ( mov , i , coinNum , startX , startY , endX , endY , time , battery , radius , score , isBoomEx ) ; } else { this . _goldJumpTween ( mov , i , coinNum , startX , startY , endX , endY , time , battery , score , isBoomEx ) ; } } } /**
         * 金币跳动Tween动画
         */ private _goldJumpTween ( mov , i , goldNum , startX , startY , endX , endY , time , battery , score , isBoomEx ) { mov . x = startX + i * 45 - goldNum / 2 * 45 ; mov . y = startY ; mov . rotation = 0 ; let tween = egret . Tween . get ( mov ) . wait ( i * 100 ) . to ( { y : startY - 50 } , 200 ) . to ( { y : startY + 80 } , 400 , egret . Ease . backInOut ) . to ( { y : startY + 30 } , 200 ) ; if ( isBoomEx && ! this . coinDelayTweenComplete ) { this . _coinTweenDelayHandler . push ( Handler . create ( this , this . _delayCoinTween , [ endX , endY , time , mov , battery , i , goldNum , score ] , true ) ) ; } else { tween . wait ( 400 ) . to ( { x : endX , y : endY } , time , egret . Ease . quadIn ) . call ( this . _goldTweenComplete , this , [ mov , battery , i , goldNum , score ] ) ; } } /**
         * 延迟金币回收
         */ private _delayCoinTween ( endX , endY , time , mov , battery , i , goldNum , score ) { egret . Tween . get ( mov ) . to ( { x : endX , y : endY } , time , egret . Ease . quadIn ) . call ( this . _goldTweenComplete , this , [ mov , battery , i , goldNum , score ] ) ; } /**
         * 金币爆炸Tween动画
         */ private _goldBurstTween ( mov , i , goldNum , startX , startY , endX , endY , time , battery , radius , score , isBoomEx ) { let anglePre = 360 / goldNum * 2 ; let angle = anglePre * i ; let radian = UIUtil . getRadian ( angle ) ; mov . x = Math . cos ( radian ) * 5 + startX ; mov . y = Math . sin ( radian ) * 5 + startY ; if ( i < goldNum / 2 ) { let targetX = Math . cos ( radian ) * radius + startX + MathUtil . random ( - 30 , 30 ) * 2 ; let targetY = Math . sin ( radian ) * radius + startY + MathUtil . random ( - 30 , 30 ) * 2 ; let tween = egret . Tween . get ( mov ) . wait ( MathUtil . random ( 0 , 500 ) ) . to ( { x : targetX , y : targetY , rotation : angle } , 800 , egret . Ease . cubicOut ) ; if ( isBoomEx && ! this . coinDelayTweenComplete ) { this . _coinTweenDelayHandler . push ( Handler . create ( this , this . _delayCoinTween , [ endX , endY , time , mov , battery , i , goldNum , score ] , true ) ) ; } else { tween . wait ( 200 ) . to ( { x : endX , y : endY } , time , egret . Ease . cubicIn ) . call ( this . _goldTweenComplete , this , [ mov , battery , i , goldNum , score ] ) ; } } else { let targetX = Math . cos ( radian ) * radius / 2 + startX + MathUtil . random ( - 60 , 60 ) * 3 ; let targetY = Math . sin ( radian ) * radius / 2 + startY + MathUtil . random ( - 60 , 60 ) * 3 ; let tween = egret . Tween . get ( mov ) . wait ( MathUtil . random ( 0 , 500 ) ) . to ( { x : targetX , y : targetY , rotation : angle } , 800 , egret . Ease . cubicOut ) ; if ( isBoomEx && ! this . coinDelayTweenComplete ) { this . _coinTweenDelayHandler . push ( Handler . create ( this , this . _delayCoinTween , [ endX , endY , time , mov , battery , i , goldNum , score ] , true ) ) ; } else { tween . wait ( 200 ) . to ( { x : endX , y : endY } , time , egret . Ease . cubicIn ) . call ( this . _goldTweenComplete , this , [ mov , battery , i , goldNum , score ] ) ; } } } /**
         * 金币飞行动画完毕
         *
         *  */ private _goldTweenComplete ( mov , battery , i , goldNum , score ) { if ( i == goldNum - 1 ) { battery . coinImgTween ( ) ; battery . updateGold ( score ) ; } mov . stop ( ) ; if ( mov . name == "commonGold" ) { Pool . recover ( Pool . commonGold , mov ) ; } else { Pool . recover ( Pool . commonGrayGold , mov ) ; } LayerManager . instance . removeFromLayer ( mov ) ; } private eachHeapOfGoldCoinsData = [ [ ] , [ ] , [ ] , [ ] ] ; private numberOfGoldCoins = [ 0 , 0 , 0 , 0 ] ; private goldCoinRemovalTime = [ [ ] , [ ] , [ ] , [ ] ] ; private dataStorage = [ [ ] , [ ] , [ ] , [ ] ] ; /**
         * 推金币
         */ private _coinDozer ( scoreSum , oddsSum , rev , seatingData ? ) { let data ; if ( oddsSum < 1 ) { oddsSum = 1 ; } let battery ; if ( rev ) { data = rev ; } battery = rev ? this . allBattery . get ( rev . uid ) : seatingData ; if ( battery == null ) { return ; } if ( ! battery . seatdata ) return ; let seatId = battery . seatdata . seatId ; let seatIndex = seatId - 1 ; if ( this . eachHeapOfGoldCoinsData [ seatIndex ] . length >= 3 && rev ) { this . dataStorage [ seatIndex ] . push ( rev ) ; if ( this . dataStorage [ seatIndex ] . length == 1 ) { this . _coinDozer ( scoreSum , oddsSum , null , battery ) ; } return ; } if ( rev == null ) { if ( this . dataStorage [ seatIndex ] . length == 0 ) { return ; } data = this . dataStorage [ seatIndex ] [ 0 ] ; } let clientNo = game . GameConstant . GetClientNoBySeatId ( battery . seatID ) ; let seat = game . GameConstant . GetSeatPositionByClientNo ( clientNo ) ; if ( seat == null ) return ; let x = 0 ; let y = 0 ; let group = new eui . Group ( ) ; group . touchEnabled = false ; if ( this . numberOfGoldCoins [ seatIndex ] != 0 ) { let numberMy = this . numberOfGoldCoins [ seatIndex ] ; if ( this . numberOfGoldCoins [ seatIndex ] >= 3 ) { this . numberOfGoldCoins [ seatIndex ] = 3 ; } group . x = seat . x > uniLib . Global . screenWidth / 2 ? ( 795 * uniLib . Global . screenWidth / 1280 ) - ( ( numberMy < 3 ? numberMy : 2 ) * 35 ) - 20 : ( 460 * uniLib . Global . screenWidth / 1280 ) + ( ( numberMy < 3 ? numberMy : 2 ) * 35 ) + 20 ; if ( this . numberOfGoldCoins [ seatIndex ] == 3 ) { if ( this . eachHeapOfGoldCoinsData [ seatIndex ] [ 0 ] ) this . goldCoinPush ( battery , 0 ) ; if ( this . eachHeapOfGoldCoinsData [ seatIndex ] [ 1 ] ) this . goldCoinPush ( battery , 1 ) ; if ( this . eachHeapOfGoldCoinsData [ seatIndex ] [ 2 ] ) this . goldCoinPush ( battery , 2 , false , group , oddsSum , scoreSum ) ; } } else { group . x = seat . x > uniLib . Global . screenWidth / 2 ? ( 795 * uniLib . Global . screenWidth / 1280 ) - 20 : ( 460 * uniLib . Global . screenWidth / 1280 ) + 20 ; } group . y = seat . y > uniLib . Global . screenHeight / 2 ? 553 : - 7 ; LayerManager . instance . addToLayer ( group , LAYER . EFFECT_LOW ) ; if ( this . numberOfGoldCoins [ seatIndex ] < 3 ) { let len = oddsSum > 20 ? 20 : oddsSum ; for ( var m = 0 ; m < len ; m ++ ) { game . Timer . setTimeout ( ( ) => { let imageMy = Pool . getItemByClass ( "coinDozerImage" , eui . Image ) ; if ( battery . user && battery . user . uid ) { if ( battery . user . uid == Master . instance . uid ) { imageMy . source = "batteryBase8" ; } else { imageMy . source = "batteryBase81" ; } } imageMy . scaleX = 0.85 ; imageMy . scaleY = 0.85 ; imageMy . x = 0 ; imageMy . y = seat . y > uniLib . Global . screenHeight / 2 ? 160 + y : 8 - y ; imageMy . touchEnabled = false ; y -= 6.8 ; group . addChild ( imageMy ) ; } , this , m * 10 ) ; } let TextNew = new eui . BitmapLabel ( ) ; if ( battery . user && battery . user . uid ) { if ( battery . user . uid == Master . instance . uid ) { TextNew . font = "flutters1_fnt" ; } else { TextNew . font = "flutters2_fnt" ; } } TextNew . touchEnabled = false ; TextNew . text = "" + GX . GoldFormat ( scoreSum , true , true , false ) ; group . addChild ( TextNew ) ; TextNew . anchorOffsetX = TextNew . width / 2 ; TextNew . anchorOffsetY = TextNew . height / 2 ; TextNew . scaleX = 0.25 ; TextNew . scaleY = 0.25 ; TextNew . x = 12.75 ; TextNew . y = seat . y > uniLib . Global . screenHeight / 2 ? 160 + - 10 + ( - 6.8 * ( ( oddsSum > 20 ? 20 : oddsSum ) - 1 ) ) : 16 - ( - 6.8 * ( ( oddsSum > 20 ? 20 : oddsSum ) - 1 ) ) + 10 ; } this . eachHeapOfGoldCoinsData [ seatIndex ] . push ( group ) ; this . numberOfGoldCoins [ seatIndex ] += 1 ; if ( this . goldCoinRemovalTime [ seatIndex ] [ 0 ] ) { game . Timer . clearTimeout ( this . goldCoinRemovalTime [ seatIndex ] [ 0 ] ) ; this . goldCoinRemovalTime [ seatIndex ] = [ ] ; } let batterys = battery ; let goldCoinRemovalTime = game . Timer . setTimeout ( ( ) => { this . goldCoinAutomaticallyRemoved ( batterys ) ; } , this , 4000 ) ; this . goldCoinRemovalTime [ seatIndex ] . push ( goldCoinRemovalTime ) ; } /**
         * 发送道具协议协议
         */ public sendUsePorpMsg ( idMy ) { let cmd = new Cmd . ActionCmd_CS ( ) ; cmd . act = new Cmd . Action ( ) ; cmd . act . uid = Master . instance . uid ; cmd . act . op = Cmd . Operation . UseItem ; cmd . act . id = idMy ; game . PokerFunction . tcpSend ( cmd ) ; } private goldCoinAutomaticallyRemoved ( battery ) { if ( ! battery . seatdata ) return ; let seatId = battery . seatdata . seatId ; let seatIndex = seatId - 1 ; if ( this . goldCoinRemovalTime [ seatIndex ] [ 0 ] ) { game . Timer . clearTimeout ( this . goldCoinRemovalTime [ seatIndex ] [ 0 ] ) ; this . goldCoinRemovalTime [ seatIndex ] = [ ] ; } if ( this . eachHeapOfGoldCoinsData [ seatIndex ] [ 0 ] ) { this . goldCoinPush ( battery , 0 ) ; } if ( this . eachHeapOfGoldCoinsData [ seatIndex ] [ 1 ] ) this . goldCoinPush ( battery , 1 ) ; if ( this . eachHeapOfGoldCoinsData [ seatIndex ] [ 2 ] ) this . goldCoinPush ( battery , 2 , true ) ; this . eachHeapOfGoldCoinsData [ seatIndex ] . removeAt ( 0 ) ; this . numberOfGoldCoins [ seatIndex ] = this . eachHeapOfGoldCoinsData [ seatIndex ] . length ; if ( this . eachHeapOfGoldCoinsData [ seatIndex ] [ 0 ] ) { let goldCoinRemovalTime = game . Timer . setTimeout ( ( ) => { this . goldCoinAutomaticallyRemoved ( battery ) ; } , this , 4000 ) ; this . goldCoinRemovalTime [ seatIndex ] . push ( goldCoinRemovalTime ) ; } } private goldCoinPush ( battery , second , bool ? , group ? , odds ? , score ? ) { let seat = game . GameConstant . SeatPositonList [ game . GameConstant . GetClientNoBySeatId ( battery . seatdata . seatId ) - 1 ] ; let y = 0 ; if ( second == 0 ) { LayerManager . instance . removeFromLayer ( this . eachHeapOfGoldCoinsData [ battery . seatdata . seatId - 1 ] [ 0 ] ) ; return ; } egret . Tween . get ( this . eachHeapOfGoldCoinsData [ battery . seatdata . seatId - 1 ] [ second ] ) . to ( { x : seat . x > uniLib . Global . screenWidth / 2 ? this . eachHeapOfGoldCoinsData [ battery . seatdata . seatId - 1 ] [ second ] . x + 35 : this . eachHeapOfGoldCoinsData [ battery . seatdata . seatId - 1 ] [ second ] . x + - 35 } , 300 ) . call ( ( odds , score ) => { if ( group ) { for ( var m = 0 ; m < ( odds > 20 ? 20 : odds ) ; m ++ ) { game . Timer . setTimeout ( ( ) => { let imageMy = Pool . getItemByClass ( "coinDozerImage" , eui . Image ) ; if ( battery . user && battery . user . uid ) { if ( battery . user . uid == Master . instance . uid ) { imageMy . source = "batteryBase8" ; } else { imageMy . source = "batteryBase81" ; } } imageMy . scaleX = 0.85 ; imageMy . scaleY = 0.85 ; imageMy . x = 0 ; imageMy . y = seat . y > uniLib . Global . screenHeight / 2 ? 160 + y : 8 - y ; y -= 6.8 ; group . addChild ( imageMy ) ; } , this , m * 10 ) ; } let TextNew = new eui . BitmapLabel ( ) ; if ( battery . user && battery . user . uid ) { if ( battery . user . uid == Master . instance . uid ) { TextNew . font = "flutters1_fnt" ; } else { TextNew . font = "flutters2_fnt" ; } } TextNew . text = "" + GX . GoldFormat ( score , true , true , false ) ; group . addChild ( TextNew ) ; TextNew . anchorOffsetX = TextNew . width / 2 ; TextNew . anchorOffsetY = TextNew . height / 2 ; TextNew . scaleX = 0.25 ; TextNew . scaleY = 0.25 ; TextNew . x = 12.75 ; TextNew . y = seat . y > uniLib . Global . screenHeight / 2 ? 160 + - 10 + ( - 6.8 * ( ( odds > 20 ? 20 : odds ) - 1 ) ) : 16 - ( - 6.8 * ( ( odds > 20 ? 20 : odds ) - 1 ) ) + 10 ; this . numberOfGoldCoins [ battery . seatdata . seatId - 1 ] = 3 ; this . eachHeapOfGoldCoinsData [ battery . seatdata . seatId - 1 ] . removeAt ( 0 ) ; if ( this . dataStorage [ battery . seatdata . seatId - 1 ] . length != 0 ) { this . dataStorage [ battery . seatdata . seatId - 1 ] . removeAt ( 0 ) ; this . _coinDozer ( score , odds , null , battery ) ; } } } , this , [ odds , score ] ) ; } public removeTheGoldCoinHeap ( seatdata ) { this . numberOfGoldCoins [ seatdata . seatId - 1 ] = 0 ; for ( let item = 0 ; item < this . eachHeapOfGoldCoinsData [ seatdata . seatId - 1 ] . length ; ++ item ) { LayerManager . instance . removeFromLayer ( this . eachHeapOfGoldCoinsData [ seatdata . seatId - 1 ] [ item ] ) ; } this . eachHeapOfGoldCoinsData [ seatdata . seatId - 1 ] = [ ] ; this . dataStorage [ seatdata . seatId - 1 ] = [ ] ; if ( this . goldCoinRemovalTime [ seatdata . seatId - 1 ] [ 0 ] ) { game . Timer . clearTimeout ( this . goldCoinRemovalTime [ seatdata . seatId - 1 ] [ 0 ] ) ; this . goldCoinRemovalTime [ seatdata . seatId - 1 ] = [ ] ; } } public tweenAnimation ( anchors , scale , image1 , seat , image , bool , isMove ? ) { let y = seat . y > uniLib . Global . screenHeight / 2 ? - 40 : 40 ; let x = seat . x > uniLib . Global . screenWidth / 2 ? 130 : - 130 ; image1 . source = image ; LayerManager . instance . addToLayer ( image1 , LAYER . EFFECT_LOW ) ; image1 . anchorOffsetX = anchors ; image1 . anchorOffsetY = anchors ; image1 . scaleX = scale ; image1 . scaleY = scale ; image1 . x = seat . x + x ; image1 . y = seat . y + y ; if ( isMove ) { this . imageJitter ( image1 , bool ) ; } return image1 ; } private imageJitter ( ImageMy , bool ? ) { if ( ! ImageMy ) { return ; } egret . Tween . get ( ImageMy ) . to ( { rotation : bool ? 360 : - 360 } , 2000 ) . call ( ( ) => { this . imageJitter ( ImageMy , bool ) ; } ) ; } public createMedalResources ( id ) { let image1 = new CustomImage ( ) ; let image2 = new CustomImage ( ) ; let image3 = new CustomImage ( ) ; let aNetImage = new CustomImage ( ) ; let mov = UIUtil . creatMovieClip ( "deng" ) ; let mov1 = UIUtil . creatMovieClip ( "Medal1_jewel" ) ; let mov2 = UIUtil . creatMovieClip ( "Medal2_jewel" ) ; let mov3 = UIUtil . creatMovieClip ( "Medal3_jewel" ) ; let textMy = new eui . BitmapLabel ( ) ; this . medalStorage [ id ] . push ( image1 , image2 , image3 , aNetImage , textMy , [ mov , mov1 , mov2 , mov3 ] ) ; } public medalStorage = [ [ ] , [ ] , [ ] , [ ] ] ; private medalTime = [ null , null , null , null ] ; /**
         * 奖章
         */ public _getMedal ( scoreSum , oddsSum , rev , skill ) { let levelData = FishingJoy . DataCenter . instance . getRuleConfigList ( ) ; let level ; if ( oddsSum < levelData [ 0 ] . medalGrades [ 0 ] && skill != 1 ) { return ; } else if ( oddsSum >= levelData [ 0 ] . medalGrades [ 0 ] && oddsSum < levelData [ 0 ] . medalGrades [ 1 ] ) { level = 1 ; } else if ( oddsSum >= levelData [ 0 ] . medalGrades [ 1 ] && oddsSum < levelData [ 0 ] . medalGrades [ 2 ] ) { level = 2 ; } else if ( oddsSum >= levelData [ 0 ] . medalGrades [ 2 ] ) { level = 3 ; } let battery = this . allBattery . get ( rev . uid ) ; if ( battery == null || battery . seatdata == null ) return ; let seatId = battery . seatdata . seatId ; let clientNo = game . GameConstant . GetClientNoBySeatId ( seatId ) ; this . scavengingMedals ( seatId - 1 ) ; let seatPos = game . GameConstant . SeatPositonList [ clientNo - 1 ] ; let y = seatPos . y > uniLib . Global . screenHeight / 2 ? - 40 : 40 ; let x = seatPos . x > uniLib . Global . screenWidth / 2 ? 130 : - 130 ; let image1 ; let image2 ; let image3 ; let mov ; let textMy ; let aNetImage ; let zoom = 250 / 284 * 0.9 * 0.75 ; game . SoundHand . Instance . playMedalAppearance ( ) ; if ( GX . GameLayerManager . sceneLayer . parent . x != 0 || GX . GameLayerManager . sceneLayer . parent . y != 0 ) { GX . GameLayerManager . sceneLayer . parent . x = 0 ; GX . GameLayerManager . sceneLayer . parent . y = 0 ; } let medalStorage = this . medalStorage [ seatId - 1 ] ; if ( medalStorage . length == 0 ) { this . createMedalResources ( seatId - 1 ) ; } let levelTime = skill ? 3000 : level == 3 ? 5000 : ( level + 1 ) * 1000 ; if ( skill == 1 ) { image1 = this . tweenAnimation ( 142 , zoom , medalStorage [ 0 ] , seatPos , "down" , true , true ) ; image2 = this . tweenAnimation ( 106 , zoom , medalStorage [ 1 ] , seatPos , "middle" , false , true ) ; image3 = this . tweenAnimation ( 125.5 , zoom , medalStorage [ 2 ] , seatPos , "up" , true , true ) ; mov = medalStorage [ 5 ] [ 0 ] ; mov . touchEnabled = false ; mov . y = seatPos . y + y ; mov . x = seatPos . x + x ; mov . scaleX = zoom ; mov . scaleY = zoom ; mov . frameRate = 9 ; mov . gotoAndPlay ( 1 , - 1 ) ; LayerManager . instance . addToLayer ( mov , LAYER . EFFECT_LOW ) ; aNetImage = medalStorage [ 3 ] ; aNetImage . source = "catchAllInOneDraft" ; LayerManager . instance . addToLayer ( aNetImage , LAYER . EFFECT_LOW ) ; aNetImage . anchorOffsetX = aNetImage . width / 2 ; aNetImage . anchorOffsetY = aNetImage . height / 2 ; aNetImage . x = seatPos . x + x ; aNetImage . y = seatPos . y + y - 30 ; aNetImage . scaleX = seatPos . y > uniLib . Global . screenHeight / 2 ? 1 : - 1 ; aNetImage . scaleY = seatPos . y > uniLib . Global . screenHeight / 2 ? 1 : - 1 ; } else { let anchors1 = level == 1 ? 97 : level == 2 ? 101 : 101 ; let anchors2 = level == 1 ? 118 : level == 2 ? 125 : 137.5 ; if ( rev . uid == Master . instance . uid && ( level == 2 || level == 3 ) ) { if ( this . _lastMasterWinEff && this . _lastMasterWinEff . isInView ) { gameObject . GameObjectFactory . instance . recoverGameObject ( this . _lastMasterWinEff ) ; this . _lastMasterWinEff = null ; } let data = < gameObject . IMasterWinEffVars > { } ; data . bornX = uniLib . Global . screenWidth / 2 ; data . bornY = uniLib . Global . screenHeight / 2 ; data . money = scoreSum ; data . winLevel = level ; this . _lastMasterWinEff = gameObject . GameObjectFactory . instance . creatGameObject ( GAMEOBJECT_SIGN . MASTER_WIN_EFF , data , LAYER . EFFECT_MEDIUM ) ; } let scale = 0.9 * 0.75 ; image1 = this . tweenAnimation ( anchors1 , scale , medalStorage [ 0 ] , seatPos , "Medal_ middle" + level , true ) ; image2 = this . tweenAnimation ( anchors2 , scale , medalStorage [ 1 ] , seatPos , "Medal_BG" + level , true , true ) ; mov = medalStorage [ 5 ] [ level ] ; mov . scaleX = scale ; mov . scaleY = scale ; mov . touchEnabled = false ; mov . y = seatPos . y + y ; mov . x = seatPos . x + x ; mov . frameRate = 9 ; mov . gotoAndPlay ( 1 , - 1 ) ; LayerManager . instance . addToLayer ( mov , LAYER . EFFECT_LOW ) ; } textMy = medalStorage [ 4 ] ; textMy . font = "multipleFnt_fnt" ; textMy . text = GX . GoldFormat ( scoreSum , true , true , false ) ; LayerManager . instance . addToLayer ( textMy , LAYER . EFFECT_LOW ) ; textMy . x = seatPos . x + x ; textMy . y = aNetImage ? seatPos . y + y + 30 : seatPos . y + y ; textMy . anchorOffsetX = textMy . width / 2 ; textMy . anchorOffsetY = textMy . height / 2 ; textMy . scaleX = seatPos . y > uniLib . Global . screenHeight / 2 ? 0.9 : - 0.9 ; textMy . scaleY = seatPos . y > uniLib . Global . screenHeight / 2 ? 0.9 : - 0.9 ; this . labelJitter ( textMy , true ) ; if ( aNetImage ) { this . labelJitter ( aNetImage , true ) ; } if ( this . medalTime [ seatId - 1 ] ) { game . Timer . clearTimeout ( this . medalTime [ seatId - 1 ] ) ; this . medalTime [ seatId - 1 ] = null ; } this . medalTime [ seatId - 1 ] = game . Timer . setTimeout ( ( ) => { for ( let item of FishingJoy . FishingJoyLogic . instance . medalStorage [ seatId - 1 ] ) { egret . Tween . removeTweens ( item ) ; LayerManager . instance . removeFromLayer ( item ) ; } for ( let item of FishingJoy . FishingJoyLogic . instance . medalStorage [ seatId - 1 ] [ 5 ] ) { egret . Tween . removeTweens ( item ) ; LayerManager . instance . removeFromLayer ( item ) ; } } , null , levelTime ) ; } private scavengingMedals ( id ) { if ( this . medalStorage [ id ] . length == 0 ) { return ; } else { for ( let item of FishingJoy . FishingJoyLogic . instance . medalStorage [ id ] ) { egret . Tween . removeTweens ( item ) ; LayerManager . instance . removeFromLayer ( item ) ; } for ( let item of FishingJoy . FishingJoyLogic . instance . medalStorage [ id ] [ 5 ] ) { egret . Tween . removeTweens ( item ) ; LayerManager . instance . removeFromLayer ( item ) ; } } } private labelJitter ( textMy , bool ? ) { if ( ! textMy ) { return ; } egret . Tween . get ( textMy ) . to ( { rotation : bool ? 13 : - 13 } , 500 , egret . Ease . backOut ) . call ( ( ) => { this . labelJitter ( textMy , ! bool ) ; } ) ; } private outOfTheField : eui . Image ; /**
         * 免费游戏出场离场提示
         */ public onFreeGame ( imageID , boolMy ? ) { game . SoundHand . Instance . playAlert ( ) ; if ( ! boolMy ) { if ( this . winAnim0 != null ) { egret . Tween . removeTweens ( this . winAnim0 ) ; egret . Tween . removeTweens ( this . outOfTheField ) ; LayerManager . instance . removeFromLayer ( this . winAnim0 ) ; this . winAnim0 == null ; } this . winAnim0 = UIUtil . creatMovieClip ( "appearanceOfLight" ) ; this . winAnim0 . blendMode = egret . BlendMode . ADD ; this . winAnim0 . y = uniLib . Global . screenHeight / 2 ; this . winAnim0 . x = uniLib . Global . screenWidth / 2 ; this . winAnim0 . scaleX = 4 * uniLib . Global . screenWidth / 1280 ; this . winAnim0 . scaleY = 4 * uniLib . Global . screenHeight / 720 ; ; LayerManager . instance . addToLayer ( this . winAnim0 , LAYER . EFFECT_LOW ) ; this . winAnim0 . frameRate = 10 ; this . winAnim0 . gotoAndPlay ( 1 , 4 ) ; this . winAnim0 . addEventListener ( egret . Event . COMPLETE , this . animationConcealment , this ) ; } if ( ! this . outOfTheField ) { this . outOfTheField = new eui . Image ( ) ; this . outOfTheField . visible = false ; } LayerManager . instance . addToLayer ( this . outOfTheField , LAYER . EFFECT_LOW ) ; this . outOfTheField . source = "freeOutOfTheField" + imageID ; this . outOfTheField . alpha = 1 ; this . outOfTheField . anchorOffsetX = this . outOfTheField . width / 2 ; this . outOfTheField . anchorOffsetY = this . outOfTheField . height / 2 ; this . outOfTheField . visible = true ; this . outOfTheField . scaleX = 0.8 ; this . outOfTheField . scaleY = 0.8 ; this . outOfTheField . x = 0 - this . outOfTheField . width / 2 ; this . outOfTheField . y = uniLib . Global . screenHeight / 2 ; egret . Tween . get ( this . outOfTheField ) . to ( { x : uniLib . Global . screenWidth / 2 } , 500 , egret . Ease . backOut ) . call ( ( ) => { if ( boolMy ) { this . animationConcealment ( 1 ) ; } } ) ; } public freePromptCloses ( ) { if ( this . outOfTheField ) { this . outOfTheField . visible = false ; this . outOfTheField . x = 0 - this . outOfTheField . width / 2 ; } } private animationConcealment ( boolMy ? ) { if ( boolMy != 1 ) { egret . Tween . get ( this . winAnim0 ) . to ( { alpha : 0 } , 1000 ) . call ( ( ) => { if ( this . winAnim0 != null ) { LayerManager . instance . removeFromLayer ( this . winAnim0 ) ; this . winAnim0 = null ; } } ) ; egret . Tween . get ( this . outOfTheField ) . to ( { alpha : 0.5 , scaleX : 1.5 , scaleY : 1.5 } , 300 ) . call ( ( ) => { egret . Tween . get ( this . outOfTheField ) . to ( { alpha : 0 , scaleX : 0.5 , scaleY : 0.5 } , 700 ) . call ( ( ) => { this . outOfTheField . visible = false ; this . outOfTheField . x = 0 - this . outOfTheField . width / 2 ; if ( this . freeType ) { this . freeType = null ; } } ) ; } ) ; } else { if ( ! this . outOfTheField . visible ) { return ; } egret . Tween . get ( this . outOfTheField ) . to ( { scaleX : 1.1 , scaleY : 1.1 } , 600 ) . call ( ( ) => { egret . Tween . get ( this . outOfTheField ) . to ( { scaleX : 0.8 , scaleY : 0.8 } , 700 ) . call ( ( ) => { this . animationConcealment ( 1 ) ; } ) ; } ) ; } } private animationConcealments ( ) { this . winAnim1 . removeEventListener ( egret . Event . COMPLETE , this . animationConcealments , this ) ; let back0 = UICenter . instance . getManager ( commonUI . FishMainScene ) . getView ( FishMainSceneView ) ; back0 . removeChild ( this . winAnim1 ) ; this . winAnim1 = null ; } private freeType : number ; /**
         * 出鱼
         */ private _spawnFishEvent ( data , reconnection = false ) { DataCenter . instance . isSwitchFish = false ; let fishlist = data . fishlist ; let specialTime = 0 ; if ( fishlist == null || ! ( fishlist instanceof Array ) ) { return ; } for ( let fishs of fishlist ) { if ( fishs . spawnTime == null ) { console . error ( "服务器未下发spawnTime" ) ; continue ; } for ( let item of fishs . fishs ) { let config = gameObject . GameObjectConfigParse . configDic . get ( item . templateId ) ; if ( ! config ) { console . assert ( false , "鱼模板id为" + item . templateId + "这找不到配置" ) ; continue ; } let tableConfig = config . table ; let fishPath = table . TableFishPath . getFishPath ( fishs . pathId ) ; if ( fishPath == null ) { console . assert ( false , "找不到配置路径:" + fishs . pathId ) ; return ; } if ( tableConfig . sign == GAMEOBJECT_SIGN . DRAGON ) { specialTime = tableConfig . spawnTimeout ; if ( ! reconnection ) { this . freeType = SCENEID . HaiDiBaoZang ; this . onFreeGame ( 1 ) ; } else { } } else if ( tableConfig . sign == GAMEOBJECT_SIGN . MERMAID ) { specialTime = tableConfig . spawnTimeout ; if ( ! reconnection ) { this . freeType = SCENEID . HaiDiGongDian ; this . onFreeGame ( 3 ) ; } else { } } if ( item . skill == Cmd . FishSkillType . SameGroup ) { let offset = game . GameConstant . getSameGroupOffset ( ) ; item . offsetX = offset . offsetX ; item . offsetY = offset . offsetY ; } let varsData = < gameObject . IFishVars > { } ; varsData . serveID = item . id ; varsData . pathId = fishs . pathId . toString ( ) ; varsData . skillID = item . skill ; varsData . offsetX = item . offsetX ; varsData . offsetY = item . offsetY ; varsData . reconnection = reconnection ; varsData . spawnTime = fishs . spawnTime + specialTime ; varsData . operation = [ < gameObject . IOperation > { type : OPERATION_TYPE . FISH } ] ; let fish = gameObject . GameObjectFactory . instance . creatGameObject ( item . templateId , varsData , LAYER . Fish ) ; fish . name = "path：" + fishs . pathId . toString ( ) ; if ( fish . sign == GAMEOBJECT_SIGN . MERMAID || fish . sign == GAMEOBJECT_SIGN . DRAGON ) { EventManager . fireEvent ( EVENT_ID . AIM_SPECIAL_FISH , [ fish , true ] ) ; } } } } /**
         * 碰撞检测
         */ public _checkHit ( ) { let bulletMap = this . inViewBullets ; let bulletMapLen = bulletMap . length ; let fishMap = this . inViewFishes ; let fishMapLen = fishMap . length ; if ( bulletMapLen == 0 || fishMapLen == 0 ) { return ; } this . hitFishList . clear ( ) ; let smallFishFlag = false ; let fishGroupMap = this . _fishGroupDic ; let bulletGroupMap = this . _bulletGroupDic ; fishGroupMap . clear ( ) ; bulletGroupMap . clear ( ) ; if ( this . _colliderFlag == 0 ) { this . _colliderFlag = 1 ; } else { this . _colliderFlag = 0 ; } let i = 0 ; for ( ; i < bulletMapLen ; i += this . _colliderFlag + 1 ) { let bullet = bulletMap . values [ i ] ; let bulletColliderAry = bullet . colliderAry ; for ( let m = 0 ; m < bulletColliderAry . length ; m ++ ) { bulletColliderAry [ m ] . setGlobePos ( ) ; } NineGridSplitScreenTool . setGridIndex ( bullet , bulletGroupMap ) ; } for ( i = 0 ; i < fishMapLen ; i += this . _colliderFlag + 1 ) { let fish = fishMap . values [ i ] ; if ( fish . isAlive ) { if ( fish . isAccurateCollider ) { let fishColliderAry = fish . colliderAry ; for ( let m = 0 ; m < fishColliderAry . length ; m ++ ) { fishColliderAry [ m ] . setGlobePos ( ) ; } NineGridSplitScreenTool . setGridIndex ( fish , fishGroupMap ) ; } else { if ( fishMapLen >= 60 ) { smallFishFlag = ! smallFishFlag ; if ( smallFishFlag ) { let fishColliderAry = fish . colliderAry ; for ( let m = 0 ; m < fishColliderAry . length ; m ++ ) { fishColliderAry [ m ] . setGlobePos ( ) ; } NineGridSplitScreenTool . setGridIndex ( fish , fishGroupMap ) ; } } else { let fishColliderAry = fish . colliderAry ; for ( let m = 0 ; m < fishColliderAry . length ; m ++ ) { fishColliderAry [ m ] . setGlobePos ( ) ; } NineGridSplitScreenTool . setGridIndex ( fish , fishGroupMap ) ; } } } } let bulletHit = [ ] ; for ( let j = Grid . Grid_1 ; j < Grid . Grid_9 + 1 ; j ++ ) { let bulletGameObjAry = bulletGroupMap . get ( j ) ; if ( bulletGameObjAry ) { let bulletGameObjAryLen = bulletGameObjAry . length ; for ( let f = 0 ; f < bulletGameObjAryLen ; f ++ ) { let bullet = bulletGameObjAry [ f ] as gameObject . Bullet ; let targetFish = bullet . targetFish ; if ( this . _checkFishCanCollider ( targetFish ) ) { if ( this . _checkBulletHit ( bullet , targetFish , fishGroupMap , j , true ) ) { bulletHit . push ( bullet ) ; } } else { let fishGameObjAry = fishGroupMap . get ( j ) ; if ( fishGameObjAry ) { let fishGameObjAryLen = fishGameObjAry . length ; for ( let k = 0 ; k < fishGameObjAryLen ; k ++ ) { let fish = fishGameObjAry [ k ] as gameObject . Fish ; if ( this . _checkBulletHit ( bullet , fish , fishGroupMap , j , false ) ) { bulletHit . push ( bullet ) ; break ; } } } } } } } for ( let item of bulletHit ) { gameObject . GameObjectFactory . instance . recoverGameObject ( item ) ; } if ( this . hitFishList . length > 0 ) { let cmd = new Cmd . HitFishCmd_CS ( ) ; cmd . list = this . hitFishList ; game . PokerFunction . tcpSend ( cmd ) ; } } /**
         * 检测鱼是否可以碰撞
         */ private _checkFishCanCollider ( fish ) { if ( fish && fish . isInView && fish . isAlive ) { return true ; } else { return false ; } } /**
         * 检测子弹碰撞
         */ private _checkBulletHit ( bullet , fish , fishGroupMap , gridIndex , isAim ) { let bulletColliderAry = bullet . colliderAry ; let fishColliderAry = fish . colliderAry ; let fishColliderAryLen = fishColliderAry . length ; for ( let k = 0 ; k < bulletColliderAry . length ; k ++ ) { for ( let f = 0 ; f < fishColliderAryLen ; f ++ ) { if ( Collider . isIntersect ( bulletColliderAry [ k ] , fishColliderAry [ f ] ) ) { let fishingNet = this . _creatFishingNet ( bullet , fish ) ; if ( fishingNet ) { this . _checkFishingNetHit ( bullet , fish , fishingNet , fishGroupMap , gridIndex , isAim ) ; } return true ; } } } return false ; } /**
         * 创建渔网
         */ private _creatFishingNet ( bullet , collidedFish ) { let battery = this . allBattery . get ( bullet . playerID ) ; if ( ! battery ) { return null ; } let data = < gameObject . IFishNetVars > { } ; data . bornX = bullet . x ; data . bornY = bullet . y ; data . rotation = bullet . rotation ; data . radius = battery . fishNetRadius ; let fishingNet = null ; let playerID = bullet . playerID ; if ( playerID == Master . instance . uid ) { if ( bullet . isReal ) { data . isVisible = false ; } else { data . isVisible = true ; collidedFish . playHitEff ( bullet . rotation ) ; } fishingNet = gameObject . GameObjectFactory . instance . creatGameObject ( GAMEOBJECT_SIGN . FishingNet_Self , data , LAYER . FishingNet ) ; } else { data . isVisible = true ; fishingNet = gameObject . GameObjectFactory . instance . creatGameObject ( GAMEOBJECT_SIGN . FishingNet_Green , data , LAYER . FishingNet ) ; } return fishingNet ; } /**
         * 检测渔网碰撞
         */ private _checkFishingNetHit ( bullet , collidedFish , fishingNet , fishGroupMap , gridIndex , isAim ) { let playerID = bullet . playerID ; let user = game . PokerFunction . GetUserInfoByUid ( playerID ) ; if ( ! user ) { return ; } if ( user . isRobot || playerID == Master . instance . uid ) { let deadlist = [ ] ; let deadFish = new Cmd . Fish ( ) ; deadFish . id = collidedFish . servelID ; deadlist . push ( deadFish ) ; if ( collidedFish . sign == GAMEOBJECT_SIGN . BOOM_FISH && bullet . isReal ) { let fishAry = fishGroupMap . get ( gridIndex ) ; if ( fishAry ) { fishAry . remove ( collidedFish ) ; this . _checkBoomHit ( fishAry , bullet . servelID , playerID , < gameObject . BoomFish > collidedFish , deadlist ) ; return ; } } if ( isAim ) { if ( bullet . isReal ) { this . _addHitFish ( deadlist , bullet . servelID , playerID ) ; } return ; } let fishingNetCollider = fishingNet . colliderAry ; for ( let j = 0 ; j < fishingNetCollider . length ; j ++ ) { fishingNetCollider [ j ] . setGlobePos ( ) ; } NineGridSplitScreenTool . analyseGrid ( fishingNet ) ; let isBreak = false ; for ( let i = 0 ; i < fishingNet . grid . length ; i ++ ) { let grid = fishingNet . grid [ i ] ; let fishAry = fishGroupMap . get ( grid ) ; if ( fishAry ) { let len = fishAry . length ; for ( let m = 0 ; m < len ; m ++ ) { let fish = fishAry [ m ] ; if ( fish . servelID == collidedFish . servelID ) { continue ; } isBreak = false ; let fishColliderAry = fish . colliderAry ; let fishColliderAryLen = fishColliderAry . length ; for ( let f = 0 ; f < fishColliderAryLen ; f ++ ) { if ( isBreak ) { break ; } for ( let k = 0 ; k < fishingNetCollider . length ; k ++ ) { if ( Collider . isIntersect ( fishingNetCollider [ k ] , fishColliderAry [ f ] ) ) { isBreak = true ; if ( bullet . isReal ) { if ( fish . sign == GAMEOBJECT_SIGN . BOOM_FISH ) { deadlist . length = 0 ; this . _checkBoomHit ( fishAry , bullet . servelID , playerID , < gameObject . BoomFish > fish , deadlist ) ; return ; } else { let deadFish = new Cmd . Fish ( ) ; deadFish . id = fish . servelID ; deadlist . push ( deadFish ) ; } } else { if ( playerID == Master . instance . uid ) { fish . playHitEff ( bullet . rotation ) ; } } break ; } } } } } if ( bullet . isReal ) { this . _addHitFish ( deadlist , bullet . servelID , playerID ) ; } } } } /**
         * 检测爆炸碰撞
         */ private _checkBoomHit ( fishAry , bulletID , playerID , boomFish , deadlist ) { let burstCollider = boomFish . burstCollider ; burstCollider . setGlobePos ( ) ; let fishAryLen = fishAry . length ; let i ; for ( i = 0 ; i < fishAryLen ; i ++ ) { let fish = fishAry [ i ] ; if ( fish . isAlive ) { let fishColliderAry = fish . colliderAry ; for ( let m = 0 ; m < fishColliderAry . length ; m ++ ) { fishColliderAry [ m ] . setGlobePos ( ) ; if ( Collider . isIntersect ( burstCollider , fishColliderAry [ m ] ) ) { let deadFish = new Cmd . Fish ( ) ; deadFish . id = fish . servelID ; deadlist . push ( deadFish ) ; break ; } } } } if ( deadlist . length != 0 ) { this . _addHitFish ( deadlist , bulletID , playerID , true ) ; } } /**
         * 发送协议
         */ private _addHitFish ( deadlist , bulletID , playerID , isBurst ? ) { let hitFish = new Cmd . HitFish ( ) ; hitFish . list = deadlist ; hitFish . bid = bulletID ; hitFish . list = deadlist ; hitFish . uid = playerID ; if ( isBurst ) { hitFish . hitType = GAMEOBJECT_SIGN . BOOM_FISH ; } this . hitFishList . push ( hitFish ) ; } /**
         * 字典写入玩家炮台
         */ private _addBatteryInMap ( uid , battery ) { if ( this . allBattery . length <= 4 ) { if ( ! this . allBattery . isExist ( uid ) ) { this . allBattery . set ( uid , battery ) ; } else { console . assert ( false , "玩家已经存在！" ) ; } } else { console . assert ( false , "座位已满！" ) ; } } /**
         * 字典移除玩家炮台
         */ private _removeBatteryInMap ( uid ) { if ( ! this . allBattery . remove ( uid ) ) { console . assert ( false , "玩家不存在！" ) ; } } /**
         * 释放
         */ public dispose ( ) { FishingJoy . Laya . timer . clear ( this , this . _checkHit ) ; EventManager . unregisterEvent ( EVENT_ID . ADD_BATTERY_IN_MAP , this , this . _addBatteryInMap ) ; EventManager . unregisterEvent ( EVENT_ID . REMOVE_BATTERY_IN_MAP , this , this . _removeBatteryInMap ) ; EventManager . unregisterEvent ( EVENT_ID . FISH_DIE_ACTION , this , this . _fishDieAction ) ; game . Action . deadFishEvent . remove ( this . _deadFishCmd , this ) ; game . Action . spawnFishEvent . remove ( this . _spawnFishEvent , this ) ; game . Action . changeSceneEvent . remove ( this . changeScene , this ) ; GX . PokerEvent . Instance . roomDataUpdateEvent . remove ( this . _roomDataUpdateEvent , this ) ; game . Action . sendBulletEvent . remove ( this . _firBullet , this ) ; game . Action . hitFishEvent . remove ( this . _hitFishCmd , this ) ; game . Action . actionEvent . add ( this . _receptionOfProps , this ) ; GX . PokerEvent . Instance . moneyUpdate . remove ( this . _addScore , this ) ; this . _destroyBattery ( ) ; this . _destroyFishes ( ) ; this . inViewFishes . clear ( ) ; this . allBattery . clear ( ) ; this . masterBattery = null ; FishingJoyLogic . _instance = null ; ; } /**
         * 销毁玩家
         */ private _destroyBattery ( ) { let map = this . allBattery . copy ( ) ; var len = map . length ; for ( var i = 0 ; i < len ; i ++ ) { let battery = map . getByKeyIndex ( i ) ; gameObject . GameObjectFactory . instance . recoverGameObject ( battery ) ; } map . recover ( ) ; } /**
         * 销毁鱼
         */ public _destroyFishes ( ) { let map = this . inViewFishes . copy ( ) ; var len = map . length ; for ( var i = 0 ; i < len ; i ++ ) { var fish = map . values [ i ] ; gameObject . GameObjectFactory . instance . recoverGameObject ( fish ) ; } } /**
         * 销毁子弹
         */ private destroyBullets ( ) { let map = this . inViewBullets . copy ( ) ; var len = map . length ; for ( var i = 0 ; i < len ; i ++ ) { var bullet = map . values [ i ] ; gameObject . GameObjectFactory . instance . recoverGameObject ( bullet ) ; } } /**
         * 找到场上最值钱的鱼
         */ public findMostValuableFish ( ) { let selectFishes = [ ] ; for ( let i = 0 ; i < this . allBattery . length ; i ++ ) { let battery = this . allBattery . getByKeyIndex ( i ) ; if ( battery && battery . user . uid != Master . instance . uid ) { if ( battery . targetFishId != - 1 ) { let fish = this . inViewFishes . get ( battery . targetFishId ) ; if ( this . _checkFishCanCollider ( fish ) ) { selectFishes . push ( fish ) ; } } } } let fishMap = this . inViewFishes ; let mostValuableFish = null ; let fish ; let index = 0 ; let isBreak = false ; let [ x , y ] = [ - 1 , - 1 ] ; for ( let i = fishMap . length - 1 ; i >= 0 ; i -- ) { if ( isBreak ) { break ; } fish = fishMap . values [ i ] ; if ( this . _checkFishCanCollider ( fish ) ) { if ( fish . isAccurateCollider ) { for ( let j = 0 ; j < fish . colliderAry . length ; j ++ ) { let collider = fish . colliderAry [ j ] ; [ x , y ] = UIUtil . localToGlobal ( collider ) ; if ( UIUtil . inAimView ( x , y ) ) { if ( fish . sign == GAMEOBJECT_SIGN . DRAGON || fish . sign == GAMEOBJECT_SIGN . MERMAID ) { return fish ; } else { if ( selectFishes . indexOf ( fish ) == - 1 ) { mostValuableFish = fish ; index = i ; isBreak = true ; } break ; } } } } else { [ x , y ] = UIUtil . localToGlobal ( fish ) ; if ( selectFishes . indexOf ( fish ) == - 1 ) { if ( UIUtil . inAimView ( x , y ) ) { mostValuableFish = fish ; index = i ; break ; } } } } } if ( mostValuableFish != null ) { for ( let k = index - 1 ; k >= 0 ; k -- ) { fish = fishMap . values [ k ] ; if ( this . _checkFishCanCollider ( fish ) ) { if ( fish . isAccurateCollider ) { for ( let j = 0 ; j < fish . colliderAry . length ; j ++ ) { let collider = fish . colliderAry [ j ] ; [ x , y ] = UIUtil . localToGlobal ( collider ) ; if ( UIUtil . inAimView ( x , y ) ) { if ( fish . sign == GAMEOBJECT_SIGN . DRAGON || fish . sign == GAMEOBJECT_SIGN . MERMAID ) { return fish ; } if ( selectFishes . indexOf ( fish ) == - 1 ) { if ( mostValuableFish . odds < fish . odds ) { mostValuableFish = fish ; } } break ; } } } else { [ x , y ] = UIUtil . localToGlobal ( fish ) ; if ( selectFishes . indexOf ( fish ) == - 1 ) { if ( UIUtil . inAimView ( x , y ) ) { if ( mostValuableFish . odds < fish . odds ) { mostValuableFish = fish ; } } } } } } } else { if ( selectFishes . length > 0 ) { mostValuableFish = selectFishes [ 0 ] ; } } return mostValuableFish ; } } }