Ejemplo n.º 1
0
        /// <summary>
        /// Sprawdza czy wybrano tę akcję
        /// </summary>
        /// <param name="state">Aktualny stan klawiszy</param>
        /// <returns>Zwraca true, jeżeli wywołano tę akcję</returns>
        public bool IsCalled(InputState state)
        {
            KeyPress keyTest;
            if (NewPressOnly)
            {
                keyTest = state.IsNewKey;
            }
            else
            {
                keyTest = state.IsKeyDown;
            }

            return Keys.Any(key => keyTest(key));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reaguje na wciskane klawisze. 
        /// Jeœli ekran jest aktywny, wtedy przekazuje kontrolê do aktywnego poziomu.
        /// </summary>
        /// <param name="gameTime">Czas gry</param>
        /// <param name="input">Stan klawwiszy</param>
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            KeyboardState keyboardState = input.CurrentKeyboardState;

            if (_pauseAction.IsCalled(input))
            {
                Pause();
            }
            else
            {
                if (CurrentLevel != null)
                    CurrentLevel.Player.HandleInput(gameTime, input);
            }
        }
Ejemplo n.º 3
0
        public void HandleInput(GameTime gameTime, InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            //kody
            if (SettingsManager.Instance.Debug)
            {
                if (input.IsKeyDown(Keys.NumPad7)) Oxygen = Oxygen - 1 >= 0 ? Oxygen - 1 : Oxygen;
                if (input.IsKeyDown(Keys.NumPad9)) Oxygen = Oxygen + 1 <= SettingsManager.Instance.MaxOxygen ? Oxygen + 1 : Oxygen;

                if (input.IsKeyDown(Keys.NumPad4)) Points--;
                if (input.IsKeyDown(Keys.NumPad6)) Points++;

                if (input.IsKeyDown(Keys.NumPad1))
                {
                    WorldCollisionComponent.Active = false;
                    PhysicsComponent.HasGravity = false;
                }
                if (input.IsKeyDown(Keys.NumPad3))
                {
                    WorldCollisionComponent.Active = false;
                    PhysicsComponent.HasGravity = false;
                }
            }
            if (SettingsManager.Instance.Controls[EAction.MoveRight].IsCalled(input))
            {
                Velocity = new Vector2(_sideMoveSpeed, Velocity.Y);
                if (IsOnGround && AnimationComponent.CurrentAnimationName != "Run")
                    AnimationComponent.SetActiveAnimation("Run");
                //if (IsClimbing)
                //	EndClimb();
            }
            if (SettingsManager.Instance.Controls[EAction.MoveLeft].IsCalled(input))
            {
                Velocity = new Vector2(-_sideMoveSpeed, Velocity.Y);
                if (IsOnGround && AnimationComponent.CurrentAnimationName != "Run")
                    AnimationComponent.SetActiveAnimation("Run");
                //if (IsClimbing)
                //	EndClimb();
            }
            if (SettingsManager.Instance.Controls[EAction.Jump].IsCalled(input) && IsOnGround)
            {
                Jump();
            }
            else if (SettingsManager.Instance.Controls[EAction.Jump].IsCalled(input) && IsCollidingWithLadder)
            {
                Climb(-1);
            }

            if (SettingsManager.Instance.Controls[EAction.MoveDown].IsCalled(input) && IsCollidingWithLadder)
            {
                Climb(1);
            }

            if (SettingsManager.Instance.Controls[EAction.SetDynamite].IsCalled(input))
            {
                SetDynamite();
            }

            if (IsOnGround && Velocity.X == 0.0)
                AnimationComponent.SetActiveAnimation("Idle");
        }