From 67c86ed960cc5feaedd06569ad62a340cc0d013f Mon Sep 17 00:00:00 2001 From: Carson Katri Date: Sat, 12 Jun 2021 18:06:04 -0400 Subject: Functional AI that can dribble, steal, and shoot --- Assets/Scripts/Controllers/GameController.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Assets/Scripts/Controllers/GameController.cs') 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; /// @@ -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; } -- cgit v1.2.3-56-ge451