示例#1
0
 override public void Jump( )
 {
     //如果角色在Dash的途中仍然沒有放開Jump Button 將其判定改為沒有按住
     if (props.bJumpPressed && player.IsDashing)
     {
         props.bJumpPressed = false;
     }
     if (props.bCanJump && props.bJumpPressed && !player.IsDashing)
     {
         Vector2 vel = player.Rb.velocity;
         //Wall Jump
         if (props.bWallSliding && !rayCastController.Down)
         {
             EHitDirection wallDirection = rayCastController.Left?EHitDirection.LEFT : EHitDirection.RIGHT;
             // from left wall to right wall
             if (wallDirection == EHitDirection.LEFT)
             {
                 vel.x = attr.WallJumpVel;
             }
             else
             {
                 vel.x = -attr.WallJumpVel;
             }
         }
         vel.y = attr.JumpVel;
         player.Rb.velocity = vel;
         props.bCanJump     = false;
         props.bJumpPressed = false;
         player.Anim.SetTrigger("jump");
         player.FX.PlayVFX(player.VFXAction[EVFXAction.JUMP], props.bFaceRight);
         player.FX.PlaySFX(ESFXType.JUMP);
     }
     #region WALL_SLIDE_DOWN_VEL
     if (props.bWallSliding)
     {
         Vector2 vel   = player.Rb.velocity;
         float   input = props.inputValue.y > 0f?0f : props.inputValue.y;
         vel.y += input * attr.WallSlideVel;
         player.Rb.velocity = vel;
     }
     #endregion
     #region CHANGE_GRAVITY_SCALE
     if (player.Rb.velocity.y <= 0f && !props.bWallSliding)
     {
         player.Rb.gravityScale = props.originGravity * attr.FallGravityMultiplier;
     }
     else if (props.bWallSliding && player.Rb.velocity.y <= 0f)
     {
         player.Rb.gravityScale = props.originGravity * attr.WallSlidingGravityMultiplier;
     }
     else
     {
         player.Rb.gravityScale = props.originGravity;
     }
     #endregion
 }
示例#2
0
 public HitResult(RaycastHit2D hit2D, EHitDirection direction, Vector2 detailPos)
 {
     this.hit2D     = hit2D;
     this.direction = direction;
     this.detailPos = detailPos;
 }