aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorCarson Katri <carson.katri@gmail.com>2021-06-12 21:26:35 -0400
committerCarson Katri <carson.katri@gmail.com>2021-06-12 21:26:35 -0400
commit55c85ac8246c6f811bf1dac0de48da423f064c87 (patch)
treeaedb7f5fd8d7353c9a3e152b10a62d7228c48440
parent7a86f34935f52bd86488f878d98877cd645e9900 (diff)
parentfc19cb9c30967431f959a1c9360f5ef847bcd31c (diff)
downloadgmtk-gamejam-55c85ac8246c6f811bf1dac0de48da423f064c87.tar.gz
gmtk-gamejam-55c85ac8246c6f811bf1dac0de48da423f064c87.tar.zst
gmtk-gamejam-55c85ac8246c6f811bf1dac0de48da423f064c87.zip
Merge branch 'master' of git.cameronkatri.com:gmtk-gamejam
-rw-r--r--Assets/Scripts/Controllers/AIController.cs2
-rw-r--r--Assets/Scripts/Controllers/Ball.cs4
-rw-r--r--Assets/Scripts/Controllers/GameController.cs5
-rw-r--r--Assets/Scripts/Controllers/Player/PlayerController.cs7
4 files changed, 12 insertions, 6 deletions
diff --git a/Assets/Scripts/Controllers/AIController.cs b/Assets/Scripts/Controllers/AIController.cs
index 4879c4c..bd5fee1 100644
--- a/Assets/Scripts/Controllers/AIController.cs
+++ b/Assets/Scripts/Controllers/AIController.cs
@@ -55,7 +55,7 @@ namespace Controllers
var playerHoopDistance = Mathf.Abs(player.root.transform.position.x - game.EnemyHoop.transform.position.x);
if (hoopDistance < 6f && hoopDistance > 2.5f && (Random.Range(0, 100) > 30 || playerHoopDistance > hoopDistance)) // Take the shot when in range. 70% chance he decides to if the player is standing between him and the basket.
{
- game.enemy.Shoot(transform);
+ game.enemy.Shoot(transform, 0f);
}
}
diff --git a/Assets/Scripts/Controllers/Ball.cs b/Assets/Scripts/Controllers/Ball.cs
index 07e1b37..936b857 100644
--- a/Assets/Scripts/Controllers/Ball.cs
+++ b/Assets/Scripts/Controllers/Ball.cs
@@ -20,11 +20,11 @@ namespace Controllers
controller.BallDropped();
}
- public void Shoot(Vector3 target)
+ public void Shoot(Vector3 target, float time)
{
transform.right = target - transform.position;
Rigidbody.velocity = Vector2.zero;
- Rigidbody.AddForce((transform.right + (transform.up * 0.5f)) * shotForce);
+ Rigidbody.AddForce((transform.right + (transform.up * 0.5f)) * (shotForce * ((Mathf.Clamp(time, 0f, 1f) + 1))));
}
}
}
diff --git a/Assets/Scripts/Controllers/GameController.cs b/Assets/Scripts/Controllers/GameController.cs
index a3783bd..ce6ea7e 100644
--- a/Assets/Scripts/Controllers/GameController.cs
+++ b/Assets/Scripts/Controllers/GameController.cs
@@ -135,15 +135,16 @@ namespace Controllers
/// Shoot the ball if possible.
/// </summary>
/// <param name="playerTransform"></param>
+ /// <param name="time"></param>
/// <returns>Whether or not the ball was shot</returns>
- public bool Shoot(Transform playerTransform)
+ public bool Shoot(Transform playerTransform, float time)
{
if (controller.state != dribble) return false; // We must be dribbling the ball to shoot it.
controller.BallAnimation.enabled = true;
controller.dribbleSound.Stop();
controller.state = shoot;
controller.ball.Rigidbody.bodyType = RigidbodyType2D.Dynamic;
- controller.ball.Shoot(hoop.transform.position);
+ controller.ball.Shoot(hoop.transform.position, time);
lastShotPosition = playerTransform.position;
return true;
}
diff --git a/Assets/Scripts/Controllers/Player/PlayerController.cs b/Assets/Scripts/Controllers/Player/PlayerController.cs
index 8aa0f25..1360b6c 100644
--- a/Assets/Scripts/Controllers/Player/PlayerController.cs
+++ b/Assets/Scripts/Controllers/Player/PlayerController.cs
@@ -21,6 +21,8 @@ namespace Controllers.Player
public PlayerSegment root => segments[0];
+ private float ShootStartTime;
+
private void Awake()
{
foreach (var segment in segments) {
@@ -98,7 +100,10 @@ namespace Controllers.Player
// Try shooting the ball if pressed.
if (Input.GetKeyDown(controls.shoot))
- game.player.Shoot(segments.Last().transform);
+ ShootStartTime = Time.time;
+
+ if (Input.GetKeyUp(controls.shoot))
+ game.player.Shoot(segments.Last().transform, ShootStartTime - Time.time);
}
[Serializable]