|
|
@ -68,7 +68,8 @@ namespace Game { |
|
|
|
|
|
|
|
|
|
|
|
private float IdlePosition => Difficulty >= Difficulty.Medium ? 0 : X(); |
|
|
|
private float IdlePosition => Difficulty >= Difficulty.Medium ? 0 : X(); |
|
|
|
|
|
|
|
|
|
|
|
// TODO solution for balls outside of border |
|
|
|
private float DistortAmount => 1 - 1 / ((float) Difficulty + 1); |
|
|
|
|
|
|
|
|
|
|
|
// TODO Also must include fact that players have a height, maybe check the incoming angle |
|
|
|
// TODO Also must include fact that players have a height, maybe check the incoming angle |
|
|
|
// angle: 0 -> perpendicular, from -90 to 90 |
|
|
|
// angle: 0 -> perpendicular, from -90 to 90 |
|
|
|
private bool IsPositionReachableInTime(float futurePosition, float seconds, float angle) { |
|
|
|
private bool IsPositionReachableInTime(float futurePosition, float seconds, float angle) { |
|
|
@ -151,8 +152,12 @@ namespace Game { |
|
|
|
float radius = ball.Radius; |
|
|
|
float radius = ball.Radius; |
|
|
|
|
|
|
|
|
|
|
|
float target = Simulate(origin, velocity, radius, FutureSeconds, 0, out bool impossible); |
|
|
|
float target = Simulate(origin, velocity, radius, FutureSeconds, 0, out bool impossible); |
|
|
|
if (!impossible) |
|
|
|
if (!impossible) { |
|
|
|
return target; |
|
|
|
float max = Width / 2; |
|
|
|
|
|
|
|
float distortionOffset = DistortAmount * max; |
|
|
|
|
|
|
|
distortionOffset *= target > X() ? -1 : 1; |
|
|
|
|
|
|
|
return target + distortionOffset; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
approaching.Remove(ball); |
|
|
|
approaching.Remove(ball); |
|
|
|
// This ball was impossible to catch, try next one |
|
|
|
// This ball was impossible to catch, try next one |
|
|
@ -163,7 +168,7 @@ namespace Game { |
|
|
|
|
|
|
|
|
|
|
|
private float currentSmoothV; |
|
|
|
private float currentSmoothV; |
|
|
|
private void ApproachPosition(float pos) { |
|
|
|
private void ApproachPosition(float pos) { |
|
|
|
float result = Mathf.SmoothDamp(X(), pos, ref currentSmoothV, .5f, Speed); |
|
|
|
float result = Mathf.SmoothDamp(X(), pos, ref currentSmoothV, .2f, Speed); |
|
|
|
transform.position = new Vector2(result, Y()); |
|
|
|
transform.position = new Vector2(result, Y()); |
|
|
|
ClampInsideBorders(); |
|
|
|
ClampInsideBorders(); |
|
|
|
} |
|
|
|
} |
|
|
|