static void Main(string[] args) { Sword sword1 = new Sword(20, 40); Dagger dagger1 = new Dagger(10, 100); Soldier soldier1 = new Soldier("een", dagger1, 1400); Soldier soldier2 = new Soldier("twee", sword1, 2000); Mage mage1 = new Mage("Merlijn", 1000); BattleArena arena = new BattleArena(mage1, soldier1); arena.StartFight(); Console.ReadLine(); }
public void StartFight() { while (Soldiers[0].IsAlive && Soldiers[1].IsAlive) { int hit = Soldiers[1].Attack(); Soldiers[0].ReceieveDamage(hit); if (Soldiers[1] is Mage) { Mage tempMage = Soldiers[1] as Mage; Console.WriteLine($"{Soldiers[0].Naam} is geraakt met {hit} {tempMage.Spells[tempMage.AttackType].DamageType} damage en heeft nog {Soldiers[0].Healthpoints} over."); } else { Soldier tempSoldier = Soldiers[1] as Soldier; Console.WriteLine($"{Soldiers[0].Naam} is geraakt met {hit} {tempSoldier.Weapon.DamageType} damage en heeft nog {Soldiers[0].Healthpoints} over."); } if (Soldiers[0].IsAlive) { hit = Soldiers[0].Attack(); Soldiers[1].ReceieveDamage(hit); if (Soldiers[0] is Mage) { Mage tempMage = Soldiers[0] as Mage; Console.WriteLine($"{Soldiers[1].Naam} is geraakt met {hit} {tempMage.Spells[tempMage.AttackType].DamageType} damage en heeft nog {Soldiers[1].Healthpoints} over."); } else { Soldier tempSoldier = Soldiers[0] as Soldier; Console.WriteLine($"{Soldiers[1].Naam} is geraakt met {hit} {tempSoldier.Weapon.DamageType} damage en heeft nog {Soldiers[1].Healthpoints} over."); } } else { break; } } if (Soldiers[0].Healthpoints > Soldiers[1].Healthpoints) { Console.WriteLine($"{Soldiers[0].Naam} is gewonnen."); } else { Console.WriteLine($"{Soldiers[1].Naam} is gewonnen."); } }