Skip to content

Commit d6d8b75

Browse files
committed
fix: LoseBallChainHandler
1 parent 45eb217 commit d6d8b75

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

Assets/Code/Services/BallController/BallChainController.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,25 +198,25 @@ private void MoveBalls()
198198

199199
private void MoveBall(Ball ball, int index)
200200
{
201-
float targetDistance = Mathf.Max(_chainTracker.DistanceTravelled - (index * _ballChainDto.SpacingBalls), 0);
202-
Vector3 targetPosition = _pathCreator.path.GetPointAtDistance(targetDistance);
201+
float rawTargetDistance = _chainTracker.DistanceTravelled - (index * _ballChainDto.SpacingBalls);
202+
float targetDistance = Mathf.Clamp(rawTargetDistance, 0f, _pathCreator.path.length - 0.1f);
203203
float currentSpeed = Time.deltaTime / _ballChainDto.DurationMovingOffset;
204+
204205
if (_loseBallChainHandler.IsLose)
205206
{
206-
targetPosition = _pathCreator.path.GetPointAtDistance(_pathCreator.path.length - 0.01f);
207-
currentSpeed = Time.deltaTime / (_ballChainDto.DurationMovingOffset * (index / 100f));
207+
currentSpeed = Time.deltaTime / (_ballChainDto.DurationMovingOffset + index * 0.03f);
208208
}
209-
ball.transform.position = Vector3.Lerp(ball.transform.position, targetPosition, currentSpeed);
209+
210+
Vector3 targetPosition = _pathCreator.path.GetPointAtDistance(targetDistance, EndOfPathInstruction.Stop);
211+
ball.transform.position = Vector3.Lerp(ball.transform.position, targetPosition,
212+
currentSpeed);
213+
210214
}
211215

212216
private void MoveFistBall()
213217
{
214-
float targetDistance = _chainTracker.DistanceTravelled;
215-
Vector3 targetPosition = _pathCreator.path.GetPointAtDistance(targetDistance);
216-
if (_loseBallChainHandler.IsLose)
217-
{
218-
targetPosition = _pathCreator.path.GetPointAtDistance(_pathCreator.path.length - 0.01f);
219-
}
218+
float targetDistance = Mathf.Clamp(_chainTracker.DistanceTravelled, 0f, _pathCreator.path.length - 0.01f);
219+
Vector3 targetPosition = _pathCreator.path.GetPointAtDistance(targetDistance, EndOfPathInstruction.Stop);
220220
CurrentBalls[0].transform.position = Vector3.Lerp(CurrentBalls[0].transform.position, targetPosition,
221221
Time.deltaTime / _ballChainDto.DurationMovingOffset);
222222
}

Assets/Code/Services/BallController/LoseBallChainHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private async UniTask TriggerDefeatConditionAsync()
6666
_inputService.Cleanup();
6767

6868
_gameFactory.Player.PlayerAnimator.PlayLoopRotation();
69-
_ballChainDto.MoveSpeed = _ballChainDto.BoostSpeedBallForLose;
69+
_ballChainDto.DurationMovingOffset = _ballChainDto.BoostSpeedBallForLose;
7070
await UniTask.WaitUntil(() => _chainTracker.Balls.Count == 0);
7171
_gameFactory.Player.PlayerAnimator.StopRotation();
7272
await UniTask.Delay(1000);

Assets/Resources/StaticData/BallChainConfig.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ MonoBehaviour:
2727
SetToSpawnWidget: 1.15
2828
TimeToSpawnWidget: 50
2929
PercentToDetectionLose: 20
30-
BoostSpeedBallForLose: 4
30+
BoostSpeedBallForLose: 0.05

0 commit comments

Comments
 (0)