Ejemplo n.º 1
0
        public override void HandleInput(InputHelper nInput, GameTime nGameTime)
        {
            int hoverIndex = GetMenuEntryAt(nInput.Cursor);
            if (hoverIndex > -1 && mMenuEntries[hoverIndex].IsSelectable())
            {
                if (mSelectedEntry != hoverIndex)
                {
                    Sfx.Play("menunav");
                    mSelectedEntry = hoverIndex;
                }
            }
            else
            {
                mSelectedEntry = -1;
            }

            if (nInput.IsMenuSelect() && mSelectedEntry != -1)
            {
                Sfx.Play("menuclick");
                mMenuEntries[mSelectedEntry].MenuEntrySelected();
            }
            else if (nInput.IsMenuCancel())
            {
                ScreenManager.Game.Exit();
            }
        }
Ejemplo n.º 2
0
        public void HandleInput(InputHelper nInput)
        {
            KeyboardState nKeyboardState = nInput.KeyboardState;
            KeyboardState nPreviousKeyboardState = nInput.PreviousKeyboardState;

            if(!InState(SpriteState.Crouching))
            {
                if(isColliding && !InState(SpriteState.Jumping) && !InState(SpriteState.Falling))
                {
                    if (nKeyboardState.IsKeyDown(Keys.A))
                    {//Start walking left
                        SetAnimOrientationLeft();
                        SetState(SpriteState.Walking);
                    }

                    if (nKeyboardState.IsKeyDown(Keys.D))
                    {//Start walking right
                        SetAnimOrientationRight();
                        SetState(SpriteState.Walking);
                    }

                    if (nKeyboardState.IsKeyDown(Keys.S))
                    {//Start Crouching
                        SetState(SpriteState.Crouching);
                    }
                    else if (nKeyboardState.IsKeyDown(Keys.Space))
                    {//Start Jumping
                        mJumpStep = 0;
                        SetState(SpriteState.Jumping);
                    }
                    else if(XisUnit())
                    {
                        SetState(SpriteState.Standing);
                    }
                }

                if(InState(SpriteState.Jumping) || InState(SpriteState.Falling))
                {
                    if(InState(SpriteState.Jumping))
                    {
                        if (!nKeyboardState.IsKeyDown(Keys.Space))
                        {//Stop jumping if jump key isn't held
                            mJumpStep = 0;
                            SetState(SpriteState.Falling);
                        }
                        else if (mJumpStep < 20)
                        {//While jumping, apply an upward impulse each step
                            if (mJumpStep < 2)
                            {//For the first two steps, apply a larger, initial impulse
                                Body.ApplyLinearImpulse(new Vector2(0.0f, -23f), new Vector2(0.0f, 0.0f));
                            }
                            else //mJumpStep >= 2
                            {//After the first two steps, apply a smaller, sustaining impulse
                                Body.ApplyLinearImpulse(new Vector2(0.0f, -2.5f), new Vector2(0.0f, 0.0f));
                            }
                            mJumpStep++;
                        }
                        else //mJumpStep >= 20
                        {//Top of the jump
                            if (Body.LinearVelocity.Y > 2)
                            {//Set state to falling when we gain some downward velocity
                                mJumpStep = 0;
                                SetState(SpriteState.Falling);
                            }
                        }
                    }
                    else //InState(SpriteState.Falling)
                    {
                        if (YisUnit() && fallTimeout <= 0)
                        {
                            if (XisUnit())
                            {
                                SetState(SpriteState.Standing);
                            }
                            else //!XisUnit()
                            {
                                SetState(SpriteState.Walking);
                            }
                            Body.LinearVelocity = new Vector2(Body.LinearVelocity.X, 0.0f);
                        }
                        else
                        {
                            fallTimeout--;
                        }
                    }
                }

                if (nKeyboardState.IsKeyDown(Keys.A))
                {
                    SetAnimOrientationLeft();
                    if (!MaxSpeedLeft())
                    {
                        Body.ApplyLinearImpulse(CONST_SPEED * CUR_SPEED_SCALAR * VECTOR_LEFT, new Vector2(0, 0));
                    }
                }
                else if (nKeyboardState.IsKeyDown(Keys.D))
                {
                    SetAnimOrientationRight();
                    if (!MaxSpeedRight())
                    {
                        Body.ApplyLinearImpulse(CONST_SPEED * CUR_SPEED_SCALAR * VECTOR_RIGHT, new Vector2(0, 0));
                    }
                }
            }
            else //InState(SpriteState.Crouching)
            {
                if (!nKeyboardState.IsKeyDown(Keys.S))
                {//Stop Crouching
                    SetState(SpriteState.Walking);
                }
            }

            //ServerConnection.SendPosUpdate("4f1c15a75595e1014c20e904", Body.Position);

            //Update the camera body's position
            Vector2 tempPos = Body.Position;
            CamBody.SetTransformIgnoreContacts(ref tempPos, Body.Rotation);
        }
Ejemplo n.º 3
0
 public void HandleTransitions(InputHelper input, GameTime gameTime)
 {
     if (input.IsNewKeyPress(Keys.Back) || input.IsNewKeyPress(Keys.Left))
     {
         Sfx.Play("menuslideout");
         LoadingScreen.Load(ScreenManager, false, mPreviousScreens);
     }
 }
Ejemplo n.º 4
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(InputHelper input, GameTime gameTime)
 {
 }
Ejemplo n.º 5
0
 public override void HandleInput(InputHelper input, GameTime gameTime)
 {
     base.HandleTransitions(input, gameTime);
     base.HandleInput(input, gameTime);
 }
Ejemplo n.º 6
0
 public override void HandleInput(InputHelper nInput, GameTime nGameTime)
 {
     base.HandleTransitions(nInput, nGameTime);
 }