Улучшение характеристик юнитов
class Unit
{
public string name;
public int health;
public int MaxHealth;
public int armor;
public int damage;
public bool IsAlive;
public Unit(string name, int health, int armor, int damage)
{
this.name = name;
this.health = health;
this.MaxHealth = this.health;
this.damage = damage;
this.armor = armor;
this.IsAlive = true;
}
}
Требуется реализация еще одного метода на подобии под этим заголовком, но он должен выполнять улучшения все существующих юнитов
class Smithy : Unit
{
int lvl;
public Smithy() : base("Smithy", 40, 0, 0)
{
this.lvl = 0;
}
public void UpgradeUnit(Unit unit)
{
if (this.lvl <= 2)
{
this.lvl++;
unit.damage += 20;
unit.health += 20;
Console.WriteLine($"the {unit.name} lvl up");
Console.WriteLine($"{unit.damage} {unit.health} {lvl}");
}
else
{
Console.WriteLine($"the {unit.name} max lvl");
}
}
public void UpgradeAllUnit()
{
}
}
Юниты: маг, воин, лучник
public Mage() : base("Wizard", 60, 4, 40)
{
this.Mana = 1000;
this.MaxMana = this.Mana;
}
public FootMan() : base("footman", 80, 7, 20)
{
}
public Archer() : base("Archer", 70, 5, 20)
{
this.Arrows = 20;
}