Added start countdown

Small UI changes
Fixed initialization order for the GameManager
This commit is contained in:
2020-01-31 03:40:56 +01:00
parent d127bd6477
commit 238187c30a
13 changed files with 379 additions and 20 deletions

View File

@@ -36,7 +36,7 @@ public class GameManager : MonoBehaviour
private AudioSource audioSource;
// Start is called before the first frame update
void Start()
void Awake()
{
this.players = GameObject.FindGameObjectsWithTag("Player");
this.initialPositions = new Vector3[this.players.Length];
@@ -71,14 +71,14 @@ public class GameManager : MonoBehaviour
if (this.scorePlayer1 >= maxGoals)
{
winLabel.text = "Player 1 wins the game!";
winLabel.text = "Player 1 won!";
winLabel.transform.gameObject.SetActive(true);
Time.timeScale = 0.0f;
}
if (this.scorePlayer2 >= maxGoals)
{
winLabel.text = "Player 2 wins the game!";
winLabel.text = "Player 2 won!";
winLabel.transform.gameObject.SetActive(true);
Time.timeScale = 0.0f;
}
@@ -110,4 +110,12 @@ public class GameManager : MonoBehaviour
this.ball.GetComponent<Rigidbody>().velocity = Vector3.zero;
}
public void LockControls(float duration)
{
for (int i = 0; i < this.players.Length; i++)
{
this.players[i].GetComponent<PlayerController>().InputTimeout(duration);
}
}
}