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 FightWarriorV2
- {
- class Program
- {
- static void Main(string[] args)
- {
- int userInput;
- int chooseEnemyAttack;
- Enemy enemy = new Enemy();
- Render render = new Render();
- Random random = new Random();
- Console.WriteLine("Выберите класс: \n1. Лучник \n2. Берсерк");
- userInput = Convert.ToInt32(Console.ReadLine());
- Warrior player = ChooseClase(userInput);
- Console.Clear();
- while (player.Health > 0 && enemy.Health > 0)
- {
- render.RenderPlayerInfo(player.Name, player.Health);
- render.RenderEnemyInfo(enemy.Name, enemy.Health);
- render.ChooseAttack(player.Spell);
- userInput = Convert.ToInt32(Console.ReadLine());
- render.RenderPlayerAttack(player.Spell[userInput - 1].About, enemy.ProceduralDamage(player.Spell[userInput - 1].Damage, player.RangeAttack()));
- enemy.TakeDamage(player.Spell[userInput - 1].Damage, player.RangeAttack());
- if (enemy.Health <= 0)
- break;
- if (!player.RangeAttack())
- {
- player.TakeDamage(enemy.Spell[3].Damage);
- Console.WriteLine($"Противник наносит контрудар на {player.ProceduralDamage(enemy.Spell[3].Damage)}");
- }
- chooseEnemyAttack = random.Next(0, 3);
- render.RenderEnemyAttack(enemy.Spell[chooseEnemyAttack].About, player.ProceduralDamage(enemy.Spell[chooseEnemyAttack].Damage));
- player.TakeDamage(enemy.Spell[chooseEnemyAttack].Damage);
- if (player.Health <= 0)
- break;
- Console.ReadKey();
- Console.Clear();
- }
- }
- static Warrior ChooseClase(int userInput)
- {
- switch (userInput)
- {
- case 1:
- return new Archer();
- case 2:
- return new Berserk();
- default:
- return null;
- }
- }
- }
- abstract class Warrior
- {
- public string Name { get; protected set; }
- public float Health { get; protected set; }
- public Spell[] Spell { get; protected set; }
- public abstract bool RangeAttack();
- public void TakeDamage(float damage)
- {
- Health -= ProceduralDamage(damage);
- }
- public abstract float ProceduralDamage(float damage);
- }
- class Archer : Warrior
- {
- public Archer(string name = "Лучник", float health = 60)
- {
- Spell[] spell =
- {
- new Spell("Точный выстрел", 10),
- new Spell("Двойной выстрел", 20),
- new Spell("Тройной выстрел", 30)
- };
- Name = name;
- Health = health;
- Spell = spell;
- }
- public override bool RangeAttack()
- {
- return true;
- }
- public override float ProceduralDamage(float damage)
- {
- return damage * 1.5f;
- }
- }
- class Berserk : Warrior
- {
- public Berserk(string name = "Берсерк", float health = 60)
- {
- Spell[] spell =
- {
- new Spell("Удар сверху", 10),
- new Spell("Размашистый удар", 15),
- new Spell("Вихрь клинков", 20)
- };
- Name = name;
- Health = health;
- Spell = spell;
- }
- public override bool RangeAttack()
- {
- return false;
- }
- public override float ProceduralDamage(float damage)
- {
- return damage * 0.7f;
- }
- }
- class Spell
- {
- public string About;
- public int Damage;
- public Spell(string about, int damage)
- {
- About = about;
- Damage = damage;
- }
- }
- class Enemy
- {
- public string Name = "Лерой Дженкинс";
- public float Health = 50;
- public Spell[] Spell = {new Spell("Удар в лоб", 10), new Spell("Крик - Лирооооооой Дженкинс", 15), new Spell("Пробежка по логову драконов", 20), new Spell("Контрудар", 5)};
- public void TakeDamage(float damage, bool range)
- {
- Health -= ProceduralDamage(damage, range);
- }
- public float ProceduralDamage(float damage, bool range)
- {
- if (range)
- return damage * 0.8f;
- else
- return damage * 1.2f;
- }
- }
- class Render
- {
- public void RenderPlayerInfo(string name, float health)
- {
- Console.SetCursorPosition(0, 0);
- Console.WriteLine($"Вы, {name}");
- Console.SetCursorPosition(0, 1);
- Console.WriteLine($"Ваше здоровье: {health}");
- }
- public void RenderEnemyInfo(string name, float health)
- {
- Console.SetCursorPosition(50, 0);
- Console.WriteLine($"Ваш враг, {name}");
- Console.SetCursorPosition(50, 1);
- Console.WriteLine($"Здоровье врага: {health}");
- }
- public void ChooseAttack(Spell[] spell)
- {
- Console.WriteLine("Выберите атаку:");
- for (int i = 0; i < spell.GetLength(0); i++)
- {
- Console.WriteLine($"{i+1}. {spell[i].About}. Урон: {spell[i].Damage}.");
- }
- }
- public void RenderPlayerAttack(string attack, float damage)
- {
- Console.WriteLine($"Вы используете {attack} и наносите {damage} урона.");
- }
- public void RenderEnemyAttack(string attack, float damage)
- {
- Console.WriteLine($"Враг использует {attack} и наносит {damage} урона.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement