public void ReactToExplosion(BasePlayerProjectile projectile, float amplitude, Vector3 velocity, float altitudeVelocity)
        {
            GetHitBy(projectile, amplitude);

            AltitudeVelocity += altitudeVelocity;

            Velocity = velocity;
        }
        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();
            }
        }
Example #3
0
        private float CalculateAltitudeVelocity(BasePlayerProjectile projectile)
        {
            if (targetEnemy == null)
            {
                return(0f);
            }

            var targetPosition = targetEnemy.Position;
            var targetDistance = Vector3.Distance(projectile.Position, targetPosition);

            var timeToTravel = targetDistance / ProjectileSpeed;

            var altitudeDifference = targetEnemy.Altitude + (targetEnemy.SpriteInstance.Height / 2) - projectile.Altitude;
            var altitudeVelocity   = (altitudeDifference / timeToTravel) - ((projectile.GravityDrag * timeToTravel) / 2);

            return(altitudeVelocity);
        }
Example #4
0
        private float CalculateAltitudeVelocity(BasePlayerProjectile projectile)
        {
            if (targetEnemy == null)
            {
                return(0f);
            }
            ;

            float altitudeDifference = -projectile.Altitude;

            if (!(projectile is CannonProjectile))
            {
                altitudeDifference += targetEnemy.Altitude + (targetEnemy.SpriteInstance.Height / 4);
            }

            var altitudeVelocity = (altitudeDifference / _timeToTravel) - ((projectile.GravityDrag * _timeToTravel) / 2);

            return(altitudeVelocity);
        }