Example #1
0
    private void FetchLeaderBoardData()
    {
        LeaderBoardData = new List <LeaderLine>();
        string data = getLeaderBoard();

        string[] data_list = data.Split('\n');
        //Debug.Log("Fetching Leaderboard");
        foreach (var line in data_list)
        {
            if (line == "")
            {
                break;
            }
            string[]   line_list = line.Split('\t');
            LeaderLine newline   = new LeaderLine(line_list[0], line_list[1], line_list[2]);
            LeaderBoardData.Add(newline);
            // Debug.Log(line_list[0]);
            // Debug.Log(line_list[1]);
            // Debug.Log(line_list[2]);
        }
        LeaderLine head = new LeaderLine("zsj", "history", "10");
        LeaderLine a    = new LeaderLine("gsg", "geography", "100");

        LeaderBoardData.Add(head);
        LeaderBoardData.Add(a);
    }
 public static dynamic GetTSObject(LeaderLine dynObject)
 {
     if (dynObject is null)
     {
         return(null);
     }
     return(dynObject.teklaObject);
 }
Example #3
0
    public int compare(LeaderLine a, LeaderLine b)
    {
        int result = 0;

        if (a.score > b.score)
        {
            result = -1;
        }
        else if (a.score < b.score)
        {
            result = 1;
        }
        return(result);
    }
Example #4
0
    public void UpdateLeaderBoard(string newName, int newScore)
    {
        LeaderLine temp = new LeaderLine();

        temp.name  = newName;
        temp.score = newScore;
        leaderBoard.Add(temp);
        leaderBoard.Sort(compare);
        leaderBoard.RemoveAt(leaderBoard.Count - 1);
        for (int i = 0; i < LEADER_BOARD_MAX; ++i)
        {
            PlayerPrefs.SetString("name" + i, leaderBoard[i].name);
            PlayerPrefs.SetInt("score" + i, leaderBoard[i].score);
        }
        PlayerPrefs.Save();
    }
Example #5
0
    // Use this for initialization
    void Start()
    {
        for (int i = 0; i < LEADER_BOARD_MAX; ++i)
        {
            LeaderLine temp = new LeaderLine();
            temp.name  = PlayerPrefs.GetString("name" + i);
            temp.score = PlayerPrefs.GetInt("score" + i);
            if (temp.name.Equals(""))
            {
                temp.score = -1;
            }
            leaderBoard.Add(temp);
        }

        hasInit = true;
    }