]> git.cameronkatri.com Git - gmtk-gamejam.git/commitdiff
Only shoot if you have the ball
authorCameron Katri <me@cameronkatri.com>
Sun, 13 Jun 2021 16:25:28 +0000 (12:25 -0400)
committerCameron Katri <me@cameronkatri.com>
Sun, 13 Jun 2021 16:25:28 +0000 (12:25 -0400)
Assets/Scripts/Controllers/Player/PlayerController.cs

index e555becd309847ad1ea7a91803752dbe8f0fb65a..191c970f9aa3ba141a938365130147af745049b4 100644 (file)
@@ -103,20 +103,22 @@ namespace Controllers.Player
         }
       }
       
-      // Try shooting the ball if pressed.
-      if (Input.GetKeyDown(controls.shoot))
-      {
-        ShootStartTime = Time.time;
-        progressBarContainer.SetActive(true);
-      }
+      if (game.player.HasBall) {
+        // Try shooting the ball if pressed.
+        if (Input.GetKeyDown(controls.shoot))
+        {
+          ShootStartTime = Time.time;
+          progressBarContainer.SetActive(true);
+        }
 
-      progressBar.transform.localScale = new Vector3(0.75f * Mathf.Clamp(Time.time - ShootStartTime, 0f, 1f), 0.05f, 1f);
-      // progressBar.transform.localPosition = new Vector3(0.75f * (1 - Mathf.Clamp(Time.time - ShootStartTime, 0f, 1f)), 0f, 0f);
+        progressBar.transform.localScale = new Vector3(0.75f * Mathf.Clamp(Time.time - ShootStartTime, 0f, 1f), 0.05f, 1f);
+        // progressBar.transform.localPosition = new Vector3(0.75f * (1 - Mathf.Clamp(Time.time - ShootStartTime, 0f, 1f)), 0f, 0f);
 
-      if (Input.GetKeyUp(controls.shoot))
-      {
-        game.player.Shoot(segments.Last().transform, Time.time - ShootStartTime);
-        progressBarContainer.SetActive(false);
+        if (Input.GetKeyUp(controls.shoot))
+        {
+          game.player.Shoot(segments.Last().transform, Time.time - ShootStartTime);
+          progressBarContainer.SetActive(false);
+        }
       }
     }