aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Assets/Scripts/Controllers/GameController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts/Controllers/GameController.cs')
-rw-r--r--Assets/Scripts/Controllers/GameController.cs27
1 files changed, 24 insertions, 3 deletions
diff --git a/Assets/Scripts/Controllers/GameController.cs b/Assets/Scripts/Controllers/GameController.cs
index c9cb0ce..35e6b62 100644
--- a/Assets/Scripts/Controllers/GameController.cs
+++ b/Assets/Scripts/Controllers/GameController.cs
@@ -46,6 +46,11 @@ namespace Controllers
[SerializeField] public AudioSource dribbleSound;
[SerializeField] public AudioSource airhornSound;
+ [Header("VFX")]
+ [SerializeField] private GameObject twoPointVFX;
+ [SerializeField] private GameObject threePointVFX;
+ [SerializeField] private GameObject spotlightVFX;
+
[Header("UI")]
[SerializeField] private Text playerScoreText;
[SerializeField] private Text enemyScoreText;
@@ -148,14 +153,20 @@ namespace Controllers
if (Vector2.Distance(lastShotPosition, Rim) >= 10)
{
score += 3;
+ controller.ParticleEffect(true, hoop);
}
else
{
score += 2;
+ controller.ParticleEffect(false, hoop);
}
+
+ // Make two spotlights.
+ Instantiate(controller.spotlightVFX);
+ Instantiate(controller.spotlightVFX);
// They made a shot! Now respawn the players and give possession to the opposite player.
- controller.Respawn(isEnemy ? Possession.Player : Possession.Enemy, $"{controller.player.score}-{controller.enemy.score}");
+ controller.StartCoroutine(controller.Respawn(isEnemy ? Possession.Player : Possession.Enemy, $"{controller.player.score}-{controller.enemy.score}"));
}
private State dribble => isEnemy ? State.EnemyDribble : State.PlayerDribble;
@@ -165,6 +176,8 @@ namespace Controllers
public bool HasBall => controller.state == dribble;
+ public bool IsShooting => controller.state == shoot;
+
/// <summary>
/// When dribbling, move the ball with the player.
/// </summary>
@@ -219,7 +232,7 @@ namespace Controllers
public void Foul(string reason)
{
// Give the other player the ball on a foul.
- controller.Respawn(isEnemy ? Possession.Player : Possession.Enemy, reason);
+ controller.StartCoroutine(controller.Respawn(isEnemy ? Possession.Player : Possession.Enemy, reason, false));
}
}
@@ -231,9 +244,17 @@ namespace Controllers
state = State.Idle;
}
- private void Respawn(Possession possession, string message)
+ private void ParticleEffect(bool threePts, Hoop hoop)
+ {
+ var vfx = Instantiate(threePts ? threePointVFX : twoPointVFX);
+ vfx.transform.position = hoop.transform.position;
+ }
+
+ private IEnumerator Respawn(Possession possession, string message, bool wait = true)
{
BallDropped();
+
+ yield return new WaitForSeconds(wait ? 0.5f : 0f); // Wait a slight bit before respawning so they can see the VFXs.
PlayerSpawnPoints.body.transform.position = new Vector3(PlayerSpawnPoints.character.position.x, PlayerSpawnPoints.character.position.y, PlayerSpawnPoints.body.transform.position.y);
PlayerSpawnPoints.body.GetComponent<Rigidbody2D>().velocity = Vector2.zero;