private void CalculateJumpPosition() { var playerPosition = _p0 = transform.position; var preLastPlatform = _platformSystem.PreLastPlatform(); var preLastPlatformPosition = preLastPlatform.transform.position; Vector3 localPosition; switch (_jumpDirection) { case JumpDirection.Left: localPosition = transform.localPosition; if (localPosition.z + _jumpDistance <= PlatformAvailableRadius) { _isSteppedCenter = false; _p1 = new Vector3( playerPosition.x, playerPosition.y + preLastPlatformPosition.y + _jumpDistance, playerPosition.z + _jumpDistance ); _p2 = new Vector3( playerPosition.x, playerPosition.y + preLastPlatformPosition.y, playerPosition.z + _jumpDistance ); return; } else if (localPosition.x + _jumpDistance <= PlatformOutRadius) { _p1 = new Vector3( playerPosition.x, playerPosition.y - localPosition.z + 3, preLastPlatformPosition.z + 3 ); _p2 = new Vector3( playerPosition.x, playerPosition.y + preLastPlatformPosition.y, preLastPlatformPosition.z + 3 ); StartCoroutine(Die(1)); return; } break; case JumpDirection.Right: localPosition = transform.localPosition; if (localPosition.x + _jumpDistance <= PlatformAvailableRadius) { _isSteppedCenter = false; _p1 = new Vector3( playerPosition.x + _jumpDistance, playerPosition.y + preLastPlatformPosition.y + _jumpDistance, playerPosition.z ); _p2 = new Vector3( playerPosition.x + _jumpDistance, playerPosition.y + preLastPlatformPosition.y, playerPosition.z ); return; } else if (localPosition.x + _jumpDistance <= PlatformOutRadius) { _p1 = new Vector3( preLastPlatformPosition.x + 3, playerPosition.y - localPosition.x + 3, playerPosition.z ); _p2 = new Vector3( preLastPlatformPosition.x + 3, playerPosition.y + preLastPlatformPosition.y, playerPosition.z ); StartCoroutine(Die(1)); return; } break; default: throw new ArgumentOutOfRangeException(); } var lastPlatform = _platformSystem.LastPlatform(); var lastPlatformPosition = lastPlatform.transform.position; float distance; switch (_jumpDirection) { case JumpDirection.Left: distance = lastPlatformPosition.z - playerPosition.z; break; case JumpDirection.Right: distance = lastPlatformPosition.x - playerPosition.x; break; default: throw new ArgumentOutOfRangeException(); } var deltaDistance = Mathf.Abs(distance - _jumpDistance); if (deltaDistance <= PlatformCenterRadius) { _isSteppedCenter = true; switch (_jumpDirection) { case JumpDirection.Left: _p1 = new Vector3( lastPlatformPosition.x, playerPosition.y + distance, lastPlatformPosition.z ); _p2 = new Vector3( lastPlatformPosition.x, playerPosition.y + lastPlatformPosition.y, lastPlatformPosition.z ); break; case JumpDirection.Right: _p1 = new Vector3( lastPlatformPosition.x, playerPosition.y + distance, lastPlatformPosition.z ); _p2 = new Vector3( lastPlatformPosition.x, playerPosition.y + lastPlatformPosition.y, lastPlatformPosition.z ); break; default: throw new ArgumentOutOfRangeException(); } } else if (deltaDistance <= PlatformAvailableRadius) { _isSteppedCenter = false; switch (_jumpDirection) { case JumpDirection.Left: _p1 = new Vector3( playerPosition.x, playerPosition.y + _jumpDistance, playerPosition.z + _jumpDistance ); _p2 = new Vector3( playerPosition.x, playerPosition.y, playerPosition.z + _jumpDistance ); break; case JumpDirection.Right: _p1 = new Vector3( playerPosition.x + _jumpDistance, playerPosition.y + _jumpDistance, playerPosition.z ); _p2 = new Vector3( playerPosition.x + _jumpDistance, playerPosition.y, playerPosition.z ); break; default: throw new ArgumentOutOfRangeException(); } } else if (deltaDistance <= PlatformOutRadius) { switch (_jumpDirection) { case JumpDirection.Left: if (playerPosition.z + _jumpDistance < lastPlatformPosition.z) { _p1 = new Vector3( playerPosition.x, playerPosition.y + distance - 2, lastPlatformPosition.z - 2 ); _p2 = new Vector3( playerPosition.x, playerPosition.y + lastPlatformPosition.y, lastPlatformPosition.z - 2 ); } else { _p1 = new Vector3( playerPosition.x, playerPosition.y + distance + 2, lastPlatformPosition.z + 2 ); _p2 = new Vector3( playerPosition.x, playerPosition.y + lastPlatformPosition.y, lastPlatformPosition.z + 2 ); } break; case JumpDirection.Right: if (playerPosition.x + _jumpDistance < lastPlatformPosition.x) { _p1 = new Vector3( lastPlatformPosition.x - 2, playerPosition.y + distance - 2, playerPosition.z ); _p2 = new Vector3( lastPlatformPosition.x - 2, playerPosition.y + lastPlatformPosition.y, playerPosition.z ); } else { _p1 = new Vector3( lastPlatformPosition.x + 2, playerPosition.y + distance + 2, playerPosition.z ); _p2 = new Vector3( lastPlatformPosition.x + 2, playerPosition.y + lastPlatformPosition.y, playerPosition.z ); } break; default: throw new ArgumentOutOfRangeException(); } StartCoroutine(Die(2.25f)); } else { switch (_jumpDirection) { case JumpDirection.Left: _p1 = _p0 + (Vector3.forward + Vector3.up) * _jumpDistance; _p2 = _p0 + Vector3.forward * _jumpDistance; break; case JumpDirection.Right: _p1 = _p0 + (Vector3.right + Vector3.up) * _jumpDistance; _p2 = _p0 + Vector3.right * _jumpDistance; break; default: throw new ArgumentOutOfRangeException(); } StartCoroutine(Die(1)); } }