/// <summary> /// Evaluates the GotStatusEffect Components of each Entity to determine which type of status effect it has received. /// The corresponding Status Animation is then created and the GotStatusEffect Component is removed. /// </summary> public override void Process() { CGotStatusEffect statusEffects; CStatusAnimations statusAnims; CPosition pos; for (int i = 0; i < Entities.Count; i++) { statusEffects = World.GetComponent <CGotStatusEffect>(Entities[i]); statusAnims = World.GetComponent <CStatusAnimations>(Entities[i]); pos = World.GetComponent <CPosition>(Entities[i]); if (statusEffects.Contains(typeof(CFrozen))) { HandleFreezeEffect(statusAnims, pos); } if (statusEffects.Contains(typeof(CPoison))) { HandlePoisonEffect(statusAnims, pos); } } /// <summary> /// Remove GotStatusEffect Components from each Entity. /// Backwards looping is used to avoid errors caused when modifying a collection while looping over it. /// </summary> for (int i = Entities.Count - 1; i >= 0; i--) { World.RemoveComponent <CGotStatusEffect>(Entities[i]); } }
/// <summary> /// Loops through each Poisoned Entity and applies poison damage. If the poison has expired, then /// the Poison Component is removed from the Entity. /// </summary> public override void Process() { /// <summary> /// The System where Attacks are registered. /// </summary> DamageSystem damageSystem = World.GetSystem <DamageSystem>(); if (ReadyToApplyPoison(_lastTick, _tickInterval)) { _lastTick = World.GameTime; CPoison poison; for (int i = 0; i < Entities.Count; i++) { poison = World.GetComponent <CPoison>(Entities[i]); if (!Utils.DurationReached(poison.TimeApplied, poison.Duration)) { damageSystem.RegisterAttack(Entities[i], poison.Strength); } else { World.RemoveComponent <CPoison>(Entities[i]); } } } }
public override void Process() { /// <summary> /// This loop represents each Entity with a Collision Component. /// Backwards loop to allow Entities to be removed from the World while looping. /// </summary> for (int i = Entities.Count - 1; i >= 0; i--) { World.RemoveComponent <CCollision>(Entities[i]); } }
/// <summary> /// Fetches the Frozen Component of each Entity. If the effect has expired, /// the Frozen Component is removed from the Entity. /// </summary> public override void Process() { CFrozen frozen; for (int i = 0; i < Entities.Count; i++) { frozen = World.GetComponent <CFrozen>(Entities[i]); if (FreezeExpired(frozen.TimeApplied, frozen.Duration)) { World.RemoveComponent <CFrozen>(Entities[i]); } } }
public override void Process() { CAI AI; CPosition pos; CAnimation anim; /// <summary> /// For each Enemy AI Entity. /// </summary> for (int i = 0; i < Entities.Count; i++) { AI = World.GetComponent <CAI>(Entities[i]); pos = World.GetComponent <CPosition>(Entities[i]); if (!AI.IsInRange) { CheckRange(Entities[i], AI, pos); /// If the AI is now in range, stop moving and begin attacking. if (AI.IsInRange) { World.RemoveComponent <CVelocity>(Entities[i]); } } else if (!AI.AttackIsReady) { CheckCooldown(Entities[i]); } else { anim = World.GetComponent <CAnimation>(Entities[i]); /// <summary> /// Attack will be carried out when the Attack animation has ended. /// </summary> if (SwinGame.AnimationEnded(anim.Anim)) { Attack <CEnemyTeam>(Entities[i]); ///If the Entity has attacked, stand still during the cooldown period. SwinGame.AssignAnimation(anim.Anim, "Still", anim.AnimScript); } } } }