/// <summary> /// Reads the get score tables response. /// </summary> /// <param name='response'> /// The response. /// </param> void ReadGetTablesResponse(string response) { GJTable[] tables; bool success = GJAPI.Instance.IsResponseSuccessful(response); if (!success) { GJAPI.Instance.GJDebug("Could not fetch score tables.\n" + response, LogType.Error); tables = null; } else { Dictionary <string, string>[] dictionaries = GJAPI.Instance.ResponseToDictionaries(response); GJAPI.Instance.CleanDictionaries(ref dictionaries); StringBuilder debug = new StringBuilder(); debug.Append("Score Tables successfully fetched.\n"); int count = dictionaries.Length; tables = new GJTable [count]; for (int i = 0; i < count; i++) { tables [i] = new GJTable(dictionaries [i]); debug.Append(tables [i].ToString()); } GJAPI.Instance.GJDebug(debug.ToString()); } if (GetTablesCallback != null) { GetTablesCallback(tables); } }
/// <summary> /// Called when processing new data. /// </summary> public void LeaderboardProcessData(string boardName, string text, int score) { GJTable table = null; for (int i = 0; i < mScores.Length; i++) { if (mScores[i].Name == boardName) { table = mScores[i]; break; } } if (table != null) { mState = State.Busy; if (mIsGuest) { GJAPI.Scores.AddForGuest(text, (uint)score, "Guest", table.Id); } else { GJAPI.Scores.Add(text, (uint)score, table.Id); } } }
/// <summary> /// Reads the get score tables response. /// </summary> /// <param name='response'> /// The response. /// </param> void ReadGetTablesResponse(string response) { GJTable[] tables; bool success = GJAPI.Instance.IsResponseSuccessful (response); if (!success) { GJAPI.Instance.GJDebug ("Could not fetch score tables.\n" + response, LogType.Error); tables = null; } else { Dictionary<string,string>[] dictionaries = GJAPI.Instance.ResponseToDictionaries (response); GJAPI.Instance.CleanDictionaries (ref dictionaries); StringBuilder debug = new StringBuilder(); debug.Append ("Score Tables successfully fetched.\n"); int count = dictionaries.Length; tables = new GJTable [count]; for (int i = 0; i < count; i++) { tables [i] = new GJTable (dictionaries [i]); debug.Append (tables [i].ToString ()); } GJAPI.Instance.GJDebug (debug.ToString ()); } if (GetTablesCallback != null) { GetTablesCallback (tables); } }
/// <summary> /// GetScoreTables callback. /// </summary> /// <param name='t'> /// The tables. <seealso cref="GJTable"/>. /// </param> void OnGetScoreTables(GJTable[] t) { GJAPI.Scores.GetTablesCallback -= OnGetScoreTables; if (t == null) { SetWindowMessage ("Error loading score tables."); ChangeState (BaseWindowStates.Error.ToString ()); return; } tables = t; int count = t.Length; tablesNames = new string[count]; for (int i = 0 ; i < count ; i++) { this.tablesNames[i] = t[i].Name; } GetScores (); }