Пример #1
0
    bool FacingAndTouchingWall()
    {
        if (_anim.Facing == 0)
        {
            return(false);
        }
        //if not pushing into wall via input or velocity, dont walljump
        if (!(PMath.GetSign(VirtualController.GetAxisHorizontal()) == _anim.Facing) &&
            !(PMath.GetSign(_rigidbody.velocity.x) == _anim.Facing))
        {
            return(false);
        }

        Vector3    dir = new Vector3(_anim.Facing, 0);
        RaycastHit r;
        Vector3    origin = transform.position;
        float      spd    = 0.55f;
        int        gMask  = Layers.GetGroundMask(true);

        if (Physics.Raycast(origin + new Vector3(0, 0.8f, 0), dir, out r, spd, gMask) ||
            Physics.Raycast(origin + new Vector3(0, 0.5f, 0), dir, out r, spd, gMask) ||
            Physics.Raycast(origin + new Vector3(0, 0.2f, 0), dir, out r, spd, gMask) ||
            Physics.Raycast(origin + new Vector3(0, -0.15f, 0), dir, out r, spd, gMask) ||
            Physics.Raycast(origin + new Vector3(0, -0.45f, 0), dir, out r, spd, gMask))
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Пример #2
0
    void BasicMovement()
    {
        Vector3 moveInputs = Vector3.zero;

        moveInputs.x = VirtualController.GetAxisHorizontal();
        moveInputs.z = VirtualController.GetAxisVertical();
        _anim.SetMoving(moveInputs.x != 0);
        _anim.SetFacing(moveInputs.x);
        if (UnlockTable.PowerActive(UnlockID.Crouch))
        {
            _anim.SetCrouchInput(moveInputs.z < 0);
        }

        if (moveInputs.x != 0 && _rigidbody.velocity.x != 0)
        {
            _rigidbody.velocity = new Vector3(0, _rigidbody.velocity.y);
        }

        Vector3 movement = CheckMovement(moveInputs);

        Vector3 movepos = transform.position;

        movepos.x += movement.x;
        //movepos.z += movement.z;

        transform.position = movepos;
    }
Пример #3
0
 // Update is called once per frame
 void Update()
 {
     if (dashPauseTimer > 0)
     {
         dashPauseTimer     -= Time.deltaTime;
         _rigidbody.velocity = Vector3.zero;
         if (dashPauseTimer <= 0)
         {
             dashPauseTimer = 0;
             _anim.StopDashSlashAnim();
         }
         return;
     }
     if (wallJumpLockTimer > 0)
     {
         wallJumpLockTimer -= Time.deltaTime;
         if (wallJumpLockTimer <= 0)
         {
             wallJumpLockTimer = 0;
             Vector3 v = _rigidbody.velocity;
             v.x *= 0.65f;
             v.y *= 0.75f;
             _rigidbody.velocity = v;
         }
         return;
     }
     isGrounded = Grounded();
     _anim.SetGrounded(isGrounded);
     if (controlsLocked || hitstun)
     {
         return;
     }
     BasicMovement();
     if (VirtualController.JumpButtonPressed())
     {
         if (UnlockTable.PowerActive(UnlockID.Jump))
         {
             Jump();
         }
     }
     else if (!_anim.IsCrouching && VirtualController.ActionButtonPressed())
     {
         if (VirtualController.GetAxisHorizontal() != 0 && UnlockTable.PowerActive(UnlockID.DashSlash))
         {
             DashSlash(PMath.GetSign(VirtualController.GetAxisHorizontal()));
         }
         else if (UnlockTable.PowerActive(UnlockID.Slash))
         {
             Slash();
         }
     }
     if (isGrounded)
     {
         numAirJumps = maxAirJumps;
     }
     UpdateCoords();
 }