from medium upwards, ai goes to middle when idle

main
Benjamin Kraft 1 year ago
parent f109ffbd34
commit b9c07db9d0
  1. 21
      Assets/Prefabs/Player.prefab
  2. 5
      Assets/Scripts/Game/AIPlayer.cs
  3. 3
      Assets/Scripts/Game/GameManager.cs

@ -13,7 +13,6 @@ GameObject:
- component: {fileID: 5402279313309450412} - component: {fileID: 5402279313309450412}
- component: {fileID: 1666507220592599477} - component: {fileID: 1666507220592599477}
- component: {fileID: 1287955657} - component: {fileID: 1287955657}
- component: {fileID: 6551590900950860653}
m_Layer: 0 m_Layer: 0
m_Name: Player m_Name: Player
m_TagString: Untagged m_TagString: Untagged
@ -30,7 +29,7 @@ Transform:
m_GameObject: {fileID: 5402279313309450415} m_GameObject: {fileID: 5402279313309450415}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 4, y: 4, z: 4} m_LocalScale: {x: 4, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
@ -121,7 +120,7 @@ PolygonCollider2D:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5402279313309450415} m_GameObject: {fileID: 5402279313309450415}
m_Enabled: 0 m_Enabled: 1
m_Density: 1 m_Density: 1
m_Material: {fileID: 6200000, guid: 2d231bbc8208f52c797c91aa2030f60f, type: 2} m_Material: {fileID: 6200000, guid: 2d231bbc8208f52c797c91aa2030f60f, type: 2}
m_IsTrigger: 0 m_IsTrigger: 0
@ -192,19 +191,3 @@ MonoBehaviour:
AlwaysReplicateAsRoot: 0 AlwaysReplicateAsRoot: 0
DontDestroyWithOwner: 0 DontDestroyWithOwner: 0
AutoObjectParentSync: 1 AutoObjectParentSync: 1
--- !u!58 &6551590900950860653
CircleCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5402279313309450415}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 6200000, guid: 2d231bbc8208f52c797c91aa2030f60f, type: 2}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
serializedVersion: 2
m_Radius: 0.5

@ -8,8 +8,6 @@ namespace Game {
/* /*
* Possible optimizations: * Possible optimizations:
*
* - Move to center when idle
* - Ignore impossible balls * - Ignore impossible balls
* - Try to hit ball with edge * - Try to hit ball with edge
*/ */
@ -120,8 +118,9 @@ namespace Game {
var approaching = balls.Where(BallApproaches).ToList(); var approaching = balls.Where(BallApproaches).ToList();
if (approaching.Count == 0) if (approaching.Count == 0)
return X(); return Difficulty >= Difficulty.Medium ? 0 : X();
// Nearest by Y-Distance
Ball ball = approaching.Aggregate(approaching[0], (prev, current) => YDistanceToBall(current) < YDistanceToBall(prev) ? current : prev); Ball ball = approaching.Aggregate(approaching[0], (prev, current) => YDistanceToBall(current) < YDistanceToBall(prev) ? current : prev);
Vector2 origin = ball.Rb.position; Vector2 origin = ball.Rb.position;

@ -49,6 +49,9 @@ namespace Game {
} }
private void Start() { private void Start() {
Settings.Type = Type.Hybrid;
Settings.AIDifficulty = Difficulty.Easy;
var ball = Instantiate(ballPrefab).GetComponent<Ball>(); var ball = Instantiate(ballPrefab).GetComponent<Ball>();
Balls.Add(ball); Balls.Add(ball);
ball.Radius = 0.5f; ball.Radius = 0.5f;

Loading…
Cancel
Save