Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Glads
- {
- class Program
- {
- static void Main(string[] args)
- {
- Rogue rogue = new Rogue(60, 1);
- Paladin paladin = new Paladin(100, 6);
- Vampire vampire = new Vampire(50, 10);
- Druid druid = new Druid(80, 7);
- Shaman shaman = new Shaman(70, 8);
- List<Fighter> fighterList = new List<Fighter>();
- fighterList.Add(rogue);
- fighterList.Add(paladin);
- fighterList.Add(vampire);
- fighterList.Add(druid);
- fighterList.Add(shaman);
- Console.WriteLine("Выберите бойцов (Поочередно введите две цифры):\n1 - Rogue\n2 - Paladin\n3 - Vampire\n4 - Druid\n5 - Shaman");
- int userInput1 = Convert.ToInt32(Console.ReadLine());
- int userInput2 = Convert.ToInt32(Console.ReadLine());
- fighterList[userInput1 - 1].startFight(fighterList[userInput1 - 1], fighterList[userInput2 - 1]);
- }
- abstract class Fighter
- {
- protected int Health;
- protected int Damage;
- public Fighter(int health, int damage)
- {
- Health = health;
- Damage = damage;
- }
- public void startFight(Fighter fighter1, Fighter fighter2)
- {
- Console.WriteLine("Start!");
- while (fighter1.Health >= 0 && fighter2.Health >= 0)
- {
- fighter1.TakeDamage(fighter2.Damage);
- fighter2.TakeDamage(fighter1.Damage);
- fighter1.SpecialAbility();
- fighter2.SpecialAbility();
- fighter1.ShowInfo(1);
- fighter2.ShowInfo(2);
- Console.ReadKey();
- Console.Clear();
- }
- if (fighter1.Health > 0)
- {
- Console.WriteLine("Победил первый боец!");
- }
- else
- {
- Console.WriteLine("Победил второй боец!");
- }
- }
- public void TakeDamage(int damageAmount)
- {
- Health -= damageAmount;
- }
- abstract public void SpecialAbility();
- public void ShowInfo(int fighterNumber)
- {
- Console.WriteLine($"Здоровье бойца номер: {fighterNumber} = {Health}");
- }
- }
- class Rogue : Fighter
- {
- public Rogue(int health, int damage) : base(health, damage) { }
- public override void SpecialAbility()
- {
- Damage += 3;
- }
- }
- class Paladin : Fighter
- {
- public Paladin(int health, int damage) : base(health, damage) { }
- public override void SpecialAbility()
- {
- Health += 1;
- }
- }
- class Vampire : Fighter
- {
- public Vampire(int health, int damage) : base(health, damage) { }
- public override void SpecialAbility()
- {
- Damage += 1;
- Health += 2;
- }
- }
- class Druid : Fighter
- {
- public Druid(int health, int damage) : base(health, damage) { }
- public override void SpecialAbility()
- {
- if (Health <= 20)
- {
- Damage += 15;
- }
- }
- }
- class Shaman : Fighter
- {
- public Shaman(int health, int damage) : base(health, damage) { }
- private bool cooldown = false;
- public override void SpecialAbility()
- {
- if (Health <= 15 && cooldown != true)
- {
- Health += 50;
- cooldown = true;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement