Exemplo n.º 1
0
        public void doCombat(Player player, ref bool escape, int choice, ref bool newGame)
        {
            string answer;
            if (hasEnemy(choice) && RoomInstance.enemy.Alive == true)
            {
                while (Combat(player))
                {
                    escape = false;
                    Clear(); //clear screen to draw combat
                    Draw(player, RoomInstance.enemy);
                    Draw("1: Attack\n2: Run");
                    choice = userInput(2);
                    switch (choice)
                    {
                        case 0: //return to title
                            Draw("Are you sure you want to return to the main menu? Y/N");
                            answer = getInput();
                            if (answer == "y" || answer == "Y")
                            {
                                GameRunning = false;
                                newGame = true;
                                Clear();
                            }
                            break;
                        case 1://attack
                            Console.WriteLine("You attack with {0}, doing {1} damage to the {2}", player.weaponName(), player.Damage(), RoomInstance.enemy.Name);
                            RoomInstance.enemy.Health -= player.Damage();
                            if (rnd() < 4)
                            {
                                Console.WriteLine("On counter attack, {0} hits you for {1} damage.", RoomInstance.enemy.Name, RoomInstance.enemy.WeaponDamage);
                                player.Health -= RoomInstance.enemy.WeaponDamage;
                            }
                            ReadLine();

                            break;
                        case 2://try to run
                            if (rnd() < 2)
                            {
                                Console.WriteLine("You fail to escape, {0} hits you for {1} damage.", RoomInstance.enemy.Name, RoomInstance.enemy.WeaponDamage);
                                player.Health -= RoomInstance.enemy.WeaponDamage;
                                ReadLine();

                            }
                            else
                            {
                                escape = true;
                            }
                            break;
                        default:
                            choice = userInput(2);

                            break;
                    }
                    if (escape == true && player.Location < 5)
                    {
                        Draw("You get away safely, but the monster still lurks");
                        ReadLine();
                        break;
                    }
                    else if(escape == true && player.Location == 5)
                    {
                        Draw("You cannot escape this battle!");
                        ReadLine();
                        escape = false;
                    }

                }
                if (player.Health <= 0)
                {
                    Clear();
                    Console.WriteLine("Game Over");
                    player.Health = 0;
                    Draw(player);
                    Draw("\nPress Enter to return to the title screen.");
                    GameRunning = false;
                    newGame = true;
                }
                else if (escape == false)
                {
                    Draw("\nHurray you killed the monster!");
                    player.weaponGet().WeaponLevel++;
                    player.Score += RoomInstance.enemy.Points;

                    player.Level++;
                    player.weaponGet().WeaponLevel++;
                    RoomInstance.enemy.Alive = false;
                    if (player.Health < Player.maxHP / 4)
                    {
                        Draw("You consume the soul of your fallen enemy, restoring your health");

                        player.Health = Player.maxHP;
                    }
                }
                ReadLine();
            }
        }
Exemplo n.º 2
0
 public static void Draw(Player player, Enemy enemy)
 {
     Console.WriteLine("Score: '{0}' Health: '{1}' Name: '{2}' Damage: '{3}'\n\n", player.Score, player.Health, player.Name, player.Damage());
     Console.WriteLine("Health: '{0}' Name: '{1}'\n\n", enemy.Health, enemy.Name);
 }