From 78be656b187c9deeb53b1d45e9c4f9827a3e1220 Mon Sep 17 00:00:00 2001 From: Benjamin Kraft Date: Fri, 14 Apr 2023 18:19:18 +0200 Subject: [PATCH] use ball radius --- Assets/Scenes/Game.unity | 24 +++++++++--------------- Assets/Scripts/Game/AIPlayer.cs | 6 +++--- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/Assets/Scenes/Game.unity b/Assets/Scenes/Game.unity index 500d42c..e28c91c 100644 --- a/Assets/Scenes/Game.unity +++ b/Assets/Scenes/Game.unity @@ -648,7 +648,7 @@ SpriteRenderer: m_FlipX: 0 m_FlipY: 0 m_DrawMode: 2 - m_Size: {x: 28.636364, y: 35} + m_Size: {x: 20, y: 35} m_AdaptiveModeThreshold: 0.5 m_SpriteTileMode: 0 m_WasSpriteAssigned: 1 @@ -723,7 +723,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: isUpdating: 1 - panelHeightPixelsMinimum: 200 + panelHeightPixelsMinimum: 250 playGroundSize: {x: 20, y: 35} emptySpaceHeight: 3 mainCamera: {fileID: 1698696476} @@ -735,12 +735,6 @@ MonoBehaviour: playerPanelTop: {fileID: 738870617} playerPanelBottom: {fileID: 2108734120} background: {fileID: 712762093} - top: 17.5 - bottom: -17.5 - left: -10 - right: 10 - boardTop: 14.5 - boardBottom: -14.5 --- !u!1001 &1166615026 PrefabInstance: m_ObjectHideFlags: 0 @@ -943,7 +937,7 @@ Camera: far clip plane: 1000 field of view: 60 orthographic: 1 - orthographic size: 25.454546 + orthographic size: 27.6875 m_Depth: 0 m_CullingMask: serializedVersion: 2 @@ -1016,11 +1010,11 @@ PrefabInstance: m_Modifications: - target: {fileID: 4540566536649322900, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_Size.x - value: 28.636364 + value: 20 objectReference: {fileID: 0} - target: {fileID: 4540566536649322900, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_Size.y - value: 7.954546 + value: 10.1875 objectReference: {fileID: 0} - target: {fileID: 4540566536649322901, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_Name @@ -1036,7 +1030,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4540566536649322903, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_LocalPosition.y - value: -21.477272 + value: -22.59375 objectReference: {fileID: 0} - target: {fileID: 4540566536649322903, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_LocalPosition.z @@ -1155,11 +1149,11 @@ PrefabInstance: m_Modifications: - target: {fileID: 4540566536649322900, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_Size.x - value: 28.636364 + value: 20 objectReference: {fileID: 0} - target: {fileID: 4540566536649322900, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_Size.y - value: 7.954546 + value: 10.1875 objectReference: {fileID: 0} - target: {fileID: 4540566536649322901, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_Name @@ -1175,7 +1169,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4540566536649322903, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_LocalPosition.y - value: 21.477272 + value: 22.59375 objectReference: {fileID: 0} - target: {fileID: 4540566536649322903, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_LocalPosition.z diff --git a/Assets/Scripts/Game/AIPlayer.cs b/Assets/Scripts/Game/AIPlayer.cs index ef1532d..b8f9e72 100644 --- a/Assets/Scripts/Game/AIPlayer.cs +++ b/Assets/Scripts/Game/AIPlayer.cs @@ -66,8 +66,8 @@ namespace Game { // TODO Also must include fact that players have a height, maybe check the incoming angle // angle: 0 -> perpendicular, from -90 to 90 - private bool IsPositionReachableInTime(float futurePosition, float seconds, float angle) { - float requiredDistance = Mathf.Abs(futurePosition - X) - Width / 2; + private bool IsPositionReachableInTime(float futurePosition, float seconds, float radius, float angle) { + float requiredDistance = Mathf.Abs(futurePosition - X) - Width / 2 - radius; if (requiredDistance < 0) return true; if (Mathf.Abs(futurePosition) > Border) @@ -96,7 +96,7 @@ namespace Game { // Horizontal line (player line) -> stop simulating if (Intersect(origin, end, playerLeft, playerRight, out Vector2 point, out Vector2 rs)) { secondsUsed += secondsLeft * rs.x; - if (!IsPositionReachableInTime(point.x, secondsUsed, Vector2.Angle(velocity, transform.up))) + if (!IsPositionReachableInTime(point.x, secondsUsed, radius, Vector2.Angle(velocity, transform.up))) ignore = true; return point.x; }