示例#1
0
        private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e)
        {
            RLKeyPress         keyPress = _rootConsole.Keyboard.GetKeyPress();
            Stack <IGameState> s        = new Stack <IGameState>();
            IGameState         state    = null;

            do
            {
                state = GameStack.Peek();

                if (state.OnUpdate(keyPress))
                {
                    s.Push(GameStack.Pop());
                }
            }while (!state.Pauses && GameStack.Count > 0);

            while (s.Count > 0)
            {
                GameStack.Push(s.Pop());
            }
        }
示例#2
0
        private static void OnRootConsoleRender(object sender, UpdateEventArgs e)
        {
            Stack <IGameState> s     = new Stack <IGameState>();
            IGameState         state = null;

            do
            {
                state = GameStack.Peek();
                state.OnRender();
                if (state.Transparent)
                {
                    s.Push(GameStack.Pop());
                }
            }while (!state.Pauses && GameStack.Count > 0);

            while (s.Count > 0)
            {
                GameStack.Push(s.Pop());
            }

            _rootConsole.Draw();
        }
示例#3
0
        static void Main(string[] args)
        {
            GameStack gameStack = new GameStack();
            GameQueue gameQueue = new GameQueue();

            #region Part 1
            //add spells to the stack and then pop them
            #region stack section

            //add the spells to the stack
            #region spells
            Console.WriteLine("Adding spells to the stack:");

            gameStack.Push("Lightning Bolt");
            Console.WriteLine(gameStack.Peek());

            gameStack.Push("Snapcaster Mage");
            Console.WriteLine(gameStack.Peek());

            gameStack.Push("CounterSpell");
            Console.WriteLine(gameStack.Peek());

            gameStack.Push("TwinBolt");
            Console.WriteLine(gameStack.Peek());

            gameStack.Push("Daze");
            Console.WriteLine(gameStack.Peek());
            #endregion

            Console.WriteLine();
            Console.WriteLine("Spells resolving in reverse order:");
            //while loop to pop each item in the list while it has items in it
            while (gameStack.IsEmpty == false)
            {
                Console.WriteLine(gameStack.Pop());
            }
            #endregion

            //spacing lines
            Console.WriteLine();
            Console.WriteLine();

            //add people to a queue and then dequeue them
            #region queue section

            //adding people to a queue
            #region people
            Console.WriteLine("People being queued a server");
            gameQueue.Enqueue("Nick");
            gameQueue.Enqueue("Briana");
            gameQueue.Enqueue("Drake");
            gameQueue.Enqueue("Nico");
            gameQueue.Enqueue("Some other nerd");

            //displays each of the people in the queue
            for (int i = 0; i < gameQueue.Count - 1; i++)
            {
                Console.WriteLine(gameQueue.Queue[i]);
            }
            #endregion

            //while the queue has people in it, dequeue until the list is empty
            Console.WriteLine();
            Console.WriteLine("Adding the queued people to the server:");
            while (gameQueue.IsEmpty == false)
            {
                Console.WriteLine(gameQueue.Dequeue() + " Has joined the server: " + (gameQueue.Count - 1) + " player(s) left in the queue");
            }
            #endregion
            #endregion

            //spacing for part 2
            Console.WriteLine("\n\n\n\n");

            #region Part 2
            //part 2 stacks

            //store the current page as a string, defaults to Google on startup
            while (true)
            {
                Console.WriteLine();
                Console.WriteLine("Here are your possible controls:");
                Console.WriteLine("1. visit a new webpage");
                Console.WriteLine("2. move forward to the next page");
                Console.WriteLine("3. navigate back to the previous page");
                Console.WriteLine("4. print the current page, as well as the backward stack and forward stack");
                Console.WriteLine("5. quit the loop");

                string answer    = Console.ReadLine();
                int    answerInt = 0;
                int.TryParse(answer, out answerInt);

                switch (answerInt)
                {
                case 1:
                    currentPage = VisitPage(currentPage);
                    break;

                case 2:
                    currentPage = NextPage(currentPage);
                    break;

                case 3:
                    currentPage = PreviousPage(currentPage);
                    break;

                case 4:
                    PrintEverything(currentPage);
                    break;

                case 5:
                    return;

                default:
                    Console.WriteLine("Invalid Entry, please try again");
                    Console.WriteLine("--------------------");
                    Console.WriteLine();
                    break;
                }
            }

            #endregion
        }
示例#4
0
        private void TransToMainMenu()
        {
            Thread.Sleep(3000);

            GameStack.Push(GameStack.MakeItem <MainMenuStackItem>());
        }