Exemple #1
0
        private static void ShowActionMenu(Character myCharacter, List <SolarSystem> universe, Items[] tradingGoods, string[] TradeMenu)
        {
            bool keepLooping = true;

            do
            {
                bool commandNotExecuted = true;
                do
                {
                    Menus.WelcomeScreen();
                    try
                    {
                        Console.Write("\nSelect from the following options:\n\n1. Status\n2. Trade\n3. Travel to...\n4. Refuel\n5. Change ship\n6. Quit game\n\n>>> ");
                        MenuSelection selection = new MenuSelection(Console.ReadLine().Trim());
                        if (Enumerable.Range(1, 6).Contains(selection.GetSelection()))
                        {
                            switch (selection.GetSelection())
                            {
                            case 1:
                                Console.Clear();
                                Menus.WelcomeScreen();
                                myCharacter.ShowStatus();
                                break;

                            case 2:
                                Console.Clear();
                                Menus.WelcomeScreen();
                                Trade(tradingGoods, myCharacter, TradeMenu);
                                break;

                            case 3:
                                Console.Clear();
                                Menus.WelcomeScreen();
                                myCharacter.Travel(universe);
                                break;

                            case 4:
                                Console.Clear();
                                Menus.WelcomeScreen();
                                myCharacter.Refuel(true);
                                break;

                            case 5:
                                Console.Clear();
                                Menus.WelcomeScreen();
                                myCharacter.newShip(true);
                                break;

                            case 6:
                                Console.Clear();
                                Init i = new Init();
                                i.Run();
                                break;
                            }
                            commandNotExecuted = false;
                        }
                        else
                        {
                            Console.Clear();
                            throw new Exception("\nInvalid Entry");
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                } while (commandNotExecuted);
                Console.WriteLine("\nCommand successfully executed. Press Enter to Continue.");
                Console.ReadLine();
                Console.Clear();
            } while (keepLooping);
        }