Exemple #1
0
    public void OnUpdateState(PlayerInputs input)
    {
        if (input.verticalInput < model.InputThreshold && !model.JumpingEnabled)
        {
            model.EnableJumping();
        }

        if (input.horizontalInput > model.InputThreshold && manager.WallHugDirection > 0f)
        {
            manager.ChangeState(MovementState.FALL_FORGIVENESS);
            model.ApplyHorizontalForce(1);
        }
        else if (input.horizontalInput < -model.InputThreshold && manager.WallHugDirection < 0f)
        {
            manager.ChangeState(MovementState.FALL_FORGIVENESS);
            model.ApplyHorizontalForce(-1);
        }
        else if (Mathf.Abs(input.horizontalInput) > model.InputThreshold)
        {
            model.WallHangFactor = 0.25f;
        }
        else
        {
            model.WallHangFactor = 1f;
        }

        if (input.verticalInput > model.InputThreshold && model.JumpingEnabled)
        {
            model.WallJump();
            manager.ChangeState(MovementState.WALL_LAUNCH);
        }
    }
Exemple #2
0
    public void OnUpdateState(PlayerInputs input)
    {
        jumpDeltaTime += Time.fixedDeltaTime;

        if (jumpDeltaTime > model.JumpLeniency || Mathf.Abs(input.verticalInput) <= model.InputThreshold || model.ParabolicJump)
        {
            if (transitionToHugging)
            {
                manager.ChangeState(MovementState.HUGGING_WALL);
                transitionToHugging = false;
            }
            else
            {
                manager.ChangeState(MovementState.FALLING);
            }
        }

        if (input.horizontalInput > model.InputThreshold)
        {
            model.ApplyHorizontalForce(1);
        }
        else if (input.horizontalInput < -model.InputThreshold)
        {
            model.ApplyHorizontalForce(-1);
        }
    }
Exemple #3
0
    public void OnUpdateState(PlayerInputs input)
    {
        if (input.verticalInput < model.InputThreshold && !model.JumpingEnabled)
        {
            model.EnableJumping();
        }

        //catch for no collisions, just in case
        if (manager.CurrentCollisions.Count == 0)
        {
            manager.ChangeState(MovementState.FALL_FORGIVENESS);
        }

        if (input.horizontalInput > model.InputThreshold || input.horizontalInput < -model.InputThreshold)
        {
            manager.ChangeStateImmediate(MovementState.ACCELERATING);
        }
        else
        {
            model.StopHorizontalMovement();
        }

        if (input.verticalInput > model.InputThreshold && model.JumpingEnabled)
        {
            manager.ChangeState(MovementState.JUMPING);
        }
    }
Exemple #4
0
    public void OnUpdateState(PlayerInputs input)
    {
        if (input.verticalInput < model.InputThreshold && !model.JumpingEnabled)
        {
            model.EnableJumping();
        }

        if (input.horizontalInput > model.InputThreshold)
        {
            model.MoveHorizontally(1);
        }
        else if (input.horizontalInput < -model.InputThreshold)
        {
            model.MoveHorizontally(-1);
        }
        else
        {
            model.StopHorizontalMovement();
            manager.ChangeState(MovementState.STOPPED);
        }

        if (input.verticalInput > model.InputThreshold && model.JumpingEnabled)
        {
            manager.ChangeState(MovementState.JUMPING);
        }
    }
Exemple #5
0
    public void OnUpdateState(PlayerInputs input)
    {
        if (input.verticalInput < model.InputThreshold && !model.JumpingEnabled)
        {
            model.EnableJumping();
        }

        if (input.horizontalInput > model.InputThreshold)
        {
            model.ApplyHorizontalForce(1);
        }
        else if (input.horizontalInput < -model.InputThreshold)
        {
            model.ApplyHorizontalForce(-1);
        }
        else
        {
            manager.ChangeState(MovementState.STOPPED);
        }

        if (input.verticalInput > model.InputThreshold && model.JumpingEnabled)
        {
            manager.ChangeState(MovementState.JUMPING);
            return;
        }

        if (Mathf.Abs(model.MyRigidbody.velocity.x) >= model.HorizontalTerminalVelocity)
        {
            manager.ChangeState(MovementState.MOVING);
            return;
        }
    }
Exemple #6
0
    public void OnUpdateState(PlayerInputs input)
    {
        if (input.horizontalInput > model.InputThreshold)
        {
            model.ApplyHorizontalForce(1);
        }
        else if (input.horizontalInput < -model.InputThreshold)
        {
            model.ApplyHorizontalForce(-1);
        }

        if (input.verticalInput > model.InputThreshold && model.JumpingEnabled)
        {
            manager.ChangeState(MovementState.JUMPING);
        }
    }
Exemple #7
0
 void Update()
 {
     if (Input.GetKey("space"))
     {
         movementManager.resetCharacter();
         movementManager.ChangeState(MovementState.STOPPED);
     }
 }
Exemple #8
0
 /// <summary>
 /// Assumptions: First only wall collisions, then no collisions.
 /// </summary>
 /// <param name="collision"></param>
 /// <param name="isEntering"></param>
 public void CollisionChange(Collision2D collision, CollisionState collisionState)
 {
     if (collisionState == CollisionState.ENTERING)
     {
         if (collision.contacts[0].normal.y > 0.4f)
         {
             manager.ChangeState(MovementState.STOPPED);
         }
         else if (collision.contacts[0].normal.y < -0.4f)
         {
             manager.ChangeState(MovementState.FALLING);
         }
         else if (Mathf.Abs(collision.contacts[0].normal.x) > 0.4f)
         {
             manager.ChangeState(MovementState.HUGGING_WALL);
         }
     }
 }
    public void OnUpdateState(PlayerInputs input)
    {
        fallDeltaTime += Time.fixedDeltaTime;

        if (fallDeltaTime > model.FallLeniency)
        {
            manager.ChangeState(MovementState.FALLING);
        }
        else if (input.verticalInput > model.InputThreshold && model.JumpingEnabled)
        {
            manager.ChangeState(MovementState.JUMPING);
        }

        if (input.horizontalInput > model.InputThreshold)
        {
            model.ApplyHorizontalForce(1);
        }
        else if (input.horizontalInput < -model.InputThreshold)
        {
            model.ApplyHorizontalForce(-1);
        }
    }