public void UpdateBestScore() { scoreText.text = PlayerPrefController.GetHighScore().ToString(); int bestTime = PlayerPrefController.GetBestTime(); int minutes = (int)(bestTime / 60) % 60; int seconds = (int)bestTime % 60; timeText.text = string.Format("{00:00}:{01:00}", minutes, seconds); }
public void GameOver() { // Calculate score for this particular run and add it to the existing score int waveMultiplier = 1 + (1 / currentWave); score += (int)currentTime * waveMultiplier; // Compare score & time to current (local) high score & time if (score >= PlayerPrefController.GetHighScore()) { PlayerPrefController.SetHighScore(score); } if (Time.timeSinceLevelLoad > PlayerPrefController.GetBestTime()) { PlayerPrefController.SetBestTime((int)Time.timeSinceLevelLoad); } playerLost = true; // If the current run time was better than the last attempt (or it is run #1), player can continue if (kinGeneration > 1 && currentTime < lastKinTime) { kinAvailable = false; } else { kinAvailable = true; } lastKinTime = currentTime; // Fixing bug with camera getting stuck mid-shake if (cameraShake.shakeAmount > 0) { cameraShake.shakeAmount = 0; //cameraShake.ShakeCamera (); } playerStats.skillPoints = currentWave - 1; ResetGameGrid(); uiController.ShowGameOverScreen(kinAvailable); }