Ejemplo n.º 1
0
        void LoadPlanet() //This method loads a planet depending on the item (spaceship) that the player has obtained.
        {
            Console.Clear();

            try
            {
                Console.WriteLine("========================================================\n" +
                                  "You are trying to travel....analyzing ship.....\n" +
                                  "Press [Enter]\n");
                Console.ReadKey();

                if (player.Item == gameManager.Bounty)
                {
                    player.ResetHealth();
                    Planet planet = planetManager.ReturnPlanet(gameManager.Bounty - 1);

                    Console.WriteLine($"Your ship has the required components for travelling to {planet.Name}.\n" +
                                      $"You enter your spaceship and start navigating through space.....\n" +
                                      $"========================================================\n" +
                                      "Press [Enter]");
                    Console.ReadKey();
                    Console.Clear();
                    planet.Soundtrack.PlayLooping();
                    Console.WriteLine(planet.Text);
                    Console.WriteLine("You start searching for bounty....\nIs that an enemy?\n");
                    foreach (var enemy in planet.Enemies)
                    {
                        Console.WriteLine($"=================================================================\n" +
                                          $"{enemy.Name}: { enemy.AppearMessage}\n" +
                                          "=================================================================\n");
                        Fight  fight = new Fight(planet.Op);
                        string answer;
                        do
                        {
                            Console.WriteLine(fight.DisplayFight(enemy, player));
                            Console.WriteLine("\nWhat's your answer Aster?");
                            answer = Console.ReadLine();

                            if (fight.InputAnswer(answer))
                            {
                                enemy.LoseHealth(1);
                            }
                            else
                            {
                                player.LoseHealth(1);
                            }
                        } while (!enemy.IsDead() && !player.IsDead());

                        if (player.IsDead())
                        {
                            Console.WriteLine("You are dead, Aster.\n");
                            Console.WriteLine("Press [Enter] to try again...");
                            Console.ReadKey();
                            LoadPlanet();
                        }
                        else
                        {
                            Console.WriteLine($"===================================\n" +
                                              $"{enemy.Name} is dead. \n" +
                                              $"===================================\n");
                        }

                        Console.WriteLine("Press [Enter] to continue traversing through planet.");
                        Console.ReadKey();
                        Console.Clear();
                    }
                    gameManager.Bounty += 1;
                    player.AddCoins(planet.Coins);
                    Console.WriteLine("========================================================\n" +
                                      "You find no other inhabitants.\n " +
                                      $"You have cleared {planet.Name} of imperial rule....\n" +
                                      "Press [Enter] to collect bounty and return to Hubb...\n" +
                                      "========================================================");
                    Console.ReadKey();
                }

                else
                {
                    Console.Clear();
                    Console.WriteLine("You do not have the proper spaceship to travel to the next planet.\n" +
                                      "Press [Enter] to return to the Hubb....");
                    Console.ReadKey();
                }

                if (gameManager.Bounty > planetManager.ReturnPlanets().Count)
                {
                    EndGame();
                }
                else
                {
                    LoadHubb();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }