Ejemplo n.º 1
0
        public override void update(Player player)
        {
            if (player.collideBottom)
            {
                if (stateActions.Contains(STATE_ACTIONS.THROW))
                {
                    State_Throwing to = new State_Throwing();
                    to.decorate(decoration);
                    switchState(player, to);
                }
                else if (stateActions.Contains(STATE_ACTIONS.SWING))
                {
                    State_Swinging to = new State_Swinging();
                    to.decorate(decoration);
                    switchState(player, to);
                }
                else if (stateActions.Contains(STATE_ACTIONS.JUMP))
                {
                    switchState(player, new State_Jumping());
                }
                else if (stateActions.Contains(STATE_ACTIONS.RUN))
                {
                    switchState(player, new State_Running());
                }
            }
            else
            {
                switchState(player, new State_Jumping());
            }


            stateActions.Clear();
        }
Ejemplo n.º 2
0
        public override void update(Player player)
        {
            if (player.collideBottom)
            {
                if (stateActions.Contains(STATE_ACTIONS.THROW))
                {
                    State_Throwing to = new State_Throwing();
                    to.decorate(decoration);
                    switchState(player, to);
                }
                else if (stateActions.Contains(STATE_ACTIONS.SWING))
                {
                    State_Swinging to = new State_Swinging();
                    to.decorate(decoration);
                    switchState(player, to);
                }
                if (stateActions.Contains(STATE_ACTIONS.JUMP))
                {
                    switchState(player, new State_Jumping());
                }
                else if (!stateActions.Contains(STATE_ACTIONS.RUN))
                {
                    switchState(player, new State_Standing());
                }
                else
                {
                    frameSwitcher--;
                    if (frameSwitcher <= 0)
                    {
                        currentRunFrame = (currentRunFrame + 1) % player.texture_run.Length;
                        frameSwitcher   = frameSwitchPoint;
                    }
                }
            }
            else
            {
                switchState(player, new State_Jumping());
            }

            stateActions.Clear();
        }
        public override void update(Player player)
        {
            if (player.collideBottom)
            {
                switchState(player, new State_Running());
            }
            else
            {
                if (stateActions.Contains(STATE_ACTIONS.THROW))
                {
                    State_Throwing to = new State_Throwing();
                    to.decorate(decoration);
                    switchState(player, to);
                }
                else if (stateActions.Contains(STATE_ACTIONS.SWING))
                {
                    State_Swinging to = new State_Swinging();
                    to.decorate(decoration);
                    switchState(player, to);
                }
                else if (player.velocity.Y > 0)
                {
                    frameSwitcherJump--;
                    if (frameSwitcherJump <= 0)
                    {
                        currentJumpFrame  = Math.Min(currentJumpFrame + 1, player.texture_jump.Length - 1);
                        frameSwitcherJump = frameSwitchPoint;
                    }
                }
                else
                {
                    currentJumpFrame = 0;
                }
            }


            stateActions.Clear();
        }