예제 #1
2
 public void Attack(Player player, Enemy enemy)
 {
     Console.WriteLine("\n" + name + " attacked! " + enemy.name + " takes " + strength + " damage.");
     enemy.takeDamage(player.strength);
 }
예제 #2
0
        static void Main(string[] args)
        {
            Player player = new Player();
            Enemy enemy = new Enemy();

            while (player.health >= 0 || enemy.health >= 0)
            {
                player.Fight(player, enemy);
                enemy.Fight(player, enemy);
                Console.WriteLine("\nPress any key to continue...");
                Console.ReadKey();
                Console.Clear();
            }
        }
예제 #3
0
 public void Fight(Player player, Enemy enemy)
 {
     Console.WriteLine("Player health: " + player.health + " ------ Enemy health: " + enemy.health);
     Console.WriteLine("Player energy: " + player.energy + " ------ Enemy energy: " + enemy.energy);
     Console.WriteLine("\nCombat Menu\n" + "-----------------------");
     Console.WriteLine("A) Attack");
     Console.WriteLine("S) Abilities");
     Console.WriteLine("D) Items");
     var choice = Console.ReadKey();
     switch (choice.Key)
     {
         case ConsoleKey.A:
             Console.WriteLine("");
             Attack(player, enemy);
             break;
         case ConsoleKey.S:
             Console.WriteLine("");
             Abilities(player, enemy);
             break;
         case ConsoleKey.D:
             Console.WriteLine("");
             Items();
             break;
         default:
             Console.WriteLine("\n\nError: Unacceptable input. Lost turn due to inability to follow directions.");
             break;
     }
 }
예제 #4
0
 public void Abilities(Player player, Enemy enemy)
 {
     Console.WriteLine("\nAbilities Menu\n" + "-----------------------");
     Console.WriteLine("Z) Use Strong Attack");
     Console.WriteLine("X) Use Heal");
     var choice = Console.ReadKey();
     switch (choice.Key)
     {
         case ConsoleKey.Z:
             if (energy >= 20)
             {
                 Console.WriteLine("\n\n" + name + " used Strong Attack! Did 20 damage, lost 20 energy.");
                 enemy.takeDamage(20);
                 energy -= 20;
             }
             else
             {
                 Console.WriteLine("\n\nNot enough energy to use move!");
             }
             break;
         case ConsoleKey.X:
             if (energy >= 15)
             {
                 Console.WriteLine("\n\n" + name + " used Heal! Restored 25 health, lost 15 energy.");
                 health += 25;
                 energy -= 15;
             }
             else
             {
                 Console.WriteLine("\n\nNot enough energy to use move!");
             }
             break;
         default:
             Console.WriteLine("\n\nError: Unacceptable input. Lost turn due to inability to follow directions.");
             break;
     }
     if (health > 100)
     {
         health = 100;
     }
 }
예제 #5
0
 public void Fight(Player player, Enemy enemy)
 {
     Random random = new Random();
     int rand = random.Next(1, 4);
     if (rand == 1)
     {
         Attack(player, enemy);
     }
     if (rand == 2)
     {
         Abilities(player, enemy);
     }
     if (rand == 3)
     {
         Items();
     }
 }
예제 #6
0
 public void Attack(Player player, Enemy enemy)
 {
     Console.WriteLine(name + " attacked! " + player.name + " takes " + strength + " damage.");
     player.takeDamage(enemy.strength);
 }
예제 #7
0
 public void Abilities(Player player, Enemy enemy)
 {
     Random random = new Random();
     int choice = random.Next(1, 3);
     if (choice == 1)
     {
         if (energy >= 20)
         {
             Console.WriteLine(name + " used Strong Attack! Did 20 damage, lost 20 energy.");
             player.takeDamage(20);
             energy -= 20;
         }
         else
         {
             Console.WriteLine("Not enough energy to use move!");
         }
     }
     if (choice == 2)
     {
         if (energy >= 15)
         {
             Console.WriteLine(name + " used Heal! Restored 25 health, lost 15 energy.");
             health += 25;
             energy -= 15;
         }
         else
         {
             Console.WriteLine("Not enough energy to use move!");
         }
     }
     if (health > 100)
     {
         health = 100;
     }
 }
예제 #8
0
 public Player Kill(Enemy other)
 {
     experience += 25;
     Player temp = this;
     if (other.health <= 0)
     {
         if (experience == 25 + (level * 50))
         {
             temp.level += 1;
             temp.health = 100;
             temp.health += 5 * level;
             temp.strength += 5;
         }
     }
     return temp;
 }
예제 #9
0
 public int Attack(Enemy other)
 {
     return other.takeDamage(strength);
 }