aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorCarson Katri <carson.katri@gmail.com>2021-06-12 16:57:05 -0400
committerCarson Katri <carson.katri@gmail.com>2021-06-12 16:57:05 -0400
commit2da4072647dbf8577f8a5e2391551fbbfceef231 (patch)
tree636de5585864d64832d362117d40c93de97e5bb9
parent939170f625e5928d5ca86a57796aaa23f25a4fa7 (diff)
parentd6d5014337ab72a6eb8c2f93fae107c71d267649 (diff)
downloadgmtk-gamejam-2da4072647dbf8577f8a5e2391551fbbfceef231.tar.gz
gmtk-gamejam-2da4072647dbf8577f8a5e2391551fbbfceef231.tar.zst
gmtk-gamejam-2da4072647dbf8577f8a5e2391551fbbfceef231.zip
Resolve conflicts
-rw-r--r--Assets/Prefabs/Hoop.prefab69
-rw-r--r--Assets/Scenes/Main.unity104
-rw-r--r--Assets/Scripts/Controllers/AIController.cs27
-rw-r--r--Assets/Scripts/Controllers/GameController.cs17
-rw-r--r--Assets/Scripts/Controllers/Hoop.cs19
-rw-r--r--Assets/Scripts/Controllers/Hoop.cs.meta3
6 files changed, 147 insertions, 92 deletions
diff --git a/Assets/Prefabs/Hoop.prefab b/Assets/Prefabs/Hoop.prefab
index 691d0b2..7dfd3b9 100644
--- a/Assets/Prefabs/Hoop.prefab
+++ b/Assets/Prefabs/Hoop.prefab
@@ -14,6 +14,9 @@ GameObject:
- component: {fileID: 2106494524751008832}
- component: {fileID: 2106494524751008834}
- component: {fileID: 2106494524751008835}
+ - component: {fileID: 1029364543094105199}
+ - component: {fileID: 2639737386686648195}
+ - component: {fileID: 1022133350338841181}
m_Layer: 0
m_Name: Hoop
m_TagString: Untagged
@@ -183,3 +186,69 @@ BoxCollider2D:
serializedVersion: 2
m_Size: {x: 0.040855214, y: 0.030604668}
m_EdgeRadius: 0
+--- !u!61 &1029364543094105199
+BoxCollider2D:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 2106494524751008836}
+ m_Enabled: 1
+ m_Density: 1
+ m_Material: {fileID: 0}
+ m_IsTrigger: 1
+ m_UsedByEffector: 0
+ m_UsedByComposite: 0
+ m_Offset: {x: -0.0056511946, y: 0.005704716}
+ m_SpriteTilingProperty:
+ border: {x: 0, y: 0, z: 0, w: 0}
+ pivot: {x: 0.5, y: 0.5}
+ oldSize: {x: 0.32, y: 0.32}
+ newSize: {x: 0.32, y: 0.32}
+ adaptiveTilingThreshold: 0.5
+ drawMode: 0
+ adaptiveTiling: 0
+ m_AutoTiling: 0
+ serializedVersion: 2
+ m_Size: {x: 0.14921531, y: 0.050745383}
+ m_EdgeRadius: 0
+--- !u!61 &2639737386686648195
+BoxCollider2D:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 2106494524751008836}
+ m_Enabled: 1
+ m_Density: 1
+ m_Material: {fileID: 0}
+ m_IsTrigger: 1
+ m_UsedByEffector: 0
+ m_UsedByComposite: 0
+ m_Offset: {x: -0.005651191, y: -0.104769394}
+ m_SpriteTilingProperty:
+ border: {x: 0, y: 0, z: 0, w: 0}
+ pivot: {x: 0.5, y: 0.5}
+ oldSize: {x: 0.32, y: 0.32}
+ newSize: {x: 0.32, y: 0.32}
+ adaptiveTilingThreshold: 0.5
+ drawMode: 0
+ adaptiveTiling: 0
+ m_AutoTiling: 0
+ serializedVersion: 2
+ m_Size: {x: 0.14921531, y: 0.030544288}
+ m_EdgeRadius: 0
+--- !u!114 &1022133350338841181
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 2106494524751008836}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 40e5d6a883d14c7fb60913ec2fc3009c, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ Rim: {fileID: 2639737386686648195}
+ Net: {fileID: 1029364543094105199}
diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity
index 00dfe0d..0871fd5 100644
--- a/Assets/Scenes/Main.unity
+++ b/Assets/Scenes/Main.unity
@@ -152,7 +152,6 @@ Transform:
m_Children:
- {fileID: 1174357919}
- {fileID: 1189511746}
- - {fileID: 1006046227}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -299,15 +298,15 @@ Transform:
m_CorrespondingSourceObject: {fileID: 2106494524751008833, guid: b2939f2eae52d074b81e81fccdde88f9, type: 3}
m_PrefabInstance: {fileID: 1402386184}
m_PrefabAsset: {fileID: 0}
---- !u!114 &682227412 stripped
+--- !u!114 &614591307 stripped
MonoBehaviour:
- m_CorrespondingSourceObject: {fileID: 6095859834264611326, guid: c64ad9b908cb44602b3d13a74aef751f, type: 3}
- m_PrefabInstance: {fileID: 984947992}
+ m_CorrespondingSourceObject: {fileID: 1022133350338841181, guid: b2939f2eae52d074b81e81fccdde88f9, type: 3}
+ m_PrefabInstance: {fileID: 1402386184}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
- m_Script: {fileID: 11500000, guid: 261cc3206075846ebbd03b8896e7c733, type: 3}
+ m_Script: {fileID: 11500000, guid: 40e5d6a883d14c7fb60913ec2fc3009c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &700993592
@@ -327,11 +326,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 5143626018439341592, guid: 2485406c33a7d4f5481ce936cc9b162e, type: 3}
propertyPath: m_LocalPosition.x
- value: -2.46
+ value: 0.23
objectReference: {fileID: 0}
- target: {fileID: 5143626018439341592, guid: 2485406c33a7d4f5481ce936cc9b162e, type: 3}
propertyPath: m_LocalPosition.y
- value: 3.9
+ value: 5.17
objectReference: {fileID: 0}
- target: {fileID: 5143626018439341592, guid: 2485406c33a7d4f5481ce936cc9b162e, type: 3}
propertyPath: m_LocalPosition.z
@@ -399,11 +398,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 6095859834264611321, guid: c64ad9b908cb44602b3d13a74aef751f, type: 3}
propertyPath: m_LocalPosition.x
- value: -1.388642
+ value: -0.10864201
objectReference: {fileID: 0}
- target: {fileID: 6095859834264611321, guid: c64ad9b908cb44602b3d13a74aef751f, type: 3}
propertyPath: m_LocalPosition.y
- value: -1.7938846
+ value: -0.11388469
objectReference: {fileID: 0}
- target: {fileID: 6095859834264611321, guid: c64ad9b908cb44602b3d13a74aef751f, type: 3}
propertyPath: m_LocalPosition.z
@@ -459,11 +458,6 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c64ad9b908cb44602b3d13a74aef751f, type: 3}
---- !u!4 &1006046227 stripped
-Transform:
- m_CorrespondingSourceObject: {fileID: 7079067999241254396, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
- m_PrefabInstance: {fileID: 7079067998248188399}
- m_PrefabAsset: {fileID: 0}
--- !u!4 &1116995016 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 2106494524751008833, guid: b2939f2eae52d074b81e81fccdde88f9, type: 3}
@@ -513,6 +507,8 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
ball: {fileID: 707826158}
+ PlayerHoop: {fileID: 614591307}
+ EnemyHoop: {fileID: 1354192742}
--- !u!4 &1189511746 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 6095859834264611321, guid: c64ad9b908cb44602b3d13a74aef751f, type: 3}
@@ -579,6 +575,17 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: b2939f2eae52d074b81e81fccdde88f9, type: 3}
+--- !u!114 &1354192742 stripped
+MonoBehaviour:
+ m_CorrespondingSourceObject: {fileID: 1022133350338841181, guid: b2939f2eae52d074b81e81fccdde88f9, type: 3}
+ m_PrefabInstance: {fileID: 1354192741}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 40e5d6a883d14c7fb60913ec2fc3009c, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
--- !u!1001 &1402386184
PrefabInstance:
m_ObjectHideFlags: 0
@@ -726,72 +733,3 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: be9aa59b997c243a2bf4287cb2129092, type: 3}
---- !u!1001 &7079067998248188399
-PrefabInstance:
- m_ObjectHideFlags: 0
- serializedVersion: 2
- m_Modification:
- m_TransformParent: {fileID: 244382786}
- m_Modifications:
- - target: {fileID: 670472073231852718, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
- propertyPath: game
- value:
- objectReference: {fileID: 1174357920}
- - target: {fileID: 670472073231852718, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
- propertyPath: player
- value:
- objectReference: {fileID: 682227412}
- - target: {fileID: 670472073231852718, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
- propertyPath: legSpeed
- value: 5
- objectReference: {fileID: 0}
- - target: {fileID: 7079067999241254396, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
- propertyPath: m_RootOrder
- value: 2
- objectReference: {fileID: 0}
- - target: {fileID: 7079067999241254396, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
- propertyPath: m_LocalPosition.x
- value: 1.4913579
- objectReference: {fileID: 0}
- - target: {fileID: 7079067999241254396, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
- propertyPath: m_LocalPosition.y
- value: -2.725
- objectReference: {fileID: 0}
- - target: {fileID: 7079067999241254396, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
- propertyPath: m_LocalPosition.z
- value: 134.58575
- objectReference: {fileID: 0}
- - target: {fileID: 7079067999241254396, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
- propertyPath: m_LocalRotation.w
- value: 1
- objectReference: {fileID: 0}
- - target: {fileID: 7079067999241254396, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
- propertyPath: m_LocalRotation.x
- value: -0
- objectReference: {fileID: 0}
- - target: {fileID: 7079067999241254396, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
- propertyPath: m_LocalRotation.y
- value: -0
- objectReference: {fileID: 0}
- - target: {fileID: 7079067999241254396, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
- propertyPath: m_LocalRotation.z
- value: -0
- objectReference: {fileID: 0}
- - target: {fileID: 7079067999241254396, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
- propertyPath: m_LocalEulerAnglesHint.x
- value: 0
- objectReference: {fileID: 0}
- - target: {fileID: 7079067999241254396, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
- propertyPath: m_LocalEulerAnglesHint.y
- value: 0
- objectReference: {fileID: 0}
- - target: {fileID: 7079067999241254396, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
- propertyPath: m_LocalEulerAnglesHint.z
- value: 0
- objectReference: {fileID: 0}
- - target: {fileID: 7079067999241254397, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
- propertyPath: m_Name
- value: Enemy
- objectReference: {fileID: 0}
- m_RemovedComponents: []
- m_SourcePrefab: {fileID: 100100000, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
diff --git a/Assets/Scripts/Controllers/AIController.cs b/Assets/Scripts/Controllers/AIController.cs
index 19a7d3e..1b7fba8 100644
--- a/Assets/Scripts/Controllers/AIController.cs
+++ b/Assets/Scripts/Controllers/AIController.cs
@@ -26,7 +26,23 @@ namespace Controllers
public BoxCollider2D BoxCollider => _boxCollider != null ? _boxCollider : _boxCollider = GetComponent<BoxCollider2D>();
private BoxCollider2D _boxCollider;
-
+
+ private void Start()
+ {
+ // Try to grab (steal) the ball every n seconds.
+ InvokeRepeating(nameof(GrabBall), 0, 0.5f);
+ }
+
+ private void GrabBall()
+ {
+ // Grab from the middle, and the bottom.
+ if (game.player.HasBall && Random.Range(0, 100) > 95) // 5% chance of them grabbing the ball from the player.
+ {
+ game.enemy.GrabBall(transform.position);
+ game.enemy.GrabBall(transform.position + new Vector3(0f, BoxCollider.size.y / 2, 0f));
+ }
+ }
+
private void Update()
{
if (!game.enemy.HasBall) // Move towards the ball to grab it.
@@ -35,14 +51,7 @@ namespace Controllers
if (Vector2.Distance(player.transform.position, transform.position) < 1f) // Repel from the player if they get too close.
{
- transform.position -= (player.transform.position - transform.position).normalized * (Time.deltaTime * speed / 2f);
- }
-
- // Grab from the middle, and the bottom.
- if (game.player.HasBall && Random.Range(0, 100) > 50) // 50% chance of them grabbing the ball from the player.
- {
- game.enemy.GrabBall(transform.position);
- game.enemy.GrabBall(transform.position + new Vector3(0f, BoxCollider.size.y / 2, 0f));
+ transform.position += (player.transform.position - transform.position).normalized * (Time.deltaTime * speed / 2f);
}
}
else // Otherwise, move toward the basket, and then once we get within range, take the shot.
diff --git a/Assets/Scripts/Controllers/GameController.cs b/Assets/Scripts/Controllers/GameController.cs
index 9ae0ce8..b9f65f2 100644
--- a/Assets/Scripts/Controllers/GameController.cs
+++ b/Assets/Scripts/Controllers/GameController.cs
@@ -18,6 +18,9 @@ namespace Controllers
/// </summary>
[SerializeField] public Ball ball;
+ [SerializeField] public Hoop PlayerHoop;
+ [SerializeField] public Hoop EnemyHoop;
+
private void Awake()
{
player = new Player { isEnemy = false, controller = this };
@@ -37,6 +40,19 @@ namespace Controllers
/// </summary>
internal GameController controller;
+ internal int score;
+
+ private Vector2 lastShotPosition;
+ public void Score(Vector2 Rim) {
+ if (Vector2.Distance(lastShotPosition, Rim) >= 1)
+ {
+ score += 3;
+ Debug.Log("Three point");
+ } else
+ score += 2;
+ Debug.Log("Two point");
+ }
+
private State dribble => isEnemy ? State.EnemyDribble : State.PlayerDribble;
private State shoot => isEnemy ? State.EnemyShoot : State.PlayerShoot;
@@ -80,6 +96,7 @@ namespace Controllers
if (controller.state != dribble) return false; // We must be dribbling the ball to shoot it.
controller.state = shoot;
controller.ball.Shoot(playerTransform);
+ lastShotPosition = playerTransform.position;
return true;
}
}
diff --git a/Assets/Scripts/Controllers/Hoop.cs b/Assets/Scripts/Controllers/Hoop.cs
new file mode 100644
index 0000000..58f7130
--- /dev/null
+++ b/Assets/Scripts/Controllers/Hoop.cs
@@ -0,0 +1,19 @@
+using System;
+using UnityEngine;
+
+namespace Controllers
+{
+ public class Hoop : MonoBehaviour
+ {
+ [SerializeField] private BoxCollider2D Rim;
+ [SerializeField] private BoxCollider2D Net;
+
+ private void OnTriggerEnter2D(Collider2D other)
+ {
+ if (other.GetComponent<Ball>() == null) return;
+
+ if (Rim.IsTouching(other) && Net.IsTouching(other))
+ Debug.Log("Swish!");
+ }
+ }
+} \ No newline at end of file
diff --git a/Assets/Scripts/Controllers/Hoop.cs.meta b/Assets/Scripts/Controllers/Hoop.cs.meta
new file mode 100644
index 0000000..29125c3
--- /dev/null
+++ b/Assets/Scripts/Controllers/Hoop.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 40e5d6a883d14c7fb60913ec2fc3009c
+timeCreated: 1623524972 \ No newline at end of file