private TurnInfo RenderPlayers(GameDTO game) { var turn = new TurnInfo(); MyTeam.Children.Clear(); OtherTeam.Children.Clear(); bool meBlue = game.TeamOne.Any(p => (p as PlayerParticipant)?.AccountId == Session.Current.Account.AccountID); foreach (var thing in game.TeamOne.Concat(game.TeamTwo)) { var player = thing as PlayerParticipant; var bot = thing as BotParticipant; var obfusc = thing as ObfuscatedParticipant; bool blue = game.TeamOne.Contains(thing); UserControl control; if (player != null) { var selection = game.PlayerChampionSelections?.FirstOrDefault(c => c.SummonerInternalName == player.SummonerInternalName); control = new ChampSelectPlayer(player, selection); if (player.PickTurn == game.PickTurn) { if (player.SummonerId == Session.Current.Account.SummonerID) { turn.IsMyTurn = turn.IsOurTurn = true; } else if (meBlue == blue) { turn.IsOurTurn = true; } } } else if (bot != null) { control = new ChampSelectPlayer(bot); } else if (obfusc != null) { control = new ChampSelectPlayer(obfusc, null); } else { Session.Log(thing.GetType().Name); control = null; } if (blue == meBlue) { MyTeam.Children.Add(control); } else { OtherTeam.Children.Add(control); } } if (OtherTeam.Children.Count == 0) OtherTeam.Visibility = Visibility.Collapsed; Ban1.Source = Ban2.Source = Ban3.Source = Ban4.Source = Ban5.Source = Ban6.Source = null; Image[] blueBans, redBans; if (meBlue) { blueBans = new[] { Ban1, Ban2, Ban3 }; redBans = new[] { Ban4, Ban5, Ban6 }; } else { blueBans = new[] { Ban4, Ban5, Ban6 }; redBans = new[] { Ban1, Ban2, Ban3 }; } foreach (var thing in game.BannedChampions) { var champ = DataDragon.GetChampData(thing.ChampionId); var image = DataDragon.GetChampIconImage(champ); int index = thing.PickTurn - 1; if (index % 2 == 0) { //0, 2, 4: Blue team's bans blueBans[thing.PickTurn / 2].Source = image.Load(); } else { //1, 3, 5: Red team's bans redBans[thing.PickTurn / 2].Source = image.Load(); } } //Dispatcher.BeginInvoke((Action) (() => MyTeam.Height = OtherTeam.Height = Math.Max(MyTeam.ActualHeight, OtherTeam.ActualHeight)), System.Windows.Threading.DispatcherPriority.Input); return turn; }
private TurnInfo RenderPlayers(GameDTO game) { var turn = new TurnInfo(); MyTeam.Children.Clear(); OtherTeam.Children.Clear(); bool meBlue = game.TeamOne.Any(p => (p as PlayerParticipant)?.AccountId == Session.Current.Account.AccountID); foreach (var thing in game.TeamOne.Concat(game.TeamTwo)) { var player = thing as PlayerParticipant; var bot = thing as BotParticipant; var obfusc = thing as ObfuscatedParticipant; bool blue = game.TeamOne.Contains(thing); UserControl control; if (player != null) { var selection = game.PlayerChampionSelections?.FirstOrDefault(c => c.SummonerInternalName == player.SummonerInternalName); control = new ChampSelectPlayer(player, selection); if (player.PickTurn == game.PickTurn) { if (player.SummonerId == Session.Current.Account.SummonerID) { turn.IsMyTurn = turn.IsOurTurn = true; } else if (meBlue == blue) { turn.IsOurTurn = true; } } } else if (bot != null) { control = new ChampSelectPlayer(bot); } else if (obfusc != null) { control = new ChampSelectPlayer(obfusc, null); } else { Session.Log(thing.GetType().Name); control = null; } if (blue == meBlue) { MyTeam.Children.Add(control); } else { OtherTeam.Children.Add(control); } } if (OtherTeam.Children.Count == 0) { OtherTeam.Visibility = Visibility.Collapsed; } Ban1.Source = Ban2.Source = Ban3.Source = Ban4.Source = Ban5.Source = Ban6.Source = null; Image[] blueBans, redBans; if (meBlue) { blueBans = new[] { Ban1, Ban2, Ban3 }; redBans = new[] { Ban4, Ban5, Ban6 }; } else { blueBans = new[] { Ban4, Ban5, Ban6 }; redBans = new[] { Ban1, Ban2, Ban3 }; } foreach (var thing in game.BannedChampions) { var champ = DataDragon.GetChampData(thing.ChampionId); var image = DataDragon.GetChampIconImage(champ); int index = thing.PickTurn - 1; if (index % 2 == 0) { //0, 2, 4: Blue team's bans blueBans[thing.PickTurn / 2].Source = image.Load(); } else { //1, 3, 5: Red team's bans redBans[thing.PickTurn / 2].Source = image.Load(); } } //Dispatcher.BeginInvoke((Action) (() => MyTeam.Height = OtherTeam.Height = Math.Max(MyTeam.ActualHeight, OtherTeam.ActualHeight)), System.Windows.Threading.DispatcherPriority.Input); return(turn); }