Пример #1
0
    private void UploadScore()
    {
        if (nameInput.text == null || nameInput.text == string.Empty)
        {
            ShowResponseMessage(errorMessageEmptyInput, errorMessageColor);
            return;
        }

        if (_uploaded)
        {
            ShowResponseMessage(errorMessageScoreAlreadyUploaded, errorMessageColor);
            return;
        }

        bool success = highscoreTable.AddHighScoreEntry(scoreManager.GetScore(), nameInput.text);

        if (success)
        {
            _uploaded = true;
            ShowResponseMessage(successMessageScoreUploaded, successMessageColor);
            uploadScoreButton.enabled = false;
        }
        else
        {
            ShowResponseMessage(errorMessageScoreUploaded, errorMessageColor);
        }
    }
Пример #2
0
 // Update is called once per frame
 void Update()
 {
     score = ScoreSpript.scoreValue;
     if (Ended())
     {
         endLevelUI.SetActive(true);
         highScoreTable.AddHighScoreEntry(129, playerName);
     }
 }
    private void Awake()
    {
        highScoreTable = GetComponent <HighScoreTable>();
        PlayerInfo playerInfo = GameObject.FindObjectOfType <PlayerInfo>();

        if (playerInfo != null)
        {
            Debug.Log("adding highscore");
            highScoreTable.AddHighScoreEntry(playerInfo.score, playerInfo.playerName);
        }
        else
        {
            Debug.LogError("noPlayerInfoFound", this);
        }
    }
Пример #4
0
    private void TimerCountdown()
    {
        // Minutes and Seconds
        int min = Mathf.FloorToInt(timer / 60);
        int sec = Mathf.FloorToInt(timer % 60);

        // Change time text color
        if (timer > 5)
        {
            // If a full minute(s) is left then highlight time in red
            if (sec == 0)
            {
                timeDisplay.color = new Color(1, 0, 0, 1);
            }
            else
            {
                timeDisplay.color = new Color(1, 1, 1, 1);
            }
        }
        else
        {
            // If 5 seconds are left then highlight time in red
            timeDisplay.color = new Color(1, 0, 0, 1);
        }

        // Display time in "mm:ss" format
        timeDisplay.text = min.ToString("00") + ":" + sec.ToString("00");

        timer -= Time.deltaTime;

        if (timer <= 3)
        {
            FindObjectOfType <AudioManager>().Play("TimeTicking");
        }

        // If there is no time left, then go to end screen
        if (timer <= 0)
        {
            HighScoreTable.AddHighScoreEntry(Manager.Instance.Score, Manager.Instance.Name);
            SceneManager.LoadScene(2);
        }
    }
Пример #5
0
    public void StopScore()                 // Setting HighScore
    {
        PlayerPrefs.SetInt("Score", score); // Current Score
        if (score >= 1 && !isTableUpdated)
        {
            highscoretable.AddHighScoreEntry(score);
            isTableUpdated = true;
        }

        if (PlayerPrefs.HasKey("HighScore"))         // Checking if HighScore is already present
        {
            if (score > PlayerPrefs.GetInt("HighScore"))
            {
                PlayerPrefs.SetInt("HighScore", score);
            }
        }
        else
        {
            PlayerPrefs.SetInt("HighScore", score);
        }
    }