private void SetupStage(bool animate)
 {
     _currentStage = _stages[_currentStageIndex];
     _currentFrame = _currentStage.StartFrame;
     if (_useTimer)
     {
         _timer.Interval = _currentStage.Interval;
     }
     if (animate)
     {
         Animate();
     }
 }
 public int AddStage(int startFrame, int endFrame, bool loop, int interval, bool nextStageAfterComplete, bool destroyAfterComplete)
 {
     _stages.Add(new AnimationStage(startFrame, endFrame, loop, interval, nextStageAfterComplete, destroyAfterComplete));
     if (_stages.Count == 1)
     {
         _currentStage = _stages[0];
         _currentFrame = _currentStage.StartFrame;
         if (_useTimer)
         {
             _timer.Interval = _currentStage.Interval;
         }
     }
     return(_stages.Count - 1);
 }
 public Animation(GameObject parent,int width,int height,bool useTimer)
 {
     _texture=parent._texture;
     _textureRect=new Rectangle(0,0,_texture.Width,_texture.Height);
     _displayRect=new Rectangle(0,0,width,height);
     _cols=_texture.Width/width;
     _rows=_texture.Height/height;
     _totalFrames=_cols*_rows;
     _parent=parent;
     _currentStage=new AnimationStage(0,_totalFrames-1,true,0,false);
     _parent._srcRect=_displayRect;
     _currentStageIndex=0;
     _useTimer=useTimer;
     if (_useTimer){
         _timer=new Timer(DEFAULT_FRAME_DELAY,0,Animate,this);
         _timerIndex=Timers.Add(_timer);
     }
 }
 public Animation(GameObject parent, int width, int height, bool useTimer)
 {
     _texture           = parent._texture;
     _textureRect       = new Rectangle(0, 0, _texture.Width, _texture.Height);
     _displayRect       = new Rectangle(0, 0, width, height);
     _cols              = _texture.Width / width;
     _rows              = _texture.Height / height;
     _totalFrames       = _cols * _rows;
     _parent            = parent;
     _currentStage      = new AnimationStage(0, _totalFrames - 1, true, 0, false);
     _parent._srcRect   = _displayRect;
     _currentStageIndex = 0;
     _useTimer          = useTimer;
     if (_useTimer)
     {
         _timer      = new Timer(DEFAULT_FRAME_DELAY, 0, Animate, this);
         _timerIndex = Timers.Add(_timer);
     }
 }
 public int AddStage(int startFrame,int endFrame,bool loop,int interval,bool nextStageAfterComplete,bool destroyAfterComplete)
 {
     _stages.Add(new AnimationStage(startFrame,endFrame,loop,interval,nextStageAfterComplete,destroyAfterComplete));
     if (_stages.Count==1) {
         _currentStage=_stages[0];
         _currentFrame=_currentStage.StartFrame;
         if (_useTimer)
             _timer.Interval=_currentStage.Interval;
     }
     return _stages.Count-1;
 }
 private void SetupStage(bool animate)
 {
     _currentStage=_stages[_currentStageIndex];
     _currentFrame=_currentStage.StartFrame;
     if (_useTimer)
         _timer.Interval=_currentStage.Interval;
     if (animate)
         Animate();
 }