Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Learn1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Warrior[] warriors = { new Hunter("Иллидан", 130, 10, 25), new Knight("Гаррош", 90, 7, 15), new Rogue("Рагнарос", 180, 2, 33, 2), new Paladin("Нефариан", 220, 0, 29), new Mage("Смертокрыл", 500, 0, 15) };
- for (int i = 0; i < warriors.Length; i++)
- {
- Console.Write(i + " ");
- warriors[i].ShowInfo();
- }
- Console.WriteLine("Выберите Первого бойца:");
- int righWarriorIndex = Convert.ToInt32(Console.ReadLine());
- Warrior rightWarrior = warriors[righWarriorIndex];
- Console.WriteLine("Выберите Второго бойца:");
- int leftWarriorIndex = Convert.ToInt32(Console.ReadLine());
- Warrior leftWarrior = warriors[leftWarriorIndex];
- while (leftWarrior.Health > 0 && rightWarrior.Health > 0)
- {
- Console.WriteLine();
- leftWarrior.TakeDamage(rightWarrior.Damage,rightWarrior.Health);
- rightWarrior.TakeDamage(leftWarrior.Damage,leftWarrior.Health);
- leftWarrior.ShowInfo();
- rightWarrior.ShowInfo();
- }
- }
- }
- abstract class Warrior
- {
- private string _name;
- private int _health;
- private int _armor;
- private int _damage;
- public Warrior(string name, int health, int armor, int damage)
- {
- _name = name;
- _health = health;
- _armor = armor;
- _damage = damage;
- }
- public int Health { get { return _health; } }
- public int Damage { get { return _damage; } }
- public void ShowInfo()
- {
- Console.WriteLine($"{_name}: ХП - {_health}, Броня - {_armor}, Дамаг - {_damage}");
- }
- public void TakeDamage(int damage,int health)
- {
- _health -= damage - _armor;
- Spec(damage, health);
- }
- abstract public int Spec(int damage, int health,int attackspeed = 1);
- }
- class Knight : Warrior
- {
- public Knight(string name, int health, int armor, int damage) : base(name, health, armor, damage)
- {
- }
- public int GrateHeal(int damage, int health)
- {
- if(health < 50)
- {
- return health += 30;
- }
- else
- {
- return health;
- }
- }
- public override int Spec(int damage, int health,int attackspeed)
- {
- Console.WriteLine("БАБАЦ");
- return GrateHeal(damage, health);
- }
- }
- class Rogue : Warrior
- {
- public Rogue(string name, int health, int armor, int damage, int attackSpeed) : base(name, health, armor, damage)
- {
- }
- public int DoubleDamage(int damage, int health,int attackspeed)
- {
- return damage * attackspeed;
- }
- public override int Spec(int damage, int health, int attackspeed)
- {
- return DoubleDamage(damage, health, attackspeed);
- }
- }
- class Paladin : Warrior
- {
- public Paladin(string name, int health, int armor, int damage) : base(name, health, armor, damage)
- {
- }
- public override int Spec(int damage, int health,int attackspeed)
- {
- return SpecitalAttack(damage, health);
- }
- public int SpecitalAttack(int damage, int health)
- {
- if(health > 30 && health < 200)
- {
- return damage /= 2;
- }
- else
- {
- return damage;
- }
- }
- }
- class Mage : Warrior
- {
- public Mage(string name, int health, int armor, int damage) : base(name, health, armor, damage)
- {
- }
- public int FireBolt(int damage, int health)
- {
- int attack = 5;
- return damage*= attack;
- }
- public override int Spec(int damage, int health,int attackspeed)
- {
- return FireBolt(damage, health);
- }
- }
- class Hunter : Warrior
- {
- public Hunter(string name, int health, int armor, int damage) : base(name, health, armor, damage)
- {
- }
- public int AimShot(int damage, int health)
- {
- return damage *= 5;
- }
- public override int Spec(int damage, int health, int attackspeed)
- {
- return AimShot(damage, health);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement