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 ConsoleApplication38
- {
- class Program
- {
- static void Main(string[] args)
- {
- Game game = new Game();
- Console.WriteLine("Welcome to Shlyapa Bojarskogo video game!");
- game.player1 = new Archer();
- game.player2 = new Mage();
- do
- {
- game.StartGame();
- Console.WriteLine(game.player1.Health);
- Console.WriteLine(game.player2.Health);
- Console.WriteLine();
- if (game.player1.Health <= 0)
- {
- Console.WriteLine("Player 2 Wins!");
- break;
- }
- else if (game.player2.Health <= 0)
- {
- Console.WriteLine("Player 1 Wins!");
- break;
- }
- }
- while (true);
- }
- }
- class Game
- {
- public Character player1;
- public Character player2;
- public void StartGame()
- {
- player2.Health = player2.Health - player1.Attack() + player2.magicBarier;
- player1.Health = player1.Health - player2.Attack();
- }
- }
- class Character
- {
- public int Health = 100;
- public int magicBarier = 10;
- public virtual int Attack()
- {
- return 0;
- }
- }
- class Warrior : Character
- {
- public override int Attack()
- {
- return 30;
- }
- }
- class Archer : Character
- {
- Random rnd = new Random();
- public override int Attack()
- {
- if (rnd.Next(2) == 1)
- return 20;
- else
- return 30;
- }
- }
- class Mage : Character
- {
- public override int Attack()
- {
- return 15;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement