public void TakeDamage(int damage) { if (_accessory != null) { _accessory.Health -= damage; var temp = _accessory.Health; //temp health for leftover damage if (_accessory.Health <= 0 && _accessory.Type == "R") //dead zombie { Die(); } else if (_accessory.Health <= 50 && _accessory.Type != "R") //become regular zombie if health is below 50 (regular zombie max health) { _accessory = AccessoryFactory.GetAccessory("1"); _accessory.Health = temp; Console.Write(" Becoming Regular zombie."); } } }
public Zombie(string accessoryType) { isAlive = true; health = 50; _accessory = AccessoryFactory.GetAccessory(accessoryType); }