Example #1
0
    public void SubmitScore()
    {
        if (ls == leaderboardState.leaderboard)
        {
            return;
        }
        int score = player.mantisDestroyedCount;
        int time  = (int)player.timeAlive;

        value = input.text;
        if (value.Length == 0)
        {
            return;
        }
        submitScore.interactable = false;
        input.interactable       = false;
        dl.AddScore(value, score, time);
        restartOnLoad = true;
        ls            = leaderboardState.leaderboard;
        Debug.Log("Submitted score " + score + " as " + value);
    }
Example #2
0
    void Update()
    {
        if (ls == leaderboardState.leaderboard)
        {
            List <dreamloLeaderBoard.Score> scoreList = dl.ToListHighToLow();
            if (scoreList != null && dl.highScores != lastHighScores)
            {
                foreach (dreamloLeaderBoard.Score currentScore in scoreList)
                {
                    SetScore(currentScore.playerName, currentScore.playerName, "mantis", currentScore.score);
                }
                lastHighScores = dl.highScores;
                ls             = leaderboardState.done;
                if (loading)
                {
                    loading = false;
                    foreach (Text text in entries)
                    {
                        text.text = "";
                    }
                }
                if (restartOnLoad)
                {
                    Debug.Log("highscore string: " + lastHighScores);
                    SceneManager.LoadScene(SceneManager.GetActiveScene().name);
                }
            }
        }

        if (player.gameOver || lastHighestmantis == player.mantisDestroyedCount || ls == leaderboardState.leaderboard)
        {
            return;
        }
        lastHighestmantis = player.mantisDestroyedCount;
        SetScore(youUserID, "you", "mantis", player.mantisDestroyedCount);
        string[] userIds     = GetUserIDs("mantis");
        int      playerIndex = System.Array.IndexOf(userIds, youUserID);

        int iterations = Mathf.Min(entries.Length, userIds.Length);

        //entries [entries.Length - 1].text = (2 + playerIndex) + ". " + " you / " + player.highestMass;
        if (playerIndex + iterations + 1 > userIds.Length)
        {
            playerIndex = userIds.Length - iterations;
        }
        else
        {
            playerIndex -= iterations / 2;
        }

        if (playerIndex < 0)
        {
            playerIndex = 0;
        }

        for (int i = 0; i < iterations; i++)
        {
            string curUserId = userIds [playerIndex + i];
            entries [i].text  = (playerIndex + 1 + i) + ". " + (curUserId == youUserID ? "you" : curUserId) + " / " + GetScore(curUserId, "mantis");
            entries [i].color = (curUserId == youUserID ? playerColour : Color.black);
        }
    }
Example #3
0
 public void LoadLeaderboard()
 {
     dl.LoadScores();
     ls = leaderboardState.leaderboard;
 }