public void UpdateTournamentLeaders(PlanetVO planetVO, LeaderboardController.OnUpdateData callback) { if (planetVO == null) { Service.Logger.Error("Tournament leaderboard requested without setting planetVO"); return; } PlayerLeaderboardRequest request = new PlayerLeaderboardRequest(planetVO.Uid, Service.CurrentPlayer.PlayerId); LeaderboardList <PlayerLBEntity> leaderboardList = null; LeaderboardList <PlayerLBEntity> value = null; this.GetPlayerLists(PlayerListType.TournamentLeaders, planetVO.Uid, out leaderboardList, out value); Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary["callback"] = callback; dictionary["list"] = leaderboardList; dictionary["listnearby"] = value; GetTournamentLeaderboardPlayersCommand getTournamentLeaderboardPlayersCommand = new GetTournamentLeaderboardPlayersCommand(request); getTournamentLeaderboardPlayersCommand.Context = dictionary; getTournamentLeaderboardPlayersCommand.AddSuccessCallback(new AbstractCommand <PlayerLeaderboardRequest, LeaderboardResponse> .OnSuccessCallback(this.OnLeadersUpdated)); getTournamentLeaderboardPlayersCommand.AddFailureCallback(new AbstractCommand <PlayerLeaderboardRequest, LeaderboardResponse> .OnFailureCallback(this.OnLeadersUpdateFailure)); Service.ServerAPI.Sync(getTournamentLeaderboardPlayersCommand); leaderboardList.LastRefreshTime = Service.ServerAPI.ServerTime; }
public void InitLeaderBoardListForPlanet() { List <PlanetVO> allPlayerFacingPlanets = PlanetUtils.GetAllPlayerFacingPlanets(); for (int i = 0; i < allPlayerFacingPlanets.Count; i++) { string uid = allPlayerFacingPlanets[i].Uid; LeaderboardList <PlayerLBEntity> value = new LeaderboardList <PlayerLBEntity>(); this.LeadersByPlanet.Add(uid, value); value = new LeaderboardList <PlayerLBEntity>(); this.LeadersNearMeByPlanet.Add(uid, value); } List <TournamentVO> allLiveAndClosingTournaments = TournamentController.GetAllLiveAndClosingTournaments(); int j = 0; int count = allLiveAndClosingTournaments.Count; while (j < count) { string planetId = allLiveAndClosingTournaments[j].PlanetId; if (this.TournamentLeadersByPlanet.ContainsKey(planetId)) { Service.Logger.Error("Multiple tournaments are active on planet " + planetId); } else { this.InitTournamentListForPlanet(planetId); } j++; } }
private void OnTimerCallbackTop50(uint id, object cookie) { TweenAlpha.Begin(this.scrollView.transform.gameObject, 0.5f, 1f); this.top50Button.Enabled = false; this.findMeButton.Enabled = this.EnableFindMeButton(); string selectedPlanetId = this.planetSelectionDropDown.GetSelectedPlanetId(); LeaderboardList <PlayerLBEntity> leaderboardList = null; if (this.curTab == SocialTabs.Squads) { base.AddItemsToGrid <Squad>(Service.Get <LeaderboardController>().TopSquads.List, true, true); return; } if (this.curTab == SocialTabs.Leaders) { if (selectedPlanetId == null) { leaderboardList = Service.Get <LeaderboardController>().GlobalLeaders; } else { leaderboardList = Service.Get <LeaderboardController>().LeadersByPlanet[selectedPlanetId]; } } else if (this.curTab == SocialTabs.Tournament) { leaderboardList = Service.Get <LeaderboardController>().TournamentLeadersByPlanet[selectedPlanetId]; } if (leaderboardList != null) { base.AddItemsToGrid <PlayerLBEntity>(leaderboardList.List, true, true); base.PositionScrollViewForTop50(); } }
public void PopulateLeaderboard(JArray listofEntries) { if (listofEntries != null) { LeaderboardList.AddRange(listofEntries.ToObject <List <LeaderboardEntry> >()); } }
private void OnTopPlayerSuccess(bool success) { if (!success) { Service.EventManager.SendEvent(EventId.HolonetLeaderBoardUpdated, null); return; } this.topPlayers.Clear(); CurrentPlayer currentPlayer = Service.CurrentPlayer; if (this.LeadersByPlanet.ContainsKey(currentPlayer.PlanetId) && this.LeadersByPlanet[currentPlayer.PlanetId].List.Count >= 0) { LeaderboardList <PlayerLBEntity> leaderboardList = this.LeadersByPlanet[currentPlayer.PlanetId]; if (leaderboardList.List.Count > 0) { this.topPlayers.Add(leaderboardList.List[0]); int i = 0; int count = leaderboardList.List.Count; while (i < count) { if (this.topPlayers.Count >= 2) { break; } if (leaderboardList.List[i].Faction != this.topPlayers[0].Faction) { this.topPlayers.Add(leaderboardList.List[i]); } i++; } } } Service.EventManager.SendEvent(EventId.HolonetLeaderBoardUpdated, null); }
private void InitTournamentListForPlanet(string planetUid) { LeaderboardList <PlayerLBEntity> value = new LeaderboardList <PlayerLBEntity>(); this.TournamentLeadersByPlanet.Add(planetUid, value); value = new LeaderboardList <PlayerLBEntity>(); this.TournamentLeadersNearMeByPlanet.Add(planetUid, value); }
private void OnLeadersUpdated(LeaderboardResponse response, object cookie) { Dictionary <string, object> dictionary = (Dictionary <string, object>)cookie; LeaderboardList <PlayerLBEntity> leaderboardList = (LeaderboardList <PlayerLBEntity>)dictionary["list"]; LeaderboardList <PlayerLBEntity> leaderboardList2 = (LeaderboardList <PlayerLBEntity>)dictionary["listnearby"]; object cookie2 = dictionary["callback"]; this.ParsePlayerResponse(response.TopData, leaderboardList); this.ParsePlayerResponse(response.SurroundingData, leaderboardList2); this.FireCallbackFromCookie(cookie2, true); }
private void leaderboardresult(GetLeaderboardResult result) { Leaderboard.SetActive(true); maincanvas.SetActive(false); foreach (PlayerLeaderboardEntry player in result.Leaderboard) { GameObject templisting = Instantiate(LeaderboardListing, ListingContainer); LeaderboardList LL = templisting.GetComponent <LeaderboardList>(); LL.playername.text = player.DisplayName; LL.score.text = player.StatValue.ToString(); } }
private void OnGetLeaderboardsMetadata(string leaderboardsMetadata) { if (_OnGetLeaderboardsMetadata != null) { LeaderboardList result = JsonUtility.FromJson <LeaderboardList>(leaderboardsMetadata); _OnGetLeaderboardsMetadata(result); } else { Debug.Log("ArioGameService : OnGetLeaderboard Callback not defined!!"); } }
// Start is called before the first frame update IEnumerator RequestCorutine() { scoreBoard = this; WWW leaderboardData = new WWW("http://localhost:4433/Zickvi/leaderboards.php"); yield return(leaderboardData); if (string.IsNullOrEmpty(leaderboardData.error)) { // jsonData = leaderboardData.text; jsonData = "{" + "Leaderboard" + ":" + leaderboardData.text + "}"; //jsonData = System.Text.Encoding.UTF8.GetString(leaderboardData.bytes, 3, leaderboardData.bytes.Length - 3); } File.WriteAllText(Application.dataPath + "/Leaderboard.json ", jsonData); //string jsonString = File.ReadAllText(Application.dataPath + "/Leaderboard.json"); // Debug.Log(GetScores("uros", 12)); /* * string json = JsonUtility.ToJson(jsonString); * Debug.Log(jsonString); */ TextAsset asset = Resources.Load("Leaderboard") as TextAsset; if (asset != null) { LeaderboardList = JsonUtility.FromJson <LeaderboardList>(asset.text); foreach (Player play in LeaderboardList.leaderboard) { print(play.username); print(play.score); } } else { print("Asset is null"); } /* * Player loadedPlayerData = JsonUtility.FromJson<Player>(json); * * Debug.Log(loadedPlayerData.username); * Debug.Log(loadedPlayerData.score);*/ // Debug.Log("username" + loadedPlayerData.username); //Debug.Log("score" + loadedPlayerData.score); }
public void OnGetLeaderboardsMetadata(LeaderboardList leaderboardList) { if (leaderboardList.list.Length == 0) { textLeaderboardOne.text = "no leaderboard data found"; } else if (leaderboardList.list.Length >= 1) { LeaderboardList.Leaderboard leaderboard = leaderboardList.list[0]; textLeaderboardOne.text = "id: " + leaderboard.id + "\nname: " + leaderboard.name + "\nScoreOrder: " + (leaderboard.scoreOrder == LeaderboardList.SCORE_ORDER_LARGER_IS_BETTER ? "Larger_is_Better" : "Smaller_is_Better") + "\niconUrl:" + leaderboard.iconUrl; } if (leaderboardList.list.Length >= 2) { LeaderboardList.Leaderboard leaderboard = leaderboardList.list[1]; textLeaderboardTwo.text = "id: " + leaderboard.id + "\nname: " + leaderboard.name + "\nScoreOrder: " + (leaderboard.scoreOrder == LeaderboardList.SCORE_ORDER_LARGER_IS_BETTER ? "Larger_is_Better" : "Smaller_is_Better") + "\niconUrl:" + leaderboard.iconUrl; } }
private void OnGetLBPlayers(bool success) { if (!success) { this.OnDataUpdateFailure(); return; } if (!this.Visible) { ProcessingScreen.Hide(); return; } if (this.curTab == SocialTabs.Leaders) { LeaderboardList <PlayerLBEntity> leaderboardList = this.GetLeaderboardList(); base.OnPlayersListLoaded((leaderboardList != null) ? leaderboardList.List : null, new Action(this.PopulatePlayersOnGrid)); } }
private void LoadLeaders() { PlanetVO selectedPlanet = this.planetSelectionDropDown.GetSelectedPlanet(); string planetId = (selectedPlanet == null) ? null : selectedPlanet.Uid; ProcessingScreen.Show(); if (!Service.Get <LeaderboardController>().ShouldRefreshData(PlayerListType.Leaders, planetId)) { if (this.gridLoadHelper.IsAddedItems || this.gridLoadHelper.IsBusyAddingItems) { base.ResetGrid(); } LeaderboardList <PlayerLBEntity> leaderboardList = this.GetLeaderboardList(); base.OnPlayersListLoaded((leaderboardList != null) ? leaderboardList.List : null, new Action(this.PopulatePlayersOnGrid)); return; } base.ResetGrid(); Service.Get <LeaderboardController>().UpdateLeaders(selectedPlanet, new LeaderboardController.OnUpdateData(this.OnGetLBPlayers)); }
private void OnTimerCallbackFindMe(uint id, object cookie) { TweenAlpha.Begin(this.scrollView.transform.gameObject, 0.5f, 1f); this.top50Button.Enabled = true; this.findMeButton.Enabled = false; if (this.curTab == SocialTabs.Squads) { base.AddItemsToGrid <Squad>(Service.Get <LeaderboardController>().SquadsNearMe.List, false, true); base.PositionScrollViewForFindMe(); return; } LeaderboardList <PlayerLBEntity> leaderboardList = this.GetLeaderboardList(); if (leaderboardList != null) { base.AddItemsToGrid <PlayerLBEntity>(leaderboardList.List, false, true); base.PositionScrollViewForFindMe(); } }
private void GetPlayerLists(PlayerListType listType, string planetId, out LeaderboardList <PlayerLBEntity> leaderboardList, out LeaderboardList <PlayerLBEntity> nearbyLeaderboardList) { leaderboardList = null; nearbyLeaderboardList = null; if (listType != PlayerListType.Friends) { if (listType != PlayerListType.Leaders) { if (listType == PlayerListType.TournamentLeaders) { if (!string.IsNullOrEmpty(planetId)) { if (!this.TournamentLeadersByPlanet.ContainsKey(planetId)) { this.InitTournamentListForPlanet(planetId); } leaderboardList = this.TournamentLeadersByPlanet[planetId]; nearbyLeaderboardList = this.TournamentLeadersNearMeByPlanet[planetId]; } else { Service.Logger.Error("planetId value is null or empty in tournament leaderboard response handling"); } } } else if (planetId == null) { leaderboardList = this.GlobalLeaders; nearbyLeaderboardList = this.GlobalNearMeLeaders; } else { leaderboardList = this.LeadersByPlanet[planetId]; nearbyLeaderboardList = this.LeadersNearMeByPlanet[planetId]; } } else { leaderboardList = this.Friends; nearbyLeaderboardList = this.Friends; } }
private void ParseSquadResponse(List <object> squads, LeaderboardList <Squad> leaderboardList, bool featured, Squad currentPlayerSquad) { if (squads != null && squads.Count > 0) { leaderboardList.List.Clear(); int i = 0; int count = squads.Count; while (i < count) { Dictionary <string, object> dictionary = squads[i] as Dictionary <string, object>; if (dictionary != null) { string text = null; if (dictionary.ContainsKey("_id")) { text = Convert.ToString(dictionary["_id"]); } if (text != null) { Squad orCreateSquad = this.GetOrCreateSquad(text); if (featured) { orCreateSquad.FromFeaturedObject(dictionary); } else { orCreateSquad.FromLeaderboardObject(dictionary); } if (orCreateSquad.MemberCount > 0) { leaderboardList.List.Add(orCreateSquad); } if (currentPlayerSquad != null && text == currentPlayerSquad.SquadID) { leaderboardList.AlwaysRefresh = true; } } } i++; } } }
public void UpdateLeaders(PlanetVO planetVO, LeaderboardController.OnUpdateData callback) { LeaderboardList <PlayerLBEntity> leaderboardList = null; LeaderboardList <PlayerLBEntity> value = null; string planetId = (planetVO != null) ? planetVO.Uid : null; this.GetPlayerLists(PlayerListType.Leaders, planetId, out leaderboardList, out value); PlayerLeaderboardRequest request = new PlayerLeaderboardRequest(planetId, Service.Get <CurrentPlayer>().PlayerId); GetLeaderboardPlayersCommand getLeaderboardPlayersCommand = new GetLeaderboardPlayersCommand(request); Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary["callback"] = callback; dictionary["list"] = leaderboardList; dictionary["listnearby"] = value; getLeaderboardPlayersCommand.Context = dictionary; getLeaderboardPlayersCommand.AddSuccessCallback(new AbstractCommand <PlayerLeaderboardRequest, LeaderboardResponse> .OnSuccessCallback(this.OnLeadersUpdated)); getLeaderboardPlayersCommand.AddFailureCallback(new AbstractCommand <PlayerLeaderboardRequest, LeaderboardResponse> .OnFailureCallback(this.OnLeadersUpdateFailure)); Service.Get <ServerAPI>().Sync(getLeaderboardPlayersCommand); leaderboardList.LastRefreshTime = Service.Get <ServerAPI>().ServerTime; }
private void DisplayPlayersNearMe() { LeaderboardList <PlayerLBEntity> leaderboardList = this.GetLeaderboardList(); if (this.curTab == SocialTabs.Squads && Service.Get <LeaderboardController>().SquadsNearMe.List.Count == 0) { this.top50Button.Enabled = true; this.findMeButton.Enabled = false; this.ShowFindMeFailMessage(Service.Get <LeaderboardController>().SquadsNearMe.List.Count); } if (leaderboardList != null && leaderboardList.List.Count == 0) { this.top50Button.Enabled = true; this.findMeButton.Enabled = false; this.ShowFindMeFailMessage(leaderboardList.List.Count); return; } TweenAlpha.Begin(this.scrollView.transform.gameObject, 0.5f, 0f); Service.Get <ViewTimerManager>().CreateViewTimer(0.5f, false, new TimerDelegate(this.OnTimerCallbackFindMe), null); }
private void GetPlayerLists(PlayerListType listType, string planetId, out LeaderboardList <PlayerLBEntity> leaderboardList, out LeaderboardList <PlayerLBEntity> nearbyLeaderboardList) { leaderboardList = null; nearbyLeaderboardList = null; switch (listType) { case PlayerListType.Friends: leaderboardList = this.Friends; nearbyLeaderboardList = this.Friends; return; case PlayerListType.Leaders: if (planetId == null) { leaderboardList = this.GlobalLeaders; nearbyLeaderboardList = this.GlobalNearMeLeaders; return; } leaderboardList = this.LeadersByPlanet[planetId]; nearbyLeaderboardList = this.LeadersNearMeByPlanet[planetId]; return; case PlayerListType.TournamentLeaders: if (!string.IsNullOrEmpty(planetId)) { if (!this.TournamentLeadersByPlanet.ContainsKey(planetId)) { this.InitTournamentListForPlanet(planetId); } leaderboardList = this.TournamentLeadersByPlanet[planetId]; nearbyLeaderboardList = this.TournamentLeadersNearMeByPlanet[planetId]; return; } Service.Get <StaRTSLogger>().Error("planetId value is null or empty in tournament leaderboard response handling"); return; default: return; } }
private LeaderboardList <PlayerLBEntity> GetLeaderboardList() { string selectedPlanetId = this.planetSelectionDropDown.GetSelectedPlanetId(); LeaderboardList <PlayerLBEntity> result = null; if (this.curTab == SocialTabs.Leaders) { if (selectedPlanetId == null) { result = Service.Get <LeaderboardController>().GlobalNearMeLeaders; } else { result = Service.Get <LeaderboardController>().LeadersNearMeByPlanet[selectedPlanetId]; } } else if (this.curTab == SocialTabs.Tournament) { result = Service.Get <LeaderboardController>().TournamentLeadersNearMeByPlanet[selectedPlanetId]; } return(result); }
private void ParsePlayerResponse(List <object> players, LeaderboardList <PlayerLBEntity> leaderboardList) { if (players != null && players.Count > 0) { leaderboardList.List.Clear(); int i = 0; int count = players.Count; while (i < count) { Dictionary <string, object> dictionary = players[i] as Dictionary <string, object>; if (dictionary != null) { string text = null; if (dictionary.ContainsKey("_id")) { text = Convert.ToString(dictionary["_id"]); } if (text != null) { PlayerLBEntity orCreatePlayer = this.GetOrCreatePlayer(text); if (orCreatePlayer.FromObject(dictionary) != null) { leaderboardList.List.Add(orCreatePlayer); if (orCreatePlayer.PlayerID == Service.CurrentPlayer.PlayerId) { leaderboardList.AlwaysRefresh = true; } } else { Service.Logger.Warn("Player Leaderboard Entry Failed to parse."); } } } i++; } } }
protected void Page_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("UserID"); dt.Columns.Add("UserName"); dt.Columns.Add("Count", System.Type.GetType("System.Int32")); using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["WikiVoterConnectionString"].ConnectionString)) { conn.Open(); SqlCommand command = new SqlCommand("SELECT UserID, UserName, TimeCreated FROM [User] WHERE Active = 1;", conn); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { int userID = reader.GetInt32(0); string username = reader.GetString(1); if (username != Settings.Default.WikiRaterName) { DataRow dr = dt.NewRow(); dr["UserID"] = userID; //already validated, but encode anyway dr["UserName"] = Server.HtmlEncode(username); int points = av.GetPoints(userID, false); dr["Count"] = points; if (points > 0) { dt.Rows.Add(dr); } } } } dt.DefaultView.Sort = "Count DESC"; LeaderboardList.DataSource = dt.DefaultView; LeaderboardList.DataBind(); }