Beispiel #1
0
    async Task ShowLeaderboard()
    {
        List <GlobalstatsIO_LeaderboardValue> entries = new List <GlobalstatsIO_LeaderboardValue> ();

        for (int i = 0; i < 10; i++)
        {
            entries.Add(new GlobalstatsIO_LeaderboardValue {
                rank = (i + 1).ToString(), name = "LD45", value = "9999999"
            });
        }

        Debug.Log("LB DATA" + lb.data.Length);

        for (int i = 0; i < lb.data.Length; i++)
        {
            GlobalstatsIO_LeaderboardValue data = lb.data [i];

            entries [i] = data;
        }

        for (int i = 0; i < entries.Count; i++)
        {
            LeaderRow lr = Leaderboard.transform.GetChild(i).GetComponent <LeaderRow> ();

            GlobalstatsIO_LeaderboardValue entry = entries [i];

            lr.Rank.text = entry.rank;
            lr.Name.text = entry.name;

            float secondsFloat = 0;

            float.TryParse(entry.value, out secondsFloat);

            secondsFloat = secondsFloat / 1000f;

            int seconds = Mathf.RoundToInt(secondsFloat);

            int minutes = Mathf.RoundToInt(secondsFloat / 60f);

            int secondsRemaining = seconds % 60;

            lr.Time.text = minutes + " : " + secondsRemaining;
        }

        GameOverScreen.SetActive(true);

        allowGameOverQuit = false;
        Invoke("AllowGameOver", 3f);
    }
Beispiel #2
0
    public LeaderboardEntry(GlobalstatsIO_LeaderboardValue leaderboardValue)
    {
        this.name  = leaderboardValue.name;
        this.Rank  = Int32.Parse(leaderboardValue.rank);
        this.score = Int32.Parse(leaderboardValue.value);


        foreach (GlobalstatsIO_Additional additional in leaderboardValue.additionals)
        {
            if (additional.key == "graph")
            {
                this.graph = TspLoader.Instance.GetTspNameById(Int32.Parse(additional.value));
            }
            else if (additional.key == "algo")
            {
                this.algo = PlatformGeneratorLoader.GetGenNameById(Int32.Parse(additional.value));
            }
            else if (additional.key == "distance")
            {
                this.distance = Single.Parse(additional.value);
            }
        }
    }