aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Assets/Scripts/Controllers/GameController.cs
diff options
context:
space:
mode:
authorCarson Katri <carson.katri@gmail.com>2021-06-12 18:06:04 -0400
committerCarson Katri <carson.katri@gmail.com>2021-06-12 18:06:04 -0400
commit67c86ed960cc5feaedd06569ad62a340cc0d013f (patch)
treec5408bb4dd3b6df4a6b6e88fa41ee9875d3201e4 /Assets/Scripts/Controllers/GameController.cs
parent71e603101369cf4a144904a2fc0e45ad3f862296 (diff)
downloadgmtk-gamejam-67c86ed960cc5feaedd06569ad62a340cc0d013f.tar.gz
gmtk-gamejam-67c86ed960cc5feaedd06569ad62a340cc0d013f.tar.zst
gmtk-gamejam-67c86ed960cc5feaedd06569ad62a340cc0d013f.zip
Functional AI that can dribble, steal, and shoot
Diffstat (limited to 'Assets/Scripts/Controllers/GameController.cs')
-rw-r--r--Assets/Scripts/Controllers/GameController.cs6
1 files changed, 4 insertions, 2 deletions
diff --git a/Assets/Scripts/Controllers/GameController.cs b/Assets/Scripts/Controllers/GameController.cs
index 646b750..1573405 100644
--- a/Assets/Scripts/Controllers/GameController.cs
+++ b/Assets/Scripts/Controllers/GameController.cs
@@ -60,6 +60,8 @@ namespace Controllers
private State dribble => isEnemy ? State.EnemyDribble : State.PlayerDribble;
private State shoot => isEnemy ? State.EnemyShoot : State.PlayerShoot;
+ private Hoop hoop => isEnemy ? controller.EnemyHoop : controller.PlayerHoop;
+
public bool HasBall => controller.state == dribble;
/// <summary>
@@ -80,7 +82,7 @@ namespace Controllers
public bool GrabBall(Vector2 handPosition)
{
// Don't allow the ball to be picked up if someone shot it. Also don't try picking it up if we're already holding it.
- //if (controller.state.IsShot() || controller.state == dribble) return false;
+ if (controller.state == shoot || controller.state == dribble) return false;
// Make sure its within their grab area.
if (Vector2.Distance(controller.ball.transform.position, handPosition) > 0.75f) return false;
@@ -99,7 +101,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);
+ controller.ball.Shoot(hoop.transform.position);
lastShotPosition = playerTransform.position;
return true;
}