Exemplo n.º 1
0
        /// <summary>
        /// Evaluates the action against a given InputState.
        /// </summary>
        /// <param name="state">The InputState to test for the action.</param>
        /// <param name="controllingPlayer">The player to test, or null to allow any player.</param>
        /// <param name="player">If controllingPlayer is null, this is the player that performed the action.</param>
        /// <returns>True if the action occurred, false otherwise.</returns>
        public bool Evaluate(InputState state)
        {
            // Figure out which delegate methods to map from the state which takes care of our "newPressOnly" logic
            KeyPress keyTest = newPressOnly ? (KeyPress)state.IsNewKeyPress : state.IsKeyPressed;

            // Now we simply need to invoke the appropriate methods for each button and key in our collections
            foreach (Keys key in this.keys)
            {
                if (keyTest(key))
                    return true;
            }

            // If we got here, the action is not matched
            return false;
        }
Exemplo n.º 2
0
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            base.HandleInput(gameTime, input);

            if (input.IsLeftMouseClick)
            {
                foreach (var lButton in this.Buttons.Where(x => x.IsAvailable))
                {
                    if (GraphicsUtilities.RectangleContains(
                        lButton.Position, lButton.Size,
                        input.CurrentMouseState.X, input.CurrentMouseState.Y))
                    {
                        lButton.OnSelected();
                    }
                }

                if (this.ShopButton.Bounds.Contains(input.CurrentMouseState.X, input.CurrentMouseState.Y))
                {
                    LoadingScreen.Load(this.ScreenManager, true, new ShopScreen());
                }

                if (this.BackButton.Bounds.Contains(input.CurrentMouseState.X, input.CurrentMouseState.Y))
                {
                    LoadingScreen.Load(this.ScreenManager, false, new MainMenuScreen());
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a new mouse movement behavior with the given input state.
 /// </summary>
 /// <param name="inputState">The input state will be used to capture the mouse movement.</param>
 public MouseMovementBehavior(InputState inputState)
 {
     this.InputState = inputState;
 }
Exemplo n.º 4
0
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            base.HandleInput(gameTime, input);

            if (input.IsLeftMouseClick &&
                GraphicsUtilities.RectangleContains(this.BackButtonPosition, this.BackButtonSize, input.CurrentMouseState.X, input.CurrentMouseState.Y))
            {
                LoadingScreen.Load(this.ScreenManager, true, new LevelSelectionScreen());
            }

            this.ActiveButton = this.ShopButtons.FirstOrDefault(x => x.HitTest(input.CurrentMouseState.X, input.CurrentMouseState.Y));

            if (input.IsLeftMouseClick
                && (this.ActiveButton != null)
                && (this.ActiveButton.Price >= 0)
                && (this.PlayerManager.Player.AvailableHoneycombToSpend >= this.ActiveButton.Price))
            {
                this.PlayerUpgradeSetters[this.ActiveButton.ID](this.ActiveButton.Level);
                this.PlayerManager.Player.AvailableHoneycombToSpend -= this.ActiveButton.Price;
                this.UpdateButton(this.ActiveButton);
            }
        }
Exemplo n.º 5
0
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            base.HandleInput(gameTime, input);

            foreach (var lButton in this.mButtons)
            {
                lButton.IsActive = lButton.Bounds.Contains(input.CurrentMouseState.X, input.CurrentMouseState.Y);

                if (lButton.IsActive && input.IsLeftMouseClick)
                {
                    lButton.OnSelectEntry();
                }
            }
        }
Exemplo n.º 6
0
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            base.HandleInput(gameTime, input);

            if (input.CurrentMouseState.LeftButton == ButtonState.Pressed)
            {
                this.BeeManager.Bee.ShootingBehavior.FireWhenReady(this.BeeManager.Bee, gameTime);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Allows the screen to handle user input. Unlike Update, this method
 /// is only called when the screen is active, and not when some other
 /// screen has taken the focus.
 /// </summary>
 public virtual void HandleInput(GameTime gameTime, InputState input)
 {
 }