/**
* 技能cd特效
* r:圆的半径
* skillTimer:技能时间
* color:圆环的填充颜色
**/ module FishingJoy { export class SkillCDEffect extends egret . Sprite { private shape : egret . Shape ; private RectMy : eui . Rect ; private layeMy : egret . DisplayObjectContainer ; private label : eui . Label ; public constructor ( layer , x , y , width , heith , Continued , cooling , type ) { super ( ) ; this . layeMy = layer ; this . clickAnimation ( layer , x , y , width , heith , Continued , cooling , type ) ; } /**
         * 点击动效
         */ public clickAnimation ( layer , x , y , width , heith , Continued , cooling , type ) { this . initGraphics ( layer , x , y ) ; this . changeGraphics ( Continued , cooling , type , x ) ; this . RectMy = new eui . Rect ( ) ; let RectMy = this . RectMy ; layer . addChild ( RectMy ) ; RectMy . width = width ; RectMy . touchEnabled = false ; RectMy . height = heith ; RectMy . anchorOffsetX = RectMy . width / 2 ; RectMy . anchorOffsetY = RectMy . height / 2 ; RectMy . fillAlpha = 0.7 ; RectMy . x = x ; RectMy . y = y ; RectMy . ellipseWidth = 7 ; RectMy . ellipseHeight = 7 ; RectMy . mask = this . shape ; } public initGraphics ( layer , x , y ) { this . shape = new egret . Shape ( ) ; layer . addChild ( this . shape ) ; this . shape . anchorOffsetX = this . shape . width / 2 ; this . shape . anchorOffsetY = this . shape . height / 2 ; this . shape . rotation = - 90 ; this . shape . touchEnabled = false ; this . shape . x = x ; this . shape . y = y ; } public destroy ( ) { if ( this . shape ) this . layeMy . removeChild ( this . shape ) ; if ( this . RectMy ) this . layeMy . removeChild ( this . RectMy ) ; this . removeChildren ( ) ; } private coolingTime ( type , boolMy ) { if ( type == 0 ) { FishingJoy . Master . instance . isFastShootCooling = boolMy ; } else if ( type == 1 ) { FishingJoy . Master . instance . isAimShootCooling = boolMy ; } else if ( type == 2 ) { FishingJoy . Master . instance . isAutoShootCooling = boolMy ; } else if ( type == 4 ) { FishingJoy . Master . instance . isFrozenShootCooling = boolMy ; } } private changeGraphics ( Continued , cooling , type , x ) { let shape = this . shape ; let angle = 0 ; let i = - 1 ; let Timer ; let countDown ; let battery = FishingJoyLogic . instance . allBattery . get ( Master . instance . uid ) ; if ( battery == null ) return ; countDown = Continued ; let startTime = Date . now ( ) ; let speed = 360 / Continued ; let moveStars = function ( timeStamp ) { let end = Date . now ( ) ; angle = speed * ( end - startTime ) ; changeGraphics ( angle ) ; this . coolingTime ( type , true ) ; if ( angle >= 360 ) { i = 1 ; angle = 0 ; EventManager . fireEvent ( EVENT_ID . CHANEG_SHOOT_TYPE , [ type , false ] ) ; this . destroy ( ) ; game . Timer . clearInterval ( Timer ) ; this . coolingTime ( type , false ) ; } return false ; } ; Timer = game . Timer . setInterval ( moveStars , this , 20 ) ; function changeGraphics ( angle ) { shape . graphics . clear ( ) ; shape . graphics . beginFill ( 0xB0E2FF , 1 ) ; shape . graphics . moveTo ( 0 , 0 ) ; shape . graphics . lineTo ( 60 , 0 ) ; shape . graphics . drawArc ( 0 , 0 , 60 , 0 , angle * Math . PI / 180 , i == - 1 ) ; shape . graphics . lineTo ( 0 , 0 ) ; shape . graphics . endFill ( ) ; } } } }