public static void StartGame(this Pool pool) { pool.SetScreen(new Vector2(10f, 9f)); pool.SetLife(3); pool.CreatePlayerEnergy(); var player = pool.CreatePlayer(); pool.CreateShield(player); pool.SetMapSpeed(new Vector2(0f, -0.01f)); pool.CreateMapBackground(3f, 0); pool.CreateMapBackground(11f); pool.CreateMapBackground(19f); LeaderBoardController.GetHighScores(5, highScores => { int lowestTopValue = 999999999; for (int i = 0; i < 5; ++i) { if (highScores.Length >= i + 1) { if (highScores[i].score != 0 && highScores[i].score < lowestTopValue) { lowestTopValue = highScores[i].score; } } } pool.ReplaceLowestScoreLeaderboard(lowestTopValue); }, ex => pool.ReplaceLowestScoreLeaderboard(0)); }
void RefreshLeaderboard(GameObject obj) { LeaderBoardController.GetHighScores(5, highScores => { string highScoreValues = ""; for (int i = 0; i < 5; ++i) { if (highScoreValues != "") { highScoreValues += "\n"; } var scoreUserName = "******"; var scoreValue = 0; if (highScores.Length >= i + 1) { if (!string.IsNullOrEmpty(highScores[i].userName)) { scoreUserName = highScores[i].userName.Substring(0, Mathf.Min(highScores[i].userName.Length, 3)); } scoreValue = highScores[i].score; } highScoreValues += string.Format("{0} {1} {2}", (i + 1), scoreUserName.PadRight(3, ' ').ToUpper(), scoreValue.ToString().PadLeft(8, '0')); } obj.transform.Find("HighScores").GetComponent <GUIText>().text = highScoreValues; }, ex => { obj.transform.Find("HighScores").GetComponent <GUIText>().text = "Leaderboard:\n\nWeb connection\nis required"; }); }