Example #1
0
    public void SubmitNewPlayerScore(string playerNameText, int newScore)
    {
        HighScorePlayerData newData = new HighScorePlayerData();

        newData.playerName = playerNameText;
        newData.score      = newScore;


        GameObject.Find("server").GetComponent <SocketIOComponent>().Emit("sendHighScoreData", new JSONObject(JsonUtility.ToJson(newData)));

        // If newScore is greater than playerProgress.highestScore, update playerProgress with the new value and call SavePlayerProgress()
        if (newScore > playerProgress.highestScore)
        {
            playerProgress.highestScore = newScore;
            SavePlayerProgress();
        }
    }
Example #2
0
    public void SubmitButton()
    {
        HighScorePlayerData newScore = new HighScorePlayerData();

        newScore.playerName = playerNameText.text;
        newScore.score      = playerScore;

        if (dataController.nonBrokenList.Count >= 10 && playerScore > dataController.nonBrokenList[9].score)
        {
            dataController.nonBrokenList.RemoveAt(9);
            dataController.nonBrokenList.Add(newScore);

            dataController.nonBrokenList.Sort((p1, p2) => p2.score.CompareTo(p2.score));

            /*Array.Sort(dataController.allHighScoreData.HighScorePlayerData, delegate (HighScorePlayerData player1, HighScorePlayerData player2)
             * {
             *  return (player2.score).CompareTo((player1.score));
             * });*/
        }
        else if (dataController.nonBrokenList.Count < 10)
        {
            dataController.nonBrokenList.Add(newScore);

            /*Array.Sort(dataController.allHighScoreData.HighScorePlayerData, delegate (HighScorePlayerData player1, HighScorePlayerData player2)
             * {
             *
             *
             *  return (player2.score).CompareTo((player1.score));
             * });*/

            dataController.nonBrokenList.Sort((p1, p2) => p2.score.CompareTo(p2.score));
        }
        //dataController.allHighScoreData

        dataController.SubmitNewPlayerScore(playerNameText.text, playerScore);
        EndRound();
    }