예제 #1
0
        private void DamageCharacters(float deltaTime)
        {
            if (size.X <= 0.0f)
            {
                return;
            }

            for (int i = 0; i < Character.CharacterList.Count; i++)
            {
                Character c = Character.CharacterList[i];
                if (c.AnimController.CurrentHull == null || c.IsDead)
                {
                    continue;
                }

                if (!IsInDamageRange(c, DamageRange))
                {
                    continue;
                }

                float dmg = (float)Math.Sqrt(size.X) * deltaTime / c.AnimController.Limbs.Length;
                foreach (Limb limb in c.AnimController.Limbs)
                {
                    c.LastDamageSource = null;
                    c.DamageLimb(WorldPosition, limb, new List <Affliction>()
                    {
                        AfflictionPrefab.Burn.Instantiate(dmg)
                    }, 0.0f, false, 0.0f);
                }
                c.ApplyStatusEffects(ActionType.OnFire, deltaTime);
            }
        }
예제 #2
0
 private void ApplyDamage(float deltaTime, bool applyForce)
 {
     foreach (Limb limb in character.AnimController.Limbs)
     {
         float random = Rand.Value(Rand.RandSync.Server);
         huskInfection.Clear();
         huskInfection.Add(AfflictionPrefab.InternalDamage.Instantiate(random * 10 * deltaTime / character.AnimController.Limbs.Length));
         character.LastDamageSource = null;
         float force = applyForce ? random * 0.5f * limb.Mass : 0;
         character.DamageLimb(limb.WorldPosition, limb, huskInfection, 0, false, force);
     }
 }
예제 #3
0
        private void ApplyDamage(float deltaTime, bool applyForce)
        {
            int limbCount = character.AnimController.Limbs.Count(l => !l.ignoreCollisions && !l.IsSevered);

            foreach (Limb limb in character.AnimController.Limbs)
            {
                if (limb.IsSevered)
                {
                    continue;
                }
                float random = Rand.Value();
                huskInfection.Clear();
                huskInfection.Add(AfflictionPrefab.InternalDamage.Instantiate(random * 10 * deltaTime / limbCount));
                character.LastDamageSource = null;
                float force = applyForce ? random * 0.5f * limb.Mass : 0;
                character.DamageLimb(limb.WorldPosition, limb, huskInfection, 0, false, force);
            }
        }
예제 #4
0
        private void DamageCharacters(float deltaTime)
        {
            if (size.X <= 0.0f)
            {
                return;
            }

            for (int i = 0; i < Character.CharacterList.Count; i++)
            {
                Character c = Character.CharacterList[i];
                if (c.CurrentHull == null || c.IsDead)
                {
                    continue;
                }

                if (!IsInDamageRange(c, DamageRange))
                {
                    continue;
                }

                //GetApproximateDistance returns float.MaxValue if there's no path through open gaps between the hulls (e.g. if there's a door/wall in between)
                if (hull.GetApproximateDistance(Position, c.Position, c.CurrentHull, 10000.0f) > size.X + DamageRange)
                {
                    return;
                }

                float dmg = (float)Math.Sqrt(Math.Min(500, size.X)) * deltaTime / c.AnimController.Limbs.Count(l => !l.IsSevered);
                foreach (Limb limb in c.AnimController.Limbs)
                {
                    if (limb.IsSevered)
                    {
                        continue;
                    }
                    c.LastDamageSource = null;
                    c.DamageLimb(WorldPosition, limb, AfflictionPrefab.Burn.Instantiate(dmg).ToEnumerable(), 0.0f, false, 0.0f);
                }
#if CLIENT
                //let clients display the client-side damage immediately, otherwise they may not be able to react to the damage fast enough
                c.CharacterHealth.DisplayedVitality = c.Vitality;
#endif
                c.ApplyStatusEffects(ActionType.OnFire, deltaTime);
            }
        }
예제 #5
0
        private void UpdateActiveState(float deltaTime, Character character)
        {
            if (state != InfectionState.Active)
            {
                ActivateHusk(character);
                state = InfectionState.Active;
            }

            foreach (Limb limb in character.AnimController.Limbs)
            {
                character.LastDamageSource = null;
                character.DamageLimb(
                    limb.WorldPosition, limb,
                    new List <Affliction>()
                {
                    AfflictionPrefab.InternalDamage.Instantiate(0.5f * deltaTime / character.AnimController.Limbs.Length)
                },
                    0.0f, false, 0.0f);
            }
        }