Beispiel #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            IIterator iterator = collection.Iterator();

            while (iterator.HasNext())
            {
                var guiElement = iterator.Next();
                guiElement.Accept(_drawVisitor);
            }

            base.Draw(gameTime);
        }
Beispiel #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // TODO: Add your update logic here
            switch (CurrentScreen)
            {
            case ScreenManager.MainWindow:
                collection = mainScreenElements;
                break;

            case ScreenManager.InputWindow:
                collection = inputScreenElements;
                break;

            case ScreenManager.LabelWindow:
                collection = labelScreenElements;
                break;

            case ScreenManager.Exit:
                Exit();
                break;
            }

            IIterator iterator = collection.Iterator();

            while (iterator.HasNext())
            {
                var guiElement = iterator.Next();
                guiElement.Accept(_updateVisitor);
            }

            base.Update(gameTime);
        }