コード例 #1
0
    void FormatHighscores(string textStream)
    {
        string[] entries = textStream.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries);
        highscoresList = new Highscore1[entries.Length];

        for (int i = 0; i < entries.Length; i++)
        {
            string[] entryInfo = entries[i].Split(new char[] { '|' });
            string   username  = entryInfo[0];
            int      score     = int.Parse(entryInfo[1]);
            highscoresList[i] = new Highscore1(username, score);
            print(highscoresList[i].username + ": " + highscoresList[i].score);
        }
    }
コード例 #2
0
    public void upisiUHighscore()
    {
        if (score > h1.score)
        {
            h5 = h4;
            h4 = h3;
            h3 = h2;
            h2 = h1;

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

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

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

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


        Highscore1[] niz = new Highscore1[5] {
            h1, h2, h3, h4, h5
        };
        highscore = JsonMapper.ToJson(niz);
        File.WriteAllText(Application.dataPath + "/Resursi/Highscore.json", highscore.ToString());
    }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        score = 0;

        lights = FindObjectsOfType(typeof(Light)) as Light[];
        foreach (Light light in lights)
        {
            light.intensity = 0;
        }

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

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

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

        h1 = new Highscore1((int)podaci[0]["id"], (string)podaci[0]["username"], (int)podaci[0]["score"]);
        h2 = new Highscore1((int)podaci[1]["id"], (string)podaci[1]["username"], (int)podaci[1]["score"]);
        h3 = new Highscore1((int)podaci[2]["id"], (string)podaci[2]["username"], (int)podaci[2]["score"]);
        h4 = new Highscore1((int)podaci[3]["id"], (string)podaci[3]["username"], (int)podaci[3]["score"]);
        h5 = new Highscore1((int)podaci[4]["id"], (string)podaci[4]["username"], (int)podaci[4]["score"]);
    }