Beispiel #1
0
    public override bool OnLobbyServerSceneLoadedForPlayer(GameObject lobbyPlayer, GameObject gamePlayer)
    {
        base.OnLobbyServerSceneLoadedForPlayer(lobbyPlayer, gamePlayer);
        print("OnLobbyServerSceneLoadedForPlayer");
        ChampSelectPlayer lobbyScript = lobbyPlayer.GetComponent <ChampSelectPlayer> ();

        print(lobbyScript.idx);
        //if (lobbyScript.isLocalPlayer) {
        UIPanel.SetActive(false);

        Player playerScript = gamePlayer.GetComponent <Player> ();

        if (lobbyScript.fac == Types.Faction.BLUE)
        {
            gamePlayer.transform.position = GameSceneConsts.blue_team_respawn_pt.transform.position;
        }
        else if (lobbyScript.fac == Types.Faction.RED)
        {
            gamePlayer.transform.position = GameSceneConsts.red_team_respawn_pt.transform.position;
        }

        playerScript.takedown_paras(lobbyScript.champ_chosen, lobbyScript.fac, lobbyScript.idx);
        playerScript.idx = lobbyScript.idx;
        //playerScript.init (lobbyScript.champ_chosen, lobbyScript.fac, lobbyScript.idx);
        return(true);

        //}
        return(false);
    }
Beispiel #2
0
    /*
     * public void OnLobbyClientExit(){
     *      print ("OnLobbyClientExit");
     * }
     * public void OnLobbyClientDisconnect(NetworkConnection conn){
     *      print ("OnLobbyClientDisconnect");
     * }
     *
     * public void OnLobbyServerConnect(NetworkConnection conn){
     *      print ("OnLobbyServerConnect");
     * }
     */

    public void OnPlayerExit(int _idx)
    {
        print("OnPlayerExit");
        ChampSelectPlayer player = lobbySlots [_idx].GetComponent <ChampSelectPlayer> ();

        player.Cmdchange_fac(Types.Faction.OTHER, _idx);
    }
Beispiel #3
0
    public void sel_champ(Champion.champion_name _name, int _idx)
    {
        ChampSelectPlayer player = lobbySlots [_idx].GetComponent <ChampSelectPlayer> ();

        if (!player.isLocalPlayer)
        {
            return;
        }

        player.Cmdchange_champ(_name, _idx);
    }
Beispiel #4
0
    public void change_team_BLUE(int _idx)
    {
        ChampSelectPlayer player = lobbySlots [_idx].GetComponent <ChampSelectPlayer> ();

        if (!player.isLocalPlayer)
        {
            return;
        }

        player.Cmdchange_fac(Types.Faction.BLUE, _idx);
        //OnPlayerChangeFaction (_idx);
    }
Beispiel #5
0
    public int generate_player_idx(ChampSelectPlayer _player)
    {
        //go through all players
        for (int i = 0; i < lobbySlots.Length; ++i)
        {
            if (lobbySlots [i].gameObject == _player.gameObject)
            {
                return(i);
            }
        }

        return(-1);
    }
Beispiel #6
0
    public void OnClickQuit(int _idx)
    {
        ChampSelectPlayer player = lobbySlots [_idx].GetComponent <ChampSelectPlayer> ();

        if (!player.isLocalPlayer)
        {
            return;
        }

        player.Cmdchange_fac(Types.Faction.OTHER, _idx);
        //StopClient ();
        //StopHost ();
        //openNewGamePanel ();
    }
        public void Update(PlatformGameLifecycleDTO currentGame, string username)
        {
            _user = username;
            _game = currentGame;
            BlueBansLabel.Visibility   = Visibility.Hidden;
            PurpleBansLabel.Visibility = Visibility.Hidden;
            PurpleBanListView.Items.Clear();
            BlueBanListView.Items.Clear();

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

            ImageGrid.Children.Clear();

            var allParticipants = new List <Participant>(currentGame.Game.TeamOne.ToArray());

            allParticipants.AddRange(currentGame.Game.TeamTwo);

            var i = 0;
            var y = 0;

            foreach (var part in allParticipants)
            {
                var control = new ChampSelectPlayer();
                if (part is PlayerParticipant)
                {
                    var participant = part as PlayerParticipant;
                    foreach (
                        var championSelect in
                        currentGame.Game.PlayerChampionSelections.Where(
                            championSelect =>
                            championSelect.SummonerInternalName == participant.SummonerInternalName))
                    {
                        control.KnownPar             = true;
                        control._sumName             = participant.SummonerInternalName;
                        control._champID             = championSelect.ChampionId;
                        control.ChampionImage.Source = champions.GetChampion(championSelect.ChampionId).icon;
                        var uriSource =
                            new Uri(
                                Path.Combine(Client.ExecutingDirectory, "Assets", "spell",
                                             SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell1Id))),
                                UriKind.Absolute);
                        control.SummonerSpell1.Source = new BitmapImage(uriSource);
                        uriSource =
                            new Uri(
                                Path.Combine(Client.ExecutingDirectory, "Assets", "spell",
                                             SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell2Id))),
                                UriKind.Absolute);
                        control.SummonerSpell2.Source = new BitmapImage(uriSource);

                        #region Generate Background

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

                        using (var g = Graphics.FromImage(target))
                        {
                            if (src != null)
                            {
                                g.DrawImage(src, new Rectangle(0, 0, target.Width, target.Height),
                                            cropRect,
                                            GraphicsUnit.Pixel);
                            }
                        }

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

                        #endregion Generate Background
                    }

                    control.PlayerName.Content = participant.SummonerName;

                    if (participant.TeamParticipantId != null)
                    {
                        var values = BitConverter.GetBytes((double)participant.TeamParticipantId);
                        if (!BitConverter.IsLittleEndian)
                        {
                            Array.Reverse(values);
                        }

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

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

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

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

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

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

            try
            {
                string mmrJson;
                var    url = Client.Region.SpectatorLink + "consumer/getGameMetaData/" + Client.Region.InternalName +
                             "/" + currentGame.Game.Id + "/token";
                using (var client = new WebClient())
                {
                    mmrJson = client.DownloadString(url);
                }

                var serializer       = new JavaScriptSerializer();
                var deserializedJson = serializer.Deserialize <Dictionary <string, object> >(mmrJson);
                MMRLabel.Content = "≈" + deserializedJson["interestScore"];
            }
            catch
            {
                MMRLabel.Content = "N/A";
            }
        }
Beispiel #8
0
        private void ParseSpectatorGames()
        {
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                try
                {
                    if (GameList == null)
                    {
                        return;
                    }

                    if (GameList.Count <= 0)
                    {
                        return;
                    }

                    BlueBansLabel.Visibility   = Visibility.Hidden;
                    PurpleBansLabel.Visibility = Visibility.Hidden;
                    BlueBanListView.Items.Clear();
                    PurpleBanListView.Items.Clear();
                    BlueListView.Items.Clear();
                    PurpleListView.Items.Clear();
                    int gameId        = 0;
                    object objectGame = GameList[SelectedGame];
                    var spectatorGame = objectGame as Dictionary <string, object>;
                    ImageGrid.Children.Clear();
                    if (spectatorGame != null)
                    {
                        foreach (var pair in spectatorGame)
                        {
                            switch (pair.Key)
                            {
                            case "participants":
                                {
                                    var players = pair.Value as ArrayList;

                                    int i = 0;
                                    foreach (object objectPlayer in players)
                                    {
                                        var playerInfo    = objectPlayer as Dictionary <string, object>;
                                        int teamId        = 100;
                                        int championId    = 0;
                                        int spell1Id      = 0;
                                        int spell2Id      = 0;
                                        string playerName = "";
                                        foreach (var playerPair in playerInfo)
                                        {
                                            switch (playerPair.Key)
                                            {
                                            case "teamId":
                                                teamId = (int)playerPair.Value;
                                                break;

                                            case "championId":
                                                championId = (int)playerPair.Value;
                                                break;

                                            case "summonerName":
                                                playerName = playerPair.Value as string;
                                                break;

                                            case "spell1Id":
                                                spell1Id = (int)playerPair.Value;
                                                break;

                                            case "spell2Id":
                                                spell2Id = (int)playerPair.Value;
                                                break;
                                            }
                                        }
                                        var control = new ChampSelectPlayer
                                        {
                                            ChampionImage = { Source = champions.GetChampion(championId).icon }
                                        };
                                        var uriSource =
                                            new Uri(
                                                Path.Combine(Client.ExecutingDirectory, "Assets", "spell",
                                                             SummonerSpell.GetSpellImageName(spell1Id)), UriKind.Absolute);
                                        control.SummonerSpell1.Source = new BitmapImage(uriSource);
                                        uriSource =
                                            new Uri(
                                                Path.Combine(Client.ExecutingDirectory, "Assets", "spell",
                                                             SummonerSpell.GetSpellImageName(spell2Id)), UriKind.Absolute);
                                        control.SummonerSpell2.Source = new BitmapImage(uriSource);
                                        control.PlayerName.Content    = playerName;

                                        var m = new Image();
                                        Panel.SetZIndex(m, -2); //Put background behind everything
                                        m.Stretch             = Stretch.None;
                                        m.Width               = 100;
                                        m.Opacity             = 0.30;
                                        m.HorizontalAlignment = HorizontalAlignment.Left;
                                        m.VerticalAlignment   = VerticalAlignment.Stretch;
                                        m.Margin              = new Thickness(i++ *100, 0, 0, 0);
                                        var cropRect          = new Rectangle(new Point(100, 0), new Size(100, 560));
                                        var src               =
                                            System.Drawing.Image.FromFile(Path.Combine(Client.ExecutingDirectory,
                                                                                       "Assets",
                                                                                       "champions", champions.GetChampion(championId).portraitPath)) as Bitmap;
                                        var target = new Bitmap(cropRect.Width, cropRect.Height);

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

                                        m.Source = Client.ToWpfBitmap(target);
                                        ImageGrid.Children.Add(m);
                                        if (teamId == 100)
                                        {
                                            BlueListView.Items.Add(control);
                                        }
                                        else
                                        {
                                            PurpleListView.Items.Add(control);
                                        }
                                    }
                                }
                                break;

                            case "gameId":
                                gameId = (int)pair.Value;
                                break;

                            case "mapId":
                                try
                                {
                                    MapLabel.Content = BaseMap.GetMap((int)pair.Value).DisplayName;
                                }
                                catch (Exception e)
                                {
                                    Client.Log(e.Source, "Error");
                                    Client.Log(e.Message, "Error");
                                }
                                break;

                            case "gameLength":
                                {
                                    var seconds = (int)pair.Value;
                                    Client.spectatorTimer.Stop();
                                    Client.spectatorTimer          = new Timer(1000);
                                    Client.spectatorTimer.Elapsed += (s, e) => // Sincerely Idk when to stop it
                                    {
                                        seconds++;
                                        Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                                        {
                                            TimeSpan ts           = TimeSpan.FromSeconds(seconds);
                                            GameTimeLabel.Content = string.Format("{0:D2}:{1:D2} min", ts.Minutes,
                                                                                  ts.Seconds);
                                        }));
                                    };
                                    Client.spectatorTimer.Start();
                                }
                                break;

                            case "bannedChampions":
                                {
                                    //ArrayList players = pair.Value as ArrayList;
                                    //Dictionary<string, object> playerInfo = objectPlayer as Dictionary<string, object>;
                                    //foreach (KeyValuePair<string, object> playerPair in playerInfo)
                                    var keyArray = pair.Value as ArrayList;
                                    if (keyArray.Count > 0)
                                    {
                                        BlueBansLabel.Visibility   = Visibility.Visible;
                                        PurpleBansLabel.Visibility = Visibility.Visible;
                                    }
                                    foreach (Dictionary <string, object> keyArrayP in keyArray)
                                    //Dictionary<string, object> keyArrayP = keyArray as Dictionary<string, object>;
                                    {
                                        int cid    = 0;
                                        int teamId = 100;
                                        foreach (var keyArrayPair in keyArrayP)
                                        {
                                            switch (keyArrayPair.Key)
                                            {
                                            case "championId":
                                                cid = (int)keyArrayPair.Value;
                                                break;

                                            case "teamId":
                                                teamId = (int)keyArrayPair.Value;
                                                break;
                                            }
                                        }
                                        var item       = new ListViewItem();
                                        var champImage = new Image
                                        {
                                            Height = 58,
                                            Width  = 58
                                        };
                                        //temp
                                        try
                                        {
                                            champImage.Source = champions.GetChampion(cid).icon;
                                        }
                                        catch
                                        {
                                        }

                                        item.Content = champImage;
                                        if (teamId == 100)
                                        {
                                            BlueBanListView.Items.Add(item);
                                        }
                                        else
                                        {
                                            PurpleBanListView.Items.Add(item);
                                        }
                                    }
                                }
                                break;
                            }
                        }
                    }

                    try
                    {
                        BaseRegion region = BaseRegion.GetRegion((string)SpectatorComboBox.SelectedValue);
                        string spectatorJson;
                        string url = region.SpectatorLink + "consumer/getGameMetaData/" + region.InternalName + "/" +
                                     gameId + "/token";
                        using (var client = new WebClient())
                            spectatorJson = client.DownloadString(url);

                        var serializer       = new JavaScriptSerializer();
                        var deserializedJson = serializer.Deserialize <Dictionary <string, object> >(spectatorJson);
                        MMRLabel.Content     = "≈" + deserializedJson["interestScore"];
                    }
                    catch
                    {
                        MMRLabel.Content = "N/A";
                    }

                    if (Client.curentlyRecording.Contains(gameId))
                    {
                        RecordButton.IsEnabled = false;
                        RecordButton.Content   = "Recording...";
                    }
                    else
                    {
                        RecordButton.IsEnabled = true;
                        RecordButton.Content   = "Record";
                    }
                }
                catch (Exception e)
                {
                    Client.Log(e.Message);
                }
            }));
        }
Beispiel #9
0
        public void Update(PlatformGameLifecycleDTO CurrentGame)
        {
            Game = 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 = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell1Id))), UriKind.Absolute);
                            control.SummonerSpell1.Source = new BitmapImage(uriSource);
                            uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell2Id))), UriKind.Absolute);
                            control.SummonerSpell2.Source = new BitmapImage(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"; }
        }
Beispiel #10
0
        /// <summary>
        /// Render individual players
        /// </summary>
        /// <param name="selection">The champion the player has selected</param>
        /// <param name="player">The participant details of the player</param>
        /// <returns></returns>
        internal ChampSelectPlayer RenderPlayer(PlayerChampionSelectionDTO selection, PlayerParticipant player)
        {
            ChampSelectPlayer control = new ChampSelectPlayer();

            //Render champion
            if (selection.ChampionId != 0)
            {
                control.ChampionImage.Source = champions.GetChampion(selection.ChampionId).icon;
            }
            //Render summoner spells
            if (selection.Spell1Id != 0)
            {
                string uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)selection.Spell1Id));
                control.SummonerSpell1.Source = Client.GetImage(uriSource);
                uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)selection.Spell2Id));
                control.SummonerSpell2.Source = Client.GetImage(uriSource);
            }
            //Set our summoner spells in client
            if (player.SummonerName == Client.LoginPacket.AllSummonerData.Summoner.Name)
            {
                string uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)selection.Spell1Id));
                SummonerSpell1Image.Source = Client.GetImage(uriSource);
                uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)selection.Spell2Id));
                SummonerSpell2Image.Source = Client.GetImage(uriSource);
                MyChampId = selection.ChampionId;
            }
            //Has locked in
            if (player.PickMode == 2)
            {
                string uriSource = "/LegendaryClient;component/Locked.png";
                control.LockedInIcon.Source = Client.GetImage(uriSource);
            }
            //Make obvious whos pick turn it is
            if (player.PickTurn != LatestDto.PickTurn && (LatestDto.GameState == "CHAMP_SELECT" || LatestDto.GameState == "PRE_CHAMP_SELECT"))
            {
                control.Opacity = 0.5;
            }
            else
            {
                //Full opacity when not picking or banning
                control.Opacity = 1;
            }
            //If trading with this player is possible
            if (CanTradeWith != null && (CanTradeWith.PotentialTraders.Contains(player.SummonerInternalName) || DevMode))
            {
                control.TradeButton.Visibility = System.Windows.Visibility.Visible;
            }
            //If this player is duo/trio/quadra queued with players
            if (player.TeamParticipantId != null && (double)player.TeamParticipantId != 0)
            {
                //Byte hack to get individual hex colors
                byte[] values = BitConverter.GetBytes((double)player.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;
            }
            control.LockedInIcon.Visibility = System.Windows.Visibility.Visible;
            control.TradeButton.Tag         = new KeyValuePair <PlayerChampionSelectionDTO, PlayerParticipant>(selection, player);
            control.TradeButton.Click      += TradeButton_Click;
            control.PlayerName.Content      = player.SummonerName;
            return(control);
        }
Beispiel #11
0
        /// <summary>
        /// Main logic behind Champion Select
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="message"></param>
        private void ChampSelect_OnMessageReceived(object sender, object message)
        {
            if (message.GetType() == typeof(GameDTO))
            {
                #region In Champion Select

                GameDTO ChampDTO = message as GameDTO;
                LatestDto = ChampDTO;
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() =>
                {
                    //Allow all champions to be selected (reset our modifications)
                    ListViewItem[] ChampionArray = new ListViewItem[ChampionSelectListView.Items.Count];
                    ChampionSelectListView.Items.CopyTo(ChampionArray, 0);
                    foreach (ListViewItem y in ChampionArray)
                    {
                        y.IsHitTestVisible = true;
                        y.Opacity          = 1;
                    }

                    //Push all teams into one array to save a foreach call (looks messy)
                    List <Participant> AllParticipants = new List <Participant>(ChampDTO.TeamOne.ToArray());
                    AllParticipants.AddRange(ChampDTO.TeamTwo);
                    foreach (Participant p in AllParticipants)
                    {
                        if (p is PlayerParticipant)
                        {
                            PlayerParticipant play = (PlayerParticipant)p;
                            //If it is our turn to pick
                            if (play.PickTurn == ChampDTO.PickTurn)
                            {
                                if (play.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId)
                                {
                                    ChampionSelectListView.IsHitTestVisible = true;
                                    ChampionSelectListView.Opacity          = 1;
                                    GameStatusLabel.Content = "Your turn to pick!";
                                    break;
                                }
                            }
                        }
                        //Otherwise block selection of champions unless in dev mode
                        if (!DevMode)
                        {
                            ChampionSelectListView.IsHitTestVisible = false;
                            ChampionSelectListView.Opacity          = 0.5;
                        }
                        GameStatusLabel.Content = "Waiting for others to pick...";
                    }

                    //Champion select was cancelled
                    if (ChampDTO.GameState == "TEAM_SELECT")
                    {
                        if (CountdownTimer != null)
                        {
                            CountdownTimer.Stop();
                        }
                        FixChampSelect();
                        FakePage fakePage = new FakePage();
                        fakePage.Content  = LobbyContent;
                        Client.SwitchPage(fakePage);
                        return;
                    }
                    else if (ChampDTO.GameState == "PRE_CHAMP_SELECT")
                    {
                        //Banning phase. Enable banning phase and this will render only champions for ban
                        BanningPhase = true;
                        PurpleBansLabel.Visibility   = Visibility.Visible;
                        BlueBansLabel.Visibility     = Visibility.Visible;
                        BlueBanListView.Visibility   = Visibility.Visible;
                        PurpleBanListView.Visibility = Visibility.Visible;
                        GameStatusLabel.Content      = "Bans are on-going";
                        counter = configType.BanTimerDuration - 3;

                        #region Render Bans
                        BlueBanListView.Items.Clear();
                        PurpleBanListView.Items.Clear();
                        foreach (var x in ChampDTO.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);
                            }

                            foreach (ListViewItem y in ChampionArray)
                            {
                                if ((int)y.Tag == x.ChampionId)
                                {
                                    ChampionSelectListView.Items.Remove(y);
                                    //Remove from arrays
                                    foreach (ChampionDTO PlayerChamps in ChampList.ToArray())
                                    {
                                        if (x.ChampionId == PlayerChamps.ChampionId)
                                        {
                                            ChampList.Remove(PlayerChamps);
                                            break;
                                        }
                                    }

                                    foreach (ChampionBanInfoDTO BanChamps in ChampionsForBan.ToArray())
                                    {
                                        if (x.ChampionId == BanChamps.ChampionId)
                                        {
                                            ChampionsForBan.Remove(BanChamps);
                                            break;
                                        }
                                    }
                                }
                            }
                        }

                        #endregion Render Bans
                    }
                    else if (ChampDTO.GameState == "CHAMP_SELECT")
                    {
                        //Picking has started. If pickturn has changed reset timer
                        LastPickTurn = ChampDTO.PickTurn;
                        BanningPhase = false;
                    }
                    else if (ChampDTO.GameState == "POST_CHAMP_SELECT")
                    {
                        //Post game has started. Allow trading
                        CanTradeWith            = await Client.PVPNet.GetPotentialTraders();
                        HasLockedIn             = true;
                        GameStatusLabel.Content = "All players have picked!";
                        if (configType != null)
                        {
                            counter = configType.PostPickTimerDuration - 2;
                        }
                        else
                        {
                            counter = 10;
                        }
                    }
                    else if (ChampDTO.GameState == "START_REQUESTED")
                    {
                        GameStatusLabel.Content = "The game is about to start!";
                        DodgeButton.IsEnabled   = false; //Cannot dodge past this point!
                        counter = 1;
                    }
                    else if (ChampDTO.GameState == "TERMINATED")
                    {
                        //TODO
                    }

                    #region Display players

                    BlueListView.Items.Clear();
                    PurpleListView.Items.Clear();
                    int i           = 0;
                    bool PurpleSide = false;

                    //Aram hack, view other players champions & names (thanks to Andrew)
                    List <PlayerChampionSelectionDTO> OtherPlayers = new List <PlayerChampionSelectionDTO>(ChampDTO.PlayerChampionSelections.ToArray());
                    bool AreWePurpleSide = false;

                    foreach (Participant participant in AllParticipants)
                    {
                        Participant tempParticipant = participant;
                        i++;
                        ChampSelectPlayer control = new ChampSelectPlayer();
                        //Cast AramPlayers as PlayerParticipants. This removes reroll data
                        if (tempParticipant is AramPlayerParticipant)
                        {
                            tempParticipant = new PlayerParticipant(tempParticipant.GetBaseTypedObject());
                        }

                        if (tempParticipant is PlayerParticipant)
                        {
                            PlayerParticipant player   = tempParticipant as PlayerParticipant;
                            control.PlayerName.Content = player.SummonerName;

                            foreach (PlayerChampionSelectionDTO selection in ChampDTO.PlayerChampionSelections)
                            {
                                #region Disable picking selected champs

                                foreach (ListViewItem y in ChampionArray)
                                {
                                    if ((int)y.Tag == selection.ChampionId)
                                    {
                                        y.IsHitTestVisible = false;
                                        y.Opacity          = 0.5;
                                        if (configType != null)
                                        {
                                            if (configType.DuplicatePick)
                                            {
                                                y.IsHitTestVisible = true;
                                                y.Opacity          = 1;
                                            }
                                        }
                                    }
                                }

                                #endregion Disable picking selected champs

                                if (selection.SummonerInternalName == player.SummonerInternalName)
                                {
                                    //Clear our teams champion selection for aram hack
                                    OtherPlayers.Remove(selection);
                                    control = RenderPlayer(selection, player);
                                    //If we have locked in render skin select
                                    if (HasLockedIn && selection.SummonerInternalName == Client.LoginPacket.AllSummonerData.Summoner.InternalName && !DevMode)
                                    {
                                        if (PurpleSide)
                                        {
                                            AreWePurpleSide = true;
                                        }
                                        RenderLockInGrid(selection);
                                        if (player.PointSummary != null)
                                        {
                                            LockInButton.Content = string.Format("Reroll ({0}/{1})", player.PointSummary.CurrentPoints, player.PointSummary.PointsCostToRoll);
                                            if (player.PointSummary.NumberOfRolls > 0)
                                            {
                                                LockInButton.IsEnabled = true;
                                            }
                                            else
                                            {
                                                LockInButton.IsEnabled = false;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else if (tempParticipant is ObfuscatedParticipant)
                        {
                            control.PlayerName.Content = "Summoner " + i;
                        }
                        else if (tempParticipant is BotParticipant)
                        {
                            BotParticipant bot                   = tempParticipant as BotParticipant;
                            string botChamp                      = bot.SummonerName.Split(' ')[0]; //Why is this internal name rito?
                            champions botSelectedChamp           = champions.GetChampion(botChamp);
                            PlayerParticipant part               = new PlayerParticipant();
                            PlayerChampionSelectionDTO selection = new PlayerChampionSelectionDTO();
                            selection.ChampionId                 = botSelectedChamp.id;
                            part.SummonerName                    = botSelectedChamp.displayName + " bot";
                            control = RenderPlayer(selection, part);
                        }
                        else
                        {
                            control.PlayerName.Content = "Unknown Summoner";
                        }
                        //Display purple side if we have gone through our team
                        if (i > ChampDTO.TeamOne.Count)
                        {
                            i          = 0;
                            PurpleSide = true;
                        }

                        if (!PurpleSide)
                        {
                            BlueListView.Items.Add(control);
                        }
                        else
                        {
                            PurpleListView.Items.Add(control);
                        }
                    }

                    //Do aram hack!
                    if (OtherPlayers.Count > 0)
                    {
                        if (AreWePurpleSide)
                        {
                            BlueListView.Items.Clear();
                        }
                        else
                        {
                            PurpleListView.Items.Clear();
                        }

                        foreach (PlayerChampionSelectionDTO hackSelection in OtherPlayers)
                        {
                            ChampSelectPlayer control = new ChampSelectPlayer();
                            PlayerParticipant player  = new PlayerParticipant();
                            player.SummonerName       = hackSelection.SummonerInternalName;
                            control = RenderPlayer(hackSelection, player);

                            if (AreWePurpleSide)
                            {
                                BlueListView.Items.Add(control);
                            }
                            else
                            {
                                PurpleListView.Items.Add(control);
                            }
                        }
                    }

                    #endregion Display players
                }));

                #endregion In Champion Select
            }
            else if (message.GetType() == typeof(PlayerCredentialsDto))
            {
                #region Launching Game

                PlayerCredentialsDto dto = message as PlayerCredentialsDto;
                Client.CurrentGame = dto;

                if (!HasLaunchedGame)
                {
                    HasLaunchedGame = true;
                    Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                    {
                        if (CountdownTimer != null)
                        {
                            CountdownTimer.Stop();
                        }
                        QuitCurrentGame();
                    }));
                    Client.LaunchGame();
                }

                #endregion Launching Game
            }
            else if (message.GetType() == typeof(TradeContractDTO))
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    TradeContractDTO TradeDTO = message as TradeContractDTO;
                    if (TradeDTO.State == "PENDING")
                    {
                        PlayerTradeControl.Visibility = System.Windows.Visibility.Visible;
                        PlayerTradeControl.Tag        = TradeDTO;
                        PlayerTradeControl.AcceptButton.Visibility = System.Windows.Visibility.Visible;
                        PlayerTradeControl.DeclineButton.Content   = "Decline";

                        champions MyChampion = champions.GetChampion((int)TradeDTO.ResponderChampionId);
                        PlayerTradeControl.MyChampImage.Source  = MyChampion.icon;
                        PlayerTradeControl.MyChampLabel.Content = MyChampion.displayName;
                        champions TheirChampion = champions.GetChampion((int)TradeDTO.RequesterChampionId);
                        PlayerTradeControl.TheirChampImage.Source  = TheirChampion.icon;
                        PlayerTradeControl.TheirChampLabel.Content = TheirChampion.displayName;
                        PlayerTradeControl.RequestLabel.Content    = string.Format("{0} wants to trade!", TradeDTO.RequesterInternalSummonerName);
                    }
                    else if (TradeDTO.State == "CANCELED" || TradeDTO.State == "DECLINED" || TradeDTO.State == "BUSY")
                    {
                        PlayerTradeControl.Visibility = System.Windows.Visibility.Hidden;

                        NotificationPopup pop = new NotificationPopup(ChatSubjects.INVITE_STATUS_CHANGED,
                                                                      string.Format("{0} has {1} this trade", TradeDTO.RequesterInternalSummonerName, TradeDTO.State));

                        if (TradeDTO.State == "BUSY")
                        {
                            pop.NotificationTextBox.Text = string.Format("{0} is currently busy", TradeDTO.RequesterInternalSummonerName);
                        }

                        pop.Height = 200;
                        pop.OkButton.Visibility = System.Windows.Visibility.Visible;
                        pop.HorizontalAlignment = HorizontalAlignment.Right;
                        pop.VerticalAlignment   = VerticalAlignment.Bottom;
                        Client.NotificationGrid.Children.Add(pop);//*/
                    }
                }));
            }
        }
Beispiel #12
0
    //graphics
    public void refresh_player_panel(bool isQuit = false)
    {
        //make the team list first
        BLUE_players.Clear();
        RED_players.Clear();
        for (int i = 0; i < lobbySlots.Length; ++i)
        {
            if (lobbySlots [i] != null)
            {
                ChampSelectPlayer player = lobbySlots [i].gameObject.GetComponent <ChampSelectPlayer> ();
                if (player.fac == Types.Faction.RED)
                {
                    RED_players.Add(player.gameObject);
                }
                else if (player.fac == Types.Faction.BLUE)
                {
                    BLUE_players.Add(player.gameObject);
                }
            }
        }

        string obj_name;

        //clear existing objects
        for (int j = 0; j < bluePanel.transform.childCount; ++j)
        {
            for (int k = 0; k < bluePanel.transform.GetChild(j).childCount; ++k)
            {
                Destroy(bluePanel.transform.GetChild(j).GetChild(k).gameObject);
            }
        }

        for (int i = 0; i < BLUE_players.Count; ++i)
        {
            obj_name = "P" + (i + 1).ToString();
            GameObject child    = bluePanel.transform.FindChild(obj_name).gameObject;
            GameObject newPanel = Instantiate(playerPanel_prefab, child.transform.position, Quaternion.identity) as GameObject;
            newPanel.transform.SetParent(child.transform);
            newPanel.transform.localScale = new Vector3(1, 1, 1);
            ChampSelectPlayer player = BLUE_players[i].GetComponent <ChampSelectPlayer> ();
            newPanel.transform.FindChild("Name").GetComponent <Text> ().text = player.name;
        }

        for (int j = 0; j < redPanel.transform.childCount; ++j)
        {
            for (int k = 0; k < redPanel.transform.GetChild(j).childCount; ++k)
            {
                Destroy(redPanel.transform.GetChild(j).GetChild(k).gameObject);
            }
        }

        for (int i = 0; i < RED_players.Count; ++i)
        {
            obj_name = "P" + (GameSceneConsts.max_per_team + i + 1).ToString();
            GameObject child    = redPanel.transform.FindChild(obj_name).gameObject;
            GameObject newPanel = Instantiate(playerPanel_prefab_inverse, child.transform.position, Quaternion.identity) as GameObject;
            newPanel.transform.SetParent(child.transform);
            newPanel.transform.localScale = new Vector3(1, 1, 1);
            ChampSelectPlayer player = RED_players[i].GetComponent <ChampSelectPlayer> ();
            newPanel.transform.FindChild("Name").GetComponent <Text> ().text = player.name;
        }
        if (isQuit)
        {
            StopClient();
            //StopHost ();
            //openNewGamePanel ();
        }
    }
Beispiel #13
0
    //public override void OnServerSceneChanged(string sceneName){
    //
    //}

    //void OnPlayerDisconnected(NetworkPlayer player) {
    //	print ("OnPlayerDisconnected");
    //}

    public void reg_host_player(ChampSelectPlayer _player)
    {
    }
Beispiel #14
0
        private void ParseSpectatorGames()
        {
            if (gameList == null)
            {
                return;
            }
            if (gameList.Count <= 0)
            {
                return;
            }
            BlueBansLabel.Visibility   = Visibility.Hidden;
            PurpleBansLabel.Visibility = Visibility.Hidden;
            BlueBanListView.Items.Clear();
            PurpleBanListView.Items.Clear();
            BlueListView.Items.Clear();
            PurpleListView.Items.Clear();
            int GameId     = 0;
            var objectGame = gameList[SelectedGame];
            Dictionary <string, object> SpectatorGame = objectGame as Dictionary <string, object>;

            ImageGrid.Children.Clear();
            foreach (KeyValuePair <string, object> pair in SpectatorGame)
            {
                if (pair.Key == "participants")
                {
                    ArrayList players = pair.Value as ArrayList;

                    int i = 0;
                    foreach (var objectPlayer in players)
                    {
                        Dictionary <string, object> playerInfo = objectPlayer as Dictionary <string, object>;
                        int    teamId     = 100;
                        int    championId = 0;
                        int    spell1Id   = 0;
                        int    spell2Id   = 0;
                        string PlayerName = "";
                        foreach (KeyValuePair <string, object> playerPair in playerInfo)
                        {
                            if (playerPair.Key == "teamId")
                            {
                                teamId = (int)playerPair.Value;
                            }
                            if (playerPair.Key == "championId")
                            {
                                championId = (int)playerPair.Value;
                            }
                            if (playerPair.Key == "summonerName")
                            {
                                PlayerName = playerPair.Value as string;
                            }
                            if (playerPair.Key == "spell1Id")
                            {
                                spell1Id = (int)playerPair.Value;
                            }
                            if (playerPair.Key == "spell2Id")
                            {
                                spell2Id = (int)playerPair.Value;
                            }
                        }
                        ChampSelectPlayer control = new ChampSelectPlayer();
                        control.ChampionImage.Source = champions.GetChampion(championId).icon;
                        var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(spell1Id)), UriKind.Absolute);
                        control.SummonerSpell1.Source = new BitmapImage(uriSource);
                        uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(spell2Id)), UriKind.Absolute);
                        control.SummonerSpell2.Source = new BitmapImage(uriSource);
                        control.PlayerName.Content    = PlayerName;

                        Image m = new Image();
                        Canvas.SetZIndex(m, -2); //Put background behind everything
                        m.Stretch             = Stretch.None;
                        m.Width               = 100;
                        m.Opacity             = 0.30;
                        m.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                        m.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
                        m.Margin              = new System.Windows.Thickness(i++ *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(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);

                        if (teamId == 100)
                        {
                            BlueListView.Items.Add(control);
                        }
                        else
                        {
                            PurpleListView.Items.Add(control);
                        }
                    }
                }
                else if (pair.Key == "gameId")
                {
                    GameId = (int)pair.Value;
                }
                else if (pair.Key == "mapId")
                {
                    MapLabel.Content = BaseMap.GetMap((int)pair.Value).DisplayName;
                }
                else if (pair.Key == "gameLength")
                {
                    var seconds = (int)pair.Value;
                    GameTimeLabel.Content = string.Format("{0:D}:{1:00} min", seconds / 60, seconds % 60);
                }
                else if (pair.Key == "bannedChampions")
                {
                    //ArrayList players = pair.Value as ArrayList;
                    //Dictionary<string, object> playerInfo = objectPlayer as Dictionary<string, object>;
                    //foreach (KeyValuePair<string, object> playerPair in playerInfo)
                    ArrayList keyArray = pair.Value as ArrayList;
                    if (keyArray.Count > 0)
                    {
                        BlueBansLabel.Visibility   = Visibility.Visible;
                        PurpleBansLabel.Visibility = Visibility.Visible;
                    }
                    foreach (Dictionary <string, object> keyArrayP in keyArray)
                    //Dictionary<string, object> keyArrayP = keyArray as Dictionary<string, object>;
                    {
                        int cid    = 0;
                        int teamId = 100;
                        foreach (KeyValuePair <string, object> keyArrayPair in keyArrayP)
                        {
                            if (keyArrayPair.Key == "championId")
                            {
                                cid = (int)keyArrayPair.Value;
                            }
                            if (keyArrayPair.Key == "teamId")
                            {
                                teamId = (int)keyArrayPair.Value;
                            }
                        }
                        ListViewItem item       = new ListViewItem();
                        Image        champImage = new Image();
                        champImage.Height = 58;
                        champImage.Width  = 58;
                        //temp
                        try
                        {
                            champImage.Source = champions.GetChampion(cid).icon;
                        }
                        catch { }

                        item.Content = champImage;
                        if (teamId == 100)
                        {
                            BlueBanListView.Items.Add(item);
                        }
                        else
                        {
                            PurpleBanListView.Items.Add(item);
                        }
                    }
                }
            }

            try
            {
                BaseRegion region        = BaseRegion.GetRegion((string)SpectatorComboBox.SelectedValue);
                string     spectatorJSON = "";
                string     url           = region.SpectatorLink + "consumer/getGameMetaData/" + region.InternalName + "/" + GameId + "/token";
                using (WebClient client = new WebClient())
                {
                    spectatorJSON = client.DownloadString(url);
                }
                JavaScriptSerializer        serializer       = new JavaScriptSerializer();
                Dictionary <string, object> deserializedJSON = serializer.Deserialize <Dictionary <string, object> >(spectatorJSON);
                MMRLabel.Content = "≈" + deserializedJSON["interestScore"];
            }
            catch { MMRLabel.Content = "N/A"; }
        }
Beispiel #15
0
        private async void ParseSpectatorGames()
        {
            if (gameList == null)
            {
                return;
            }
            if (gameList.Count <= 0)
            {
                return;
            }
            BlueBansLabel.Visibility   = Visibility.Hidden;
            PurpleBansLabel.Visibility = Visibility.Hidden;
            BlueBanListView.Items.Clear();
            PurpleBanListView.Items.Clear();
            BlueListView.Items.Clear();
            PurpleListView.Items.Clear();
            int GameId = 0;

            if (gameList.Count > SelectedGame)
            {
                var objectGame = gameList[SelectedGame];
                Dictionary <string, object> SpectatorGame = objectGame as Dictionary <string, object>;
                foreach (KeyValuePair <string, object> pair in SpectatorGame)
                {
                    if (pair.Key == "participants")
                    {
                        ArrayList players = pair.Value as ArrayList;
                        foreach (var objectPlayer in players)
                        {
                            Dictionary <string, object> playerInfo = objectPlayer as Dictionary <string, object>;
                            int    teamId     = 100;
                            int    championId = 0;
                            int    spell1Id   = 0;
                            int    spell2Id   = 0;
                            string PlayerName = "";
                            foreach (KeyValuePair <string, object> playerPair in playerInfo)
                            {
                                if (playerPair.Key == "teamId")
                                {
                                    teamId = (int)playerPair.Value;
                                }
                                if (playerPair.Key == "championId")
                                {
                                    championId = (int)playerPair.Value;
                                }
                                if (playerPair.Key == "summonerName")
                                {
                                    PlayerName = playerPair.Value as string;
                                }
                                if (playerPair.Key == "spell1Id")
                                {
                                    spell1Id = (int)playerPair.Value;
                                }
                                if (playerPair.Key == "spell2Id")
                                {
                                    spell2Id = (int)playerPair.Value;
                                }
                            }
                            ChampSelectPlayer control = new ChampSelectPlayer();
                            control.ChampionImage.Source = champions.GetChampion(championId).icon;
                            string uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(spell1Id));
                            control.SummonerSpell1.Source = Client.GetImage(uriSource);
                            uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(spell2Id));
                            control.SummonerSpell2.Source = Client.GetImage(uriSource);

                            control.PlayerName.Content = PlayerName;

                            if (teamId == 100)
                            {
                                BlueListView.Items.Add(control);
                            }
                            else
                            {
                                PurpleListView.Items.Add(control);
                            }
                        }
                    }
                    if (pair.Key == "gameId")
                    {
                        GameId = (int)pair.Value;
                    }
                    if (pair.Key == "bannedChampions")
                    {
                        ArrayList keyArray = pair.Value as ArrayList;
                        if (keyArray.Count > 0)
                        {
                            BlueBansLabel.Visibility   = Visibility.Visible;
                            PurpleBansLabel.Visibility = Visibility.Visible;
                        }
                        foreach (Dictionary <string, object> keyArrayP in keyArray)
                        {
                            int cid    = 0;
                            int teamId = 100;
                            foreach (KeyValuePair <string, object> keyArrayPair in keyArrayP)
                            {
                                if (keyArrayPair.Key == "championId")
                                {
                                    cid = (int)keyArrayPair.Value;
                                }
                                if (keyArrayPair.Key == "teamId")
                                {
                                    teamId = (int)keyArrayPair.Value;
                                }
                            }
                            ListViewItem item       = new ListViewItem();
                            Image        champImage = new Image();
                            champImage.Height = 58;
                            champImage.Width  = 58;
                            champImage.Source = champions.GetChampion(cid).icon;
                            item.Content      = champImage;
                            if (teamId == 100)
                            {
                                BlueBanListView.Items.Add(item);
                            }
                            else
                            {
                                PurpleBanListView.Items.Add(item);
                            }
                        }
                    }
                }

                try
                {
                    BaseRegion region        = BaseRegion.GetRegion((string)SpectatorComboBox.SelectedValue);
                    string     spectatorJSON = "";
                    string     url           = region.SpectatorLink + "consumer/getGameMetaData/" + region.InternalName + "/" + GameId + "/token";
                    using (WebClient client = new WebClient())
                    {
                        spectatorJSON = await client.DownloadStringTaskAsync(url);
                    }
                    JavaScriptSerializer        serializer       = new JavaScriptSerializer();
                    Dictionary <string, object> deserializedJSON = serializer.Deserialize <Dictionary <string, object> >(spectatorJSON);
                    MMRLabel.Content = "≈" + deserializedJSON["interestScore"];
                }
                catch { MMRLabel.Content = "N/A"; }
            }
        }