Exemple #1
0
        /// <summary>
        /// Allows the screen to run updating logic on GUI element like making property changes,
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void UpdateGUI(GameTime gameTime)
        {
            base.UpdateGUI(gameTime);

            var pressedKeys = KeyboardController.GetState().GetPressedKeys();

            foreach (var element in this.GUIElements)
            {
                element.Update(gameTime);
                var textbox = element as TextBox;
                if (pressedKeys.Length > 0 && pressedKeys[0] != Keys.Escape)
                {
                    if (textbox != null && textbox.IsActive)
                    {
                        var index = this.keyBindings.Keys.ToList().FindIndex(k => this.keyBindings[k] == textbox);
                        if (index != -1)
                        {
                            var key   = this.keyBindings.ElementAt(index).Key;
                            var value = pressedKeys[0].ToString();
                            if (KeyboardController.TrySetKey(key, (Keys)Enum.Parse(typeof(Keys), value)))
                            {
                                textbox.Text = value;
                                this.keyBindings[key].Text = value;
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Allows the screen to run updating logic like checking user inputs,
        /// changing item properties or playing music
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            var state = KeyboardController.GetState();

            if (state.IsKeyDown(Keys.Escape, true))
            {
                this.PopScreen();
            }
        }
Exemple #3
0
        /// <summary>
        /// Allows the screen to run updating logic like checking user inputs,
        /// changing item properties or playing music
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            if (gameTime != null)
            {
                var state = KeyboardController.GetState();
                if (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape, true))
                {
                    this.PopScreen();
                }

                base.Update(gameTime);
            }
        }
Exemple #4
0
        /// <summary>
        /// Allows the screen to run updating logic like checking user inputs,
        /// changing item properties or playing music
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            if (gameTime != null)
            {
                var ks = KeyboardController.GetState();

                if (ks.IsKeyDown(Keys.Escape, true))
                {
                    this.PopScreen();
                }

                base.Update(gameTime);
            }
        }
        /// <summary>
        /// Allows the screen to run updating logic like checking user inputs,
        /// changing item properties or playing music
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            if (gameTime != null)
            {
                var state = KeyboardController.GetState();

                // Control debug view
                if (this.debugView != null && state.IsKeyDown(Keys.F1, true))
                {
                    if ((this.debugView.Flags & DebugViewFlags.Shape) == DebugViewFlags.Shape)
                    {
                        this.debugView.RemoveFlags(DebugViewFlags.Shape);
                    }
                    else
                    {
                        this.debugView.AppendFlags(DebugViewFlags.Shape);
                    }

                    this.showDebugView = !this.showDebugView;
                }

                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || state.IsKeyDown(Keys.Escape, true))
                {
                    this.PopScreen();
                }

                if (state.IsKeyDown(Keys.P))
                {
                    ScreenManager.AddScreen(Enums.SystemScreen.PauseScreen);
                }

                this.World.Step((float)gameTime.ElapsedGameTime.TotalMilliseconds * 0.001f);

                this.map.Update(gameTime);
                this.Camera.Rotation = this.ScreenRotation;
                this.Camera.CenterOnFollowing();
            }

            base.Update(gameTime);
        }