Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        score = System.Convert.ToInt32(PlayerPrefs.GetString("Score"));

        PlayerPrefs.SetString("Bodovi staze", "" + bodoviStaze);

        JsonString = File.ReadAllText(Application.dataPath + "/Resursi/highscore.json");
        podaci     = JsonMapper.ToObject(JsonString);

        preostaloVrijeme = double.Parse(PlayerPrefs.GetString("Preostalo vrijeme"));

        h1 = new Highscore4((int)podaci[0]["id"], (string)podaci[0]["username"], (int)podaci[0]["score"]);
        h2 = new Highscore4((int)podaci[1]["id"], (string)podaci[1]["username"], (int)podaci[1]["score"]);
        h3 = new Highscore4((int)podaci[2]["id"], (string)podaci[2]["username"], (int)podaci[2]["score"]);
        h4 = new Highscore4((int)podaci[3]["id"], (string)podaci[3]["username"], (int)podaci[3]["score"]);
        h5 = new Highscore4((int)podaci[4]["id"], (string)podaci[4]["username"], (int)podaci[4]["score"]);
    }
Beispiel #2
0
    public void upisiUHighscore()
    {
        if (score > h1.score)
        {
            h5 = h4;
            h4 = h3;
            h3 = h2;
            h2 = h1;

            h1 = new Highscore4(0, PlayerPrefs.GetString("Username"), score);
        }
        else if (score > h2.score)
        {
            h5 = h4;
            h4 = h3;
            h3 = h2;

            h2 = new Highscore4(1, PlayerPrefs.GetString("Username"), score);
        }
        else if (score > h3.score)
        {
            h5 = h4;
            h4 = h3;

            h3 = new Highscore4(2, PlayerPrefs.GetString("Username"), score);
        }
        else if (score > h4.score)
        {
            h5 = h4;

            h4 = new Highscore4(3, PlayerPrefs.GetString("Username"), score);
        }
        else if (score > h5.score)
        {
            h5 = new Highscore4(4, PlayerPrefs.GetString("Username"), score);
        }


        Highscore4[] niz = new Highscore4[5] {
            h1, h2, h3, h4, h5
        };
        highscore = JsonMapper.ToJson(niz);
        File.WriteAllText(Application.dataPath + "/Resursi/Highscore.json", highscore.ToString());
    }