Exemplo n.º 1
0
        public void GetHitBy(BasePlayerProjectile projectile, float dmgMultiplier = 1)
        {
            if (isHorde)
            {
                return;
            }

            var effectiveMultiplier = GetEffectiveMultiplier(projectile.DamageType);
            var dmgInflicted        = effectiveMultiplier * projectile.DamageInflicted * dmgMultiplier;

            TakeDamage(dmgInflicted);

            var shouldBeHurt = true;

            switch (projectile.DamageType)
            {
            case DamageTypes.Frost:
                _frostDurationSeconds = projectile.StatusEffectSeconds * effectiveMultiplier;
                _frostDamagePerSecond = dmgInflicted * projectile.StatusDamageMultiplier;
                _burnDurationSeconds  = 0;
                shouldBeHurt          = false;
                break;

            case DamageTypes.Chemical:
                _poisonedDurationSeconds = projectile.StatusEffectSeconds * effectiveMultiplier;
                _poisonDamagePerSecond   = dmgInflicted * projectile.StatusDamageMultiplier;
                shouldBeHurt             = false;
                break;

            case DamageTypes.Electrical:
                _stunnedDurationSeconds = projectile.StatusEffectSeconds * effectiveMultiplier;
                break;

            case DamageTypes.Fire:
                _burnDurationSeconds  = projectile.StatusEffectSeconds * effectiveMultiplier;
                _burnDamagePerSecond  = dmgInflicted * projectile.StatusDamageMultiplier;
                _frostDurationSeconds = 0;
                break;
            }
            UpdateStatusEffect(justApplied: true);

            if (!IsDead && shouldBeHurt)
            {
                CurrentActionState = Action.Hurt;
                SpriteInstance.UpdateToCurrentAnimationFrame();
                UpdateSpritesRelativeY();
            }
        }
Exemplo n.º 2
0
        protected void UpdateAnimation()
        {
            if (SpriteInstance.CurrentChain == null || SpriteInstance.CurrentChain.Count == 1)
            {
                SpriteInstance.RelativeY = _spriteRelativeY;
            }
            else
            {
                SpriteInstance.UpdateToCurrentAnimationFrame();

                if (SpriteInstance.UseAnimationRelativePosition)
                {
                    SpriteInstance.RelativeX *= (SpriteInstance.FlipHorizontal
                        ? -SpriteInstance.TextureScale
                        : SpriteInstance.TextureScale);
                    SpriteInstance.RelativeY *= (SpriteInstance.FlipVertical
                        ? -SpriteInstance.TextureScale
                        : SpriteInstance.TextureScale);
                }
                SpriteInstance.RelativeY += _spriteRelativeY;
            }
        }