private void Update() { if (PlayerResources.GetPlayerHealth() >= 0) { hearts.sprite = heartSprites[PlayerResources.GetPlayerHealth()]; //Currently in Update. There were issues with the function below, so for now, it's done here. //TODO: this. } }
private void Update() { if (PlayerResources.GetPlayerHealth() < 1) { mainCamera.transform.position = new Vector3(0.0f, 300.0f, 0.0f); //Sets the position and rotation of the camera to be away from the map. mainCamera.transform.rotation = Quaternion.Euler(0.0f, 0.0f, 0.0f); gameCanvas.enabled = false; //Changes canvas being used. gameOverCanvas.enabled = true; string minutes = ((int)(timeSurvived / 60)).ToString(); string seconds = ((int)(timeSurvived % 60)).ToString(); scoreText.text = "You lasted " + minutes + " minutes, " + seconds + " seconds"; gameOver = true; } else { timeSurvived += Time.deltaTime; //Game is not over, so update the timeSurvived timer. } }