public void ReactOnCreature(CreatureBaseAbstract c) { if (c.WorldPosition == WorldPosition && Name != c.Name) { Attack(this, c); MoveRandomly(); } }
public void Attack(CreatureBaseAbstract a, CreatureBaseAbstract b) { Console.WriteLine(a.Name + " is attacking " + b.Name + "!"); IState damageState = new DamageStateHealthy(); if (a.Health < 25) { b.CheckIfDead(); damageState = new DamageStateWounded(); damageState.CalculateDamage(a, b); resetDamage(a); } else if (a.Health > 25) { b.CheckIfDead(); damageState = new DamageStateHealthy(); resetDamage(a); damageState.CalculateDamage(a, b); } Console.WriteLine(b.Name + " got hit with: " + a.Damage + " and now has: " + b.Health + " health left."); }