示例#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
 // 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();
 }
示例#3
0
    public void SetFacing(float f)
    {
        int fSign = PMath.GetSign(f);

        if (fSign != 0)
        {
            facing = fSign;
        }
        if (facing < 0)
        {
            _spriteRenderer.flipX = true;
        }
        if (facing > 0)
        {
            _spriteRenderer.flipX = false;
        }
    }