Beispiel #1
0
        /// <summary>
        /// Start the game by creating a Game, and opening the Menu.
        /// </summary>
        static void Main()
        {
            // Create a new ConsoleGame.
            ConsoleGame game = new ConsoleGame();

            // Open the menu.
            game.Menu();
        }
Beispiel #2
0
        /// <summary>
        /// Run our entire Menu.
        /// </summary>
        /// <param name="game">Game to play.</param>
        public void RenderConsoleMenu(ConsoleGame game)
        {
            menus.Add("mainMenu", "1 - Start Game\n2 - Instructions\nb - Exit");
            menus.Add("instructions", "*** How does the game work? ***\n" +
                      "\nFelliGame is a PvP tabletop game." +
                      "\nWhere each player have 6 pieces." +
                      "\n6 white pieces are placed on one side of the map, where " +
                      "6 black pieces are placed on the opposite side of the map." +
                      "\nThe players play in turns." +
                      "\nThe players can move the pieces (always following the " +
                      "path line) in any direction where exists a free adjacent spot." +
                      "\nYou can take out enemy pieces by jumping above them, and " +
                      "you'll land on the free spot adjacent to the previous enemy" +
                      " spot. (Just like in Checkers.)" +
                      "\n\n*** Win conditions ***\n" +
                      "\nThe player who takes all the opponent pieces first wins!" +
                      "\nIf the current player blocks all the opponent's pieces," +
                      " the current player wins!" +
                      "\nb - Back");

            currentMenu = "mainMenu";
            while (true)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("FelliGame");
                Console.ResetColor();

                Console.WriteLine(menus[currentMenu]);
                switch (Console.ReadLine())
                {
                // This option will start the game.
                case "1":
                    Console.WriteLine("\n*** Game is starting! ***\n");
                    game.Play();
                    Console.WriteLine("\n*** Game is over! ***\n");
                    break;

                // Open the instructions menu.
                case "2":
                    if (currentMenu == "mainMenu")
                    {
                        historic.Add(currentMenu);
                        currentMenu = "instructions";
                    }
                    break;

                // Exit the game, if we're at the top level of our menu.
                case "b":
                    if (currentMenu == "mainMenu")
                    {
                        Environment.Exit(1);
                    }
                    currentMenu = historic[historic.Count - 1];
                    historic.RemoveAt(historic.Count - 1);
                    break;

                // Always ask for a valid option while in the menu.
                default:
                    Console.WriteLine("Insert a valid input!");
                    break;
                }
            }
        }