private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.GetComponent <Ball>()) { if (gameMode.GetBallsCount() <= 1) { playerStats.ReduceLife(); if (playerStats.GetLivesLeft() <= 0) { // Destroy(playerStats); SceneManager.LoadScene("Game Over"); // playerStats.Reset(); } else { gameMode.hasStarted = false; gameMode.SpawnBall(); } } Destroy(collision.gameObject); gameMode.RemoveBall(); } }
private void Start() { playerStatsHandler = FindObjectOfType <PlayerStatsHandler>(); playerScore.text = playerStatsHandler.GetScore().ToString(); livesText.text = playerStatsHandler.GetLivesLeft().ToString(); }
void Update() { playerScore.text = playerStatsHandler.GetScore().ToString(); livesText.text = playerStatsHandler.GetLivesLeft().ToString(); }