public void SetupButton(TitleDescriptionButtonData tdPair, string sceneName, string label = "", int dataIndex = 0) { DataIndex = dataIndex; LinkID = tdPair.LinkID; Label = label; SetLoadSceneName(sceneName); SetText(tdPair); Debug.Log(tdPair.ShowRatedIcon); if (tdPair.ShowRatedIcon) { SetRatedGameIconOn(); } }
private void LeagueViewOpenUI() { // clear previous buttons foreach (var button in playerButtonList) { GameObject.Destroy(button); } playerButtonList.Clear(); OpenTitleText.text = LeagueManager.league.Name; MatchListPanel.SetActive(false); PlayerListPanel.SetActive(true); StandingsListPanel.SetActive(false); // generate player list foreach (LeaguePlayerStats player in LeagueManager.league.PlayerList) { GameObject obj = Instantiate(PlayerButtonPrefab, PlayerListContent.transform); playerButtonList.Add(obj); var tdButton = obj.GetComponent <TitleDescriptionButton>(); // player description is blank if unrated, and shows rating in rated match string playerDescription = ""; if (LeagueManager.league.Settings.LeagueType == "Rated") { playerDescription = player.Rating.ToString(); } var buttonData = new TitleDescriptionButtonData( player.PlayerId, player.PlayerName, playerDescription ); tdButton.SetupButton(buttonData, "PlayerProfile", player.PlayerName); } // buttons for host or non host if (LeagueManager.league.Host == PlayerManager.PlayerName) { HostButtonGroup.SetActive(true); } else { NonHostButtonGroup.SetActive(true); } StartButton.interactable = LeagueManager.league.PlayerList.Count > 1; }
public void UpdateMatchList() { ClearButtonList(matchButtonList); CultureInfo culture = new CultureInfo("en-US"); // generate match list if (LeagueManager.league.Schedule != null) { int matchIndex = 0; foreach (MatchBrief match in LeagueManager.league.Schedule) { if (match == null) { // skip bye round matchIndex++; continue; } GameObject obj = Instantiate(PlayerButtonPrefab, MatchListContent.transform); matchButtonList.Add(obj); var tdButton = obj.GetComponent <TitleDescriptionButton>(); string description = ""; if (match.Result == WLD.None) { string weaponText = "No Selection"; if (match.MyWeapon != Weapon.None) { weaponText = "Playing " + match.MyWeapon.ToString(); } description = weaponText + "\n" + RPSCommon.UnixTimeToDateTime(match.DateTime).ToString("m", culture) + ", " + RPSCommon.UnixTimeToDateTime(match.DateTime).ToString("t", culture); } else { string weaponText = "No Selection"; if (match.MyWeapon != Weapon.None) { weaponText = match.MyWeapon.ToString() + " VS " + match.OpponentWeapon.ToString(); } if (match.Result == WLD.Draw) { description = weaponText + "\n" + match.Result.ToString(); } else { description = weaponText + "\n" + match.Result.ToString(); } } var buttonData = new TitleDescriptionButtonData( LeagueManager.league.Key, match.Opponent, description ); tdButton.SetupButton(buttonData, "MatchOverview", "", matchIndex++); if (match.Result != WLD.None) { int points = 0; if (match.Result == WLD.Draw) { points = 1; } if (match.Result == WLD.Win) { points = 3; } tdButton.SetPointText(points); } } } }
private void LeagueViewClosedUI() { ClosedTitleText.text = LeagueManager.league.Name; MatchListPanel.SetActive(true); PlayerListPanel.SetActive(false); StandingsListPanel.SetActive(true); // clear previous buttons foreach (var button in playerButtonList) { GameObject.Destroy(button); } playerButtonList.Clear(); // show buttons for end of season navigation //if (LeagueManager.league.Status == "Complete") //{ // NonHostSeasonOverButtonGroup.SetActive(true); //} // data for end of season rating adjustments List <int> ratingList = new List <int>(); List <int> scoreList = new List <int>(); int rank = 0; if (LeagueManager.league.Status == "Complete" && // league complete LeagueManager.league.Settings.LeagueType == "Rated") // league is rated { foreach (LeaguePlayerStats player in LeagueManager.league.PlayerList) { ratingList.Add(player.Rating); scoreList.Add(player.WLDScore); } } // generate player list foreach (LeaguePlayerStats player in LeagueManager.league.PlayerList) { rank++; GameObject obj = Instantiate(PlayerButtonPrefab, StandingsListContent.transform); playerButtonList.Add(obj); var tdButton = obj.GetComponent <TitleDescriptionButton>(); var buttonData = new TitleDescriptionButtonData( player.PlayerId, player.PlayerName, player.WLDScore.ToString() + "\t" + player.Wins.ToString() + "-" + player.Losses.ToString() + "-" + player.Draws.ToString() ); tdButton.SetupButton(buttonData, "PlayerProfile", player.PlayerName); if (LeagueManager.league.Status == "Complete" && // league complete LeagueManager.league.Settings.LeagueType == "Rated") // league is rated { int points = CalculateRatingChange(ratingList, scoreList, rank); tdButton.SetPointText(points); } } UpdateMatchList(); }
public void SetText(TitleDescriptionButtonData tdPair) { Title.SetText(tdPair.Title); Description.SetText(tdPair.Description); }