예제 #1
0
        public override void Draw(GameTime gameTime)
        {
            _elapsedSinceLastAnimationChange += gameTime.ElapsedGameTime;
            if (_elapsedSinceLastAnimationChange > (_inAttackAnimation ? AttackAnimationStepTime : _animationStepTime))
            {
                _elapsedSinceLastAnimationChange = TimeSpan.Zero;
                _currentAnimationStepIndex++;
                if (_currentAnimationStepIndex == _animationStepCount)
                {
                    _currentAnimationStepIndex = 0;
                    if (_inAttackAnimation)
                    {
                        DealDamage?.Invoke(this);
                    }
                    _inAttackAnimation = false;
                }
            }

            var source = new Rectangle(_currentAnimationStepIndex * _spriteWidth,
                                       (_animationIndex + (_inAttackAnimation ? 4 : 0)) * _spriteHeight,
                                       _spriteWidth, _spriteHeight);

            ((Game1)Game).SpriteBatch.Draw(_sprite, Position - new Vector2(_spriteWidth / 2f, _spriteHeight / 2f),
                                           source, _color);

            base.Draw(gameTime);
        }
예제 #2
0
 private IEnumerator Attack()
 {
     while (true)
     {
         DealDamage?.Invoke(_damage);
         yield return new WaitForSeconds(_attackCooldown);
     }
 }
예제 #3
0
 public void OnTick(int tick)
 {
     DealDamage?.Invoke(Description, SpellCastIndex, DPS);
 }