private void StopClimbing() { m_bClimbing = false; m_rLadder = null; movementController.EnableMovement(); float fVertical = characterInput.Vertical; float fHorizontal = characterInput.Horizontal; if (characterInput.Jump) { if (!(fVertical < 0.0f && Mathf.Abs(fVertical) >= Mathf.Abs(fHorizontal))) { movementController.Jump(); } m_bQuitByJumping = true; m_fQuitByJumpingRemainingTime = quitByJumpingDuration; } else { movementController.CanJump(canJumpAfterLadderDuration); } if (onStopClimb != null) { onStopClimb(); } }
public void OnLadderColliderEnter(Object_Ladder_Collider a_rLadderCollider) { Object_Ladder rLadder = a_rLadderCollider.ladder; if (m_oLadders.Contains(rLadder) == false) { m_oLadders.Add(rLadder); } }
private void StartClimbing(Object_Ladder a_rLadder) { m_bQuitByJumping = false; m_bClimbing = true; m_rLadder = a_rLadder; Position = m_rLadder.SnapOnLadder(Position, climberTop.position, climberBottom.position); movementController.DisableMovement(); if (onStartClimb != null) { onStartClimb(); } }
public Object_Ladder GetNearestLadder(Vector2 a_f2Position) { Object_Ladder rNearestLadder = null; float fDistanceMin = float.PositiveInfinity; foreach (Object_Ladder rLadder in m_oLadders) { float fDistance = rLadder.DistanceToLadder(a_f2Position); if (fDistance < fDistanceMin) { fDistanceMin = fDistance; rNearestLadder = rLadder; } } return(rNearestLadder); }
private void ProcessLadderClimb() { float fVertical = characterInput.Vertical; float fHorizontal = characterInput.Horizontal; bool bQuitLadder = (fHorizontal != 0.0f && Mathf.Abs(fHorizontal) > Mathf.Abs(fVertical)) || characterInput.Jump; if (m_bQuitByJumping) { m_fQuitByJumpingRemainingTime -= Time.fixedDeltaTime; if (m_fQuitByJumpingRemainingTime <= 0) { m_bQuitByJumping = false; } } if (m_bClimbing) { if (bQuitLadder) { StopClimbing(); } else { float fClimbSpeed; if (characterInput.Run) { fClimbSpeed = climbRunSpeed; } else { fClimbSpeed = climbSpeed; } Climb(fClimbSpeed * Time.fixedDeltaTime * fVertical); } } else if (bQuitLadder == false && m_bQuitByJumping == false) { if (fVertical != 0.0f) { Object_Ladder rLadder = ladderTester.GetNearestLadder(movementController.rigidbodyComponent.transform.position); if (rLadder != null) { if (fVertical > 0.0f) { if (climberTop.position.y > rLadder.ladderTop.position.y - canClimbInADirectionTolerance) { return; } } else { if (climberBottom.position.y < rLadder.ladderBottom.position.y + canClimbInADirectionTolerance) { return; } } StartClimbing(rLadder); } } } }
private void StopClimbing() { m_bClimbing = false; m_rLadder = null; movementController.EnableMovement(); float fVertical = characterInput.Vertical; float fHorizontal = characterInput.Horizontal; if(characterInput.Jump) { if(!(fVertical < 0.0f && Mathf.Abs(fVertical) >= Mathf.Abs(fHorizontal))) { movementController.Jump(); } m_bQuitByJumping = true; m_fQuitByJumpingRemainingTime = quitByJumpingDuration; } else { movementController.CanJump(canJumpAfterLadderDuration); } if(onStopClimb != null) { onStopClimb(); } }
private void StartClimbing(Object_Ladder a_rLadder) { m_bQuitByJumping = false; m_bClimbing = true; m_rLadder = a_rLadder; Position = m_rLadder.SnapOnLadder(Position, climberTop.position, climberBottom.position); movementController.DisableMovement(); if(onStartClimb != null) { onStartClimb(); } }
public void OnLadderColliderExit(Object_Ladder_Collider a_rLadderCollider) { Object_Ladder rLadder = a_rLadderCollider.ladder; m_oLadders.Remove(rLadder); }