コード例 #1
0
        public void Update(PlatformGameLifecycleDTO CurrentGame)
        {
            BlueBansLabel.Visibility = System.Windows.Visibility.Hidden;
            PurpleBansLabel.Visibility = System.Windows.Visibility.Hidden;
            PurpleBanListView.Items.Clear();
            BlueBanListView.Items.Clear();

            BlueListView.Items.Clear();
            PurpleListView.Items.Clear();

            ImageGrid.Children.Clear();

            List<Participant> AllParticipants = new List<Participant>(CurrentGame.Game.TeamOne.ToArray());
            AllParticipants.AddRange(CurrentGame.Game.TeamTwo);

            int i = 0;
            int y = 0;
            foreach (Participant part in AllParticipants)
            {
                ChampSelectPlayer control = new ChampSelectPlayer();
                if (part is PlayerParticipant)
                {
                    PlayerParticipant participant = part as PlayerParticipant;
                    foreach (PlayerChampionSelectionDTO championSelect in CurrentGame.Game.PlayerChampionSelections)
                    {
                        if (championSelect.SummonerInternalName == participant.SummonerInternalName)
                        {
                            control.ChampionImage.Source = champions.GetChampion(championSelect.ChampionId).icon;
                            var uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell1Id)));
                            control.SummonerSpell1.Source = Client.GetImage(uriSource);
                            uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell2Id)));
                            control.SummonerSpell2.Source = Client.GetImage(uriSource);

                            #region Generate Background

                            Image m = new Image();
                            Canvas.SetZIndex(m, -2);
                            m.Stretch = Stretch.None;
                            m.Width = 100;
                            m.Opacity = 0.50;
                            m.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                            m.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
                            m.Margin = new System.Windows.Thickness(y++ * 100, 0, 0, 0);
                            System.Drawing.Rectangle cropRect = new System.Drawing.Rectangle(new System.Drawing.Point(100, 0), new System.Drawing.Size(100, 560));
                            System.Drawing.Bitmap src = System.Drawing.Image.FromFile(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champions.GetChampion(championSelect.ChampionId).portraitPath)) as System.Drawing.Bitmap;
                            System.Drawing.Bitmap target = new System.Drawing.Bitmap(cropRect.Width, cropRect.Height);

                            using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(target))
                            {
                                g.DrawImage(src, new System.Drawing.Rectangle(0, 0, target.Width, target.Height),
                                                cropRect,
                                                System.Drawing.GraphicsUnit.Pixel);
                            }

                            m.Source = Client.ToWpfBitmap(target);
                            ImageGrid.Children.Add(m);

                            #endregion Generate Background
                        }
                    }

                    control.PlayerName.Content = participant.SummonerName;

                    if (participant.TeamParticipantId != null)
                    {
                        byte[] values = BitConverter.GetBytes((double)participant.TeamParticipantId);
                        if (!BitConverter.IsLittleEndian) Array.Reverse(values);

                        byte r = values[2];
                        byte b = values[3];
                        byte g = values[4];

                        System.Drawing.Color myColor = System.Drawing.Color.FromArgb(r, b, g);

                        var converter = new System.Windows.Media.BrushConverter();
                        var brush = (Brush)converter.ConvertFromString("#" + myColor.Name);
                        control.TeamRectangle.Fill = brush;
                        control.TeamRectangle.Visibility = System.Windows.Visibility.Visible;
                    }
                }

                i++;
                if (i <= 5)
                {
                    BlueListView.Items.Add(control);
                }
                else
                {
                    PurpleListView.Items.Add(control);
                }
            }

            if (CurrentGame.Game.BannedChampions.Count > 0)
            {
                BlueBansLabel.Visibility = System.Windows.Visibility.Visible;
                PurpleBansLabel.Visibility = System.Windows.Visibility.Visible;
            }

            foreach (var x in CurrentGame.Game.BannedChampions)
            {
                Image champImage = new Image();
                champImage.Height = 58;
                champImage.Width = 58;
                champImage.Source = champions.GetChampion(x.ChampionId).icon;
                if (x.TeamId == 100)
                {
                    BlueBanListView.Items.Add(champImage);
                }
                else
                {
                    PurpleBanListView.Items.Add(champImage);
                }
            }

            try
            {
                string mmrJSON = "";
                string url = Client.Region.SpectatorLink + "consumer/getGameMetaData/" + Client.Region.InternalName + "/" + CurrentGame.Game.Id + "/token";
                using (WebClient client = new WebClient())
                {
                    mmrJSON = client.DownloadString(url);
                }
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                Dictionary<string, object> deserializedJSON = serializer.Deserialize<Dictionary<string, object>>(mmrJSON);
                MMRLabel.Content = "≈" + deserializedJSON["interestScore"];
            }
            catch { MMRLabel.Content = "N/A"; }
        }
コード例 #2
0
 /// 58.)
 public void RetrieveInProgressSpectatorGameInfo(String summonerName, PlatformGameLifecycleDTO.Callback callback)
 {
     PlatformGameLifecycleDTO cb = new PlatformGameLifecycleDTO(callback);
     InvokeWithCallback("gameService", "retrieveInProgressSpectatorGameInfo", new object[] { summonerName }, cb);
 }
コード例 #3
0
 public PlatformGameLifecycleDTO RetrieveInProgressSpectatorGameInfo(String summonerName)
 {
     int Id = Invoke("gameService", "retrieveInProgressSpectatorGameInfo", new object[] { summonerName });
     while (!results.ContainsKey(Id))
         System.Threading.Thread.Sleep(10);
     TypedObject messageBody = results[Id].GetTO("data").GetTO("body");
     PlatformGameLifecycleDTO result = new PlatformGameLifecycleDTO(messageBody);
     results.Remove(Id);
     return result;
 }
コード例 #4
0
 public async Task<PlatformGameLifecycleDTO> RetrieveInProgressSpectatorGameInfo(String summonerName)
 {
     int Id = Invoke("gameService", "retrieveInProgressSpectatorGameInfo", new object[] { summonerName });
     while (!results.ContainsKey(Id))
         await Task.Delay(10);
     TypedObject messageBody = results[Id].GetTO("data").GetTO("body");
     PlatformGameLifecycleDTO result = new PlatformGameLifecycleDTO(messageBody);
     results.Remove(Id);
     return result;
 }