void AddFriendsEntries(FirebaseDataManager.Profile s) { Debug.Log("ADDFRIENDS---------" + s.username + "; " + s.uid); entriesToAdd.Add(new entryToAdd() { name = s.username, uid = s.uid }); }
void AddFriendsEntries(FirebaseDataManager.Profile s) { //Debug.Log(s.name + "; " + s.score + "; " + s.uid); entriesToAdd.Add(new entryToAdd() { name = s.username, uid = s.uid }); }
void AddFriends(FirebaseDataManager.Profile entries) { int i = -1; foreach (var s in entries.nemeses) { i++; FirebaseDataManager.fdm.ReadProfile(s.uid, AddFriendsEntries); } }
private void RetrieveValues(FirebaseDataManager.Profile p) { Debug.Log("Setting own profile data: " + p.ToString()); p_name = p.username; p_won = p.games_won; p_lost = p.games_lost; p_played = p_won + p_lost; p_ratio = (float)p_won / (float)p_played; if (float.IsNaN(p_ratio)) { p_ratio = 0.0f; } p_ratio *= 1000f; p_ratio = Mathf.Round(p_ratio); p_ratio /= 10f; if (p.nemeses.Count == 0) { updated = true; p_rival = ""; return; } //FirebaseDataManager.ComputeNemesisScore(p, SetRivalData); List <Tuple <int, FirebaseDataManager.Profile.NemesisEntry> > nemeses = new List <Tuple <int, FirebaseDataManager.Profile.NemesisEntry> >(); foreach (var ne in p.nemeses) { int nScore = FirebaseDataManager.ComputeNemesisScore(p, ne); nemeses.Add(new Tuple <int, FirebaseDataManager.Profile.NemesisEntry>(nScore, ne)); Debug.Log("Found Nemesis: " + ne.uid + "; " + nScore); } nemeses.Sort(CompareNemesisEntries); Tuple <int, FirebaseDataManager.Profile.NemesisEntry> rival = nemeses[0]; p_nscore = rival.Item1; p_nplayed = rival.Item2.lost_against + rival.Item2.won_against; p_nratio = (float)rival.Item2.won_against / (float)p_nplayed; if (float.IsNaN(p_nratio)) { p_nratio = 0.0f; } p_nratio *= 1000f; p_nratio = Mathf.Round(p_nratio); p_nratio /= 10f; FirebaseDataManager.fdm.ReadProfile(rival.Item2.uid, SetRivalName); }
void AddFriends(FirebaseDataManager.Profile entries) { int i = -1; foreach (var s in entries.friends) { i++; Debug.Log("FriendUID: " + s); FirebaseDataManager.fdm.ReadProfile(s, AddFriendsEntries); } }
public void setNemText(FirebaseDataManager.Profile e, FirebaseDataManager.SocialGraph graph) { foreach (var s in e.nemeses) { if (s.uid == p_uid) { float dist = graph.GetDistanceBetween(e.uid, s.uid, 3); score = FirebaseDataManager.ComputeNemesisScore_Main(e, s, dist); Debug.Log("Score: " + score); } } if (score >= 0) { text_NemesisScoreText.text = "Nemesis: " + score; } else { text_NemesisScoreText.text = "No Nemesis."; } }
void AddNemesisWithGraph(FirebaseDataManager.Profile entry, FirebaseDataManager.SocialGraph graph) { Debug.Log(graph); computing = true; int i = -1; foreach (var s in entry.nemeses) { i++; float dist = graph.GetDistanceBetween(entry.uid, s.uid, 3); print(dist); FirebaseDataManager.fdm.ReadProfile(s.uid, AddNemesesEntries); wl.Add(new WL() { lost_against = s.lost_against, won_against = s.won_against, score = FirebaseDataManager.ComputeNemesisScore_Main(entry, s, dist), }); } sort_(wl, entriesToAdd); }
void AddNemesis(FirebaseDataManager.Profile entry) { //Debug.Log("Load Nemesis!"); //Get Social Graph FirebaseDataManager.ComputeSocialGraph(entry, AddNemesisWithGraph); /* * int i = -1; * * foreach (var s in entry.nemeses) * { * i++; * FirebaseDataManager.fdm.ReadProfile(s.uid, AddNemesesEntries); * wl.Add(new WL() * { * lost_against = s.lost_against, * won_against = s.won_against, * score = FirebaseDataManager.ComputeNemesisScore(entry, s), * }); * } * sort_(wl, entriesToAdd);*/ }
private void SetRivalName(FirebaseDataManager.Profile r) { p_rival = r.username; updated = true; }
public void SetRivalData(FirebaseDataManager.Profile p, List <Tuple <int, FirebaseDataManager.Profile.NemesisEntry> > nemeses) { }
public void Update1(FirebaseDataManager.Profile p) { GP.text = (p.games_lost + p.games_won).ToString(); GW.text = p.games_won.ToString(); GL.text = p.games_lost.ToString(); }
public void setNemText1(FirebaseDataManager.Profile e) { FirebaseDataManager.ComputeSocialGraph(e, setNemText); }
private void RetrieveValues(FirebaseDataManager.Profile p) { Debug.Log("Setting own profile data: " + p.ToString()); p_name = p.username; p_uid = p.uid; p_won = p.games_won; p_lost = p.games_lost; p_played = p_won + p_lost; p_ratio = (float)p_won / (float)p_played; if (float.IsNaN(p_ratio)) { p_ratio = 0.0f; } p_ratio *= 1000f; p_ratio = Mathf.Round(p_ratio); p_ratio /= 10f; string temp = FirebaseAuth.DefaultInstance.CurrentUser.UserId; try { if (!p.friends.Contains(temp)) { Debug.Log("Setting Friend Button to ADD"); button_addFriend_vh.value = p.uid; button_addFriend_vh.value2 = temp; setButtonValuesDelayed = 1; button_addFriend.interactable = true; button_addFriend.onClick.RemoveAllListeners(); button_addFriend.onClick.AddListener(() => { Debug.Log("Hi"); FirebaseDataManager.fdm.AddFriend(button_addFriend_vh.value, button_addFriend_vh.value2); UpdateValues(p.uid); setButtonValuesDelayed = 2; }); } else { Debug.Log("Setting Friend button to REMOVE"); button_addFriend_vh.value = p.uid; button_addFriend_vh.value2 = temp; setButtonValuesDelayed = 2; button_addFriend.interactable = true; button_addFriend.onClick.RemoveAllListeners(); button_addFriend.onClick.AddListener(() => { Debug.Log("Bye"); FirebaseDataManager.fdm.RemoveFriend(button_addFriend_vh.value, button_addFriend_vh.value2); UpdateValues(p.uid); setButtonValuesDelayed = 1; }); } } catch (Exception e) { Debug.LogError(e); } if (p.nemeses.Count == 0) { updated = true; p_rival = ""; //return; } updated = true; //FirebaseDataManager.ComputeNemesisScore(p, SetRivalData); }