private void showTopTenPlayers() { float delayRow = 0; float minus = 0; // Get the top 10 players of the game GamedoniaUsers.Search("{}", 10, "{profile.wonAttr:-1}", 0, delegate(bool success, IList data) { if (success) { if (data != null) { for (int i = 0; i < data.Count; i++) { Dictionary <string, object> resultUser = (Dictionary <string, object>)data[i]; Dictionary <string, object> resultProfile = (Dictionary <string, object>)resultUser["profile"]; if (i == 0) { if (resultUser["_id"].ToString() == PlayerManager.I.player.playerID) { AchievementManager.I.EarnAchievement("Kampioen"); } avatarWon.GetComponent <buildAvatar>().setCustomAvatarByString(resultProfile["avatar"].ToString()); avatarWon.SetActive(true); avatarWon.transform.DOScale(30, 2).SetEase(Ease.OutExpo).SetDelay(1); } GameObject row = gameObject.transform.GetChild(i).gameObject; row.SetActive(true); if (i <= 2) { row.transform.GetChild(5).GetComponent <Text>().text = resultProfile["wonAttr"].ToString(); row.GetComponent <RectTransform> ().DOScale(1.2f - minus, .5f).SetEase(Ease.InFlash).SetDelay(delayRow); row.GetComponent <RectTransform> ().DOScale(1, 1f).SetEase(Ease.OutExpo).SetDelay((.5f + delayRow)); delayRow += .2f; minus += 0.05f; } else { row.transform.GetChild(6).GetComponent <Text>().text = resultProfile["wonAttr"].ToString(); } row.transform.GetChild(0).GetComponent <Image>().sprite = PlayerManager.I.GetRankSprite(int.Parse(resultProfile["lvl"].ToString())); row.transform.GetChild(1).GetComponent <Text>().text = resultProfile["name"].ToString(); // } } } else { } }); }
private void checkAvailableName() { searchComplete = false; string checkName = p_name.text; if (LoggedInUser.profile ["name"].ToString() != checkName) { GamedoniaUsers.Search("{\"profile.name\":'" + checkName + "'}", delegate(bool success, IList data) { if (success) { if (data != null && data.Count > 0) { nameIsAvailable = false; Response.SetActive(true); searchComplete = true; Debug.Log("name found"); } else { nameIsAvailable = true; Response.SetActive(false); searchComplete = true; Debug.Log("name not found"); } } else { Response.SetActive(false); nameIsAvailable = false; searchComplete = true; Debug.Log("no success"); } }); } else { nameIsAvailable = true; searchComplete = true; Response.SetActive(false); } }
public void searchForFriends() { if (friendSearcher.text != "") { string friendcode = friendSearcher.text; GamedoniaUsers.Search("{\"profile.name\":\"" + friendcode + "\"}", delegate(bool success, IList data) { if (success) { if (data != null) { if (PlayerPrefs.GetInt("Vrienden worden?") == 0) { AchievementManager.I.wantToBeFriends(); } Dictionary <string, object> userData = (Dictionary <string, object>)data[0]; string id = userData["_id"].ToString(); if (!PlayerManager.I.friends.ContainsKey(id)) { PlayerManager.I.AddFriend(id); StartCoroutine(setFriendInformationAfterTime(1f, id)); } else { responseText.text = "Je hebt " + friendcode + " al als vriend"; StartCoroutine(showResponse(2f)); } } else { responseText.text = "Vriend niet gevonden, probeer het nogmaals"; StartCoroutine(showResponse(2f)); } } }); } }