private void Update() { playerHealthPoints = player.GetHealthPoints(); playerLives = player.GetNumberOfLives(); gameOver = player.GetGameOver(); healthSlider.value = playerHealthPoints; livesText.text = "Lives: " + playerLives.ToString(); if (gameOver) { gameOverText.gameObject.SetActive(true); //Time.timeScale = 0; } playerFinishGame = finish.GetPlayerFinished(); if (playerFinishGame) { slowSpeedButton.gameObject.SetActive(false); normalSpeedButton.gameObject.SetActive(false); fastSpeedButton.gameObject.SetActive(false); jumpButton.gameObject.SetActive(false); resumeButton.interactable = false; } if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } }
private void Update() { SensorCurrentPosition(); playerFinishedGame = finish.GetPlayerFinished(); if (playerFinishedGame) { playerSpeed -= Time.deltaTime * 2; if (playerSpeed <= 0.0f) { playerSpeed = 0.0f; } } transform.Translate(Vector3.right * playerSpeed * Time.deltaTime); if (healthPoints >= 100) { healthPoints = 100; } if (healthPoints <= 0) { healthPoints = 100; numberOfLives = numberOfLives - 1; } if (numberOfLives == 0) { gameOver = true; gameOverSensor.SetActive(true); } if (gameOver) { playerRigidbody.constraints = RigidbodyConstraints.FreezeAll; playerSpeed = 0; } // Music PlayGameSounds(); //TestingButtons(); }