private CustomLobbyPlayer RenderPlayer(PlayerParticipant player, bool IsOwner) { CustomLobbyPlayer lobbyPlayer = new CustomLobbyPlayer(); lobbyPlayer.PlayerName.Content = player.SummonerName; var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", player.ProfileIconId + ".png"), UriKind.RelativeOrAbsolute); lobbyPlayer.ProfileImage.Source = new BitmapImage(uriSource); if (IsOwner) { lobbyPlayer.OwnerLabel.Visibility = Visibility.Visible; } lobbyPlayer.Width = 400; lobbyPlayer.Margin = new Thickness(0, 0, 0, 5); if ((player.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId) || (player.SummonerId != Client.LoginPacket.AllSummonerData.Summoner.SumId && !this.IsOwner)) { lobbyPlayer.BanButton.Visibility = Visibility.Hidden; } lobbyPlayer.BanButton.Tag = player; lobbyPlayer.BanButton.Click += KickAndBan_Click; return(lobbyPlayer); }
void SetupLocalPlayer() { MyPlayer = this; if (GetComponentInChildren <Text>().text == string.Empty) { CmdUpdateName(CustomLobbyManager.Instance.GetComponent <NetworkInitializer>().PlayerName); } }
public void OnLobbyServerSceneLoadedForPlayer(NetworkManager manager, GameObject lobbyPlayer, GameObject gamePlayer) { GamePlayer player = gamePlayer.GetComponent <GamePlayer>(); CustomLobbyPlayer lobby = lobbyPlayer.GetComponent <CustomLobbyPlayer>(); // Transfer Lobby Information to Game player.playerName = lobby.playerName; player.playerColorIndex = lobby.playerColorIndex; }
//================================================================================ // Logic //================================================================================ /// <summary> /// Adds a CustomLobbyPlayer to the list and displays /// on the Lobby GUI. /// </summary> /// <param name="player">CustomLobbyPlayer that should be added</param> public void AddPlayer(CustomLobbyPlayer player) { if (players.Contains(player)) { return; } players.Add(player); player.transform.SetParent(transform, false); }
/// <summary> /// Enables Join-Buttons if number of players /// is equal or greater than number of required players. /// </summary> private void UpdateJoinButtons() { for (int i = 0; i < lobbySlots.Length; ++i) { CustomLobbyPlayer p = lobbySlots[i] as CustomLobbyPlayer; if (p != null) { p.ToggleJoinButton(numPlayers + 1 >= minPlayers); } } }
//================================================================================ // Server //================================================================================ public override GameObject OnLobbyServerCreateLobbyPlayer(NetworkConnection conn, short playerControllerId) { GameObject obj = Instantiate(lobbyPlayerPrefab.gameObject) as GameObject; CustomLobbyPlayer newPlayer = obj.GetComponent <CustomLobbyPlayer>(); newPlayer.ToggleJoinButton(numPlayers + 1 >= minPlayers); UpdateJoinButtons(); return(obj); }
/// <summary> /// Called after user clicks on "Create Game"-Button /// </summary> public void OnCreateGameClicked() { StartMatchMaker(); // Server needs to reset colors in use to prevent endless while loop CustomLobbyPlayer.ResetColorsInUse(); string matchName = RandomNameGenerator.generateRoomName(); ChangeTo(lobbyPanel); matchMaker.CreateMatch( matchName, (uint)maxPlayers, true, "", "", "", 0, 0, OnMatchCreate); }
private void GameLobby_OnMessageReceived(object sender, object message) { if (message.GetType() == typeof(GameDTO)) { GameDTO dto = message as GameDTO; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() => { if (!HasConnectedToChat) { //Run once BaseMap map = BaseMap.GetMap(dto.MapId); MapLabel.Content = map.DisplayName; ModeLabel.Content = Client.TitleCaseString(dto.GameMode); GameTypeConfigDTO configType = Client.LoginPacket.GameTypeConfigs.Find(x => x.Id == dto.GameTypeConfigId); TypeLabel.Content = GetGameMode(configType.Id); SizeLabel.Content = dto.MaxNumPlayers / 2 + "v" + dto.MaxNumPlayers / 2; HasConnectedToChat = true; try { string ObfuscatedName = Client.GetObfuscatedChatroomName(dto.Name.ToLower() + Convert.ToInt32(dto.Id), ChatPrefixes.Arranging_Practice); string JID = Client.GetChatroomJID(ObfuscatedName, dto.RoomPassword, false); newRoom = Client.ConfManager.GetRoom(new jabber.JID(JID)); newRoom.Nickname = Client.LoginPacket.AllSummonerData.Summoner.Name; newRoom.OnRoomMessage += newRoom_OnRoomMessage; newRoom.OnParticipantJoin += newRoom_OnParticipantJoin; newRoom.Join(dto.RoomPassword); } catch { } } if (dto.GameState == "TEAM_SELECT") { OptomisticLock = dto.OptimisticLock; LaunchedTeamSelect = false; BlueTeamListView.Items.Clear(); PurpleTeamListView.Items.Clear(); List <Participant> AllParticipants = new List <Participant>(dto.TeamOne.ToArray()); AllParticipants.AddRange(dto.TeamTwo); int i = 0; bool PurpleSide = false; foreach (Participant playerTeam in AllParticipants) { i++; CustomLobbyPlayer lobbyPlayer = new CustomLobbyPlayer(); BotControl botPlayer = new BotControl(); if (playerTeam is PlayerParticipant) { PlayerParticipant player = playerTeam as PlayerParticipant; lobbyPlayer = RenderPlayer(player, dto.OwnerSummary.SummonerId == player.SummonerId); IsOwner = dto.OwnerSummary.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId; StartGameButton.IsEnabled = IsOwner; AddBotBlueTeam.IsEnabled = IsOwner; AddBotPurpleTeam.IsEnabled = IsOwner; if (Client.Whitelist.Count > 0) { if (!Client.Whitelist.Contains(player.SummonerName.ToLower())) { await Client.PVPNet.BanUserFromGame(Client.GameID, player.AccountId); } } } else if (playerTeam is BotParticipant) { BotParticipant botParticipant = playerTeam as BotParticipant; botPlayer = RenderBot(botParticipant); } if (i > dto.TeamOne.Count) { i = 0; PurpleSide = true; } if (!PurpleSide) { BlueTeamListView.Items.Add(lobbyPlayer); } else { PurpleTeamListView.Items.Add(lobbyPlayer); } } } else if (dto.GameState == "CHAMP_SELECT" || dto.GameState == "PRE_CHAMP_SELECT") { if (!LaunchedTeamSelect) { Client.ChampSelectDTO = dto; Client.LastPageContent = Client.Container.Content; Client.SwitchPage(new ChampSelectPage(this)); Client.GameStatus = "championSelect"; Client.SetChatHover(); LaunchedTeamSelect = true; } } })); } }
private void Lobby_OnMessageReceived(object sender, object message) { if (message.GetType() != typeof(GameDTO)) { return; } var dto = message as GameDTO; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() => { if (!HasConnectedToChat) { //Run once BaseMap map = BaseMap.GetMap(dto.MapId); MapLabel.Content = map.DisplayName; ModeLabel.Content = Client.TitleCaseString(dto.GameMode); GameTypeConfigDTO configType = Client.LoginPacket.GameTypeConfigs.Find(x => x.Id == dto.GameTypeConfigId); TypeLabel.Content = GetGameMode(configType.Id); SizeLabel.Content = dto.MaxNumPlayers / 2 + "v" + dto.MaxNumPlayers / 2; HasConnectedToChat = true; string obfuscatedName = Client.GetObfuscatedChatroomName(dto.Name.ToLower() + Convert.ToInt64(dto.Id), ChatPrefixes.Arranging_Practice); string Jid = Client.GetChatroomJid(obfuscatedName, dto.RoomPassword, false); newRoom = new MucManager(Client.XmppConnection); Client.XmppConnection.OnMessage += XmppConnection_OnMessage; Client.XmppConnection.OnPresence += XmppConnection_OnPresence; jid = new Jid(dto.RoomName); newRoom.AcceptDefaultConfiguration(jid); newRoom.JoinRoom(jid, Client.LoginPacket.AllSummonerData.Summoner.Name, dto.RoomPassword); } switch (dto.GameState) { case "TEAM_SELECT": { OptomisticLock = dto.OptimisticLock; LaunchedTeamSelect = false; BlueTeamListView.Items.Clear(); PurpleTeamListView.Items.Clear(); var allParticipants = new List <Participant>(dto.TeamOne.ToArray()); allParticipants.AddRange(dto.TeamTwo); int i = 0; bool purpleSide = false; foreach (Participant playerTeam in allParticipants) { i++; var lobbyPlayer = new CustomLobbyPlayer(); //var botPlayer = new BotControl(); if (playerTeam is PlayerParticipant) { var player = playerTeam as PlayerParticipant; lobbyPlayer = RenderPlayer(player, dto.OwnerSummary.SummonerId == player.SummonerId); ///BotParticipant botParticipant = playerTeam as BotParticipant; //botPlayer = RenderBot(botParticipant); IsOwner = dto.OwnerSummary.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId; StartGameButton.IsEnabled = IsOwner; if (Client.Whitelist.Count > 0) { if (!Client.Whitelist.Contains(player.SummonerName.ToLower())) { await RiotCalls.BanUserFromGame(Client.GameID, player.AccountId); } } } if (i > dto.TeamOne.Count) { i = 0; purpleSide = true; } if (!purpleSide) { BlueTeamListView.Items.Add(lobbyPlayer); } else { PurpleTeamListView.Items.Add(lobbyPlayer); } } } break; case "PRE_CHAMP_SELECT": case "CHAMP_SELECT": if (!LaunchedTeamSelect) { Client.ChampSelectDTO = dto; Client.LastPageContent = Client.Container.Content; Client.SwitchPage(new ChampSelectPage(dto.RoomName, dto.RoomPassword).Load(this)); LaunchedTeamSelect = true; } break; } })); }
private void GameLobby_OnMessageReceived(object sender, object message) { if (message == null) { return; } if (message.GetType() != typeof(GameDTO)) { return; } var dto = message as GameDTO; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() => { if (!HasConnectedToChat) { //Run once BaseMap map = BaseMap.GetMap(dto.MapId); MapLabel.Content = map.DisplayName; ModeLabel.Content = Client.TitleCaseString(dto.GameMode); GameTypeConfigDTO configType = Client.LoginPacket.GameTypeConfigs.Find(x => x.Id == dto.GameTypeConfigId); TypeLabel.Content = GetGameMode(configType.Id); SizeLabel.Content = dto.MaxNumPlayers / 2 + "v" + dto.MaxNumPlayers / 2; HasConnectedToChat = true; try { string obfuscatedName = Client.GetObfuscatedChatroomName(dto.Name.ToLower() + Convert.ToInt32(dto.Id), ChatPrefixes.Arranging_Practice); string jid = Client.GetChatroomJID(obfuscatedName, dto.RoomPassword, false); newRoom = Client.ConfManager.GetRoom(new JID(jid)); newRoom.Nickname = Client.LoginPacket.AllSummonerData.Summoner.Name; newRoom.OnRoomMessage += newRoom_OnRoomMessage; newRoom.OnParticipantJoin += newRoom_OnParticipantJoin; newRoom.Join(dto.RoomPassword); } catch { } } switch (dto.GameState) { case "TEAM_SELECT": { bool isSpectator = false; OptomisticLock = dto.OptimisticLock; LaunchedTeamSelect = false; BlueTeamListView.Items.Clear(); PurpleTeamListView.Items.Clear(); SpectatorListView.Items.Clear(); foreach (Participant playerTeam in dto.TeamOne) { if (playerTeam is PlayerParticipant) { var lobbyPlayer = new CustomLobbyPlayer(); var player = playerTeam as PlayerParticipant; lobbyPlayer = RenderPlayer(player, dto.OwnerSummary.SummonerId == player.SummonerId); Client.isOwnerOfGame = dto.OwnerSummary.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId; StartGameButton.IsEnabled = Client.isOwnerOfGame; AddBotBlueTeam.IsEnabled = Client.isOwnerOfGame; AddBotPurpleTeam.IsEnabled = Client.isOwnerOfGame; BlueTeamListView.Items.Add(lobbyPlayer); if (Client.Whitelist.Count <= 0) { continue; } if (!Client.Whitelist.Contains(player.SummonerName.ToLower())) { await Client.PVPNet.BanUserFromGame(Client.GameID, player.AccountId); } } else if (playerTeam is BotParticipant) { var botParticipant = playerTeam as BotParticipant; var botPlayer = new BotControl(); botPlayer = RenderBot(botParticipant); BlueTeamListView.Items.Add(botPlayer); } } foreach (Participant playerTeam in dto.TeamTwo) { if (playerTeam is PlayerParticipant) { var lobbyPlayer = new CustomLobbyPlayer(); var player = playerTeam as PlayerParticipant; lobbyPlayer = RenderPlayer(player, dto.OwnerSummary.SummonerId == player.SummonerId); Client.isOwnerOfGame = dto.OwnerSummary.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId; StartGameButton.IsEnabled = Client.isOwnerOfGame; AddBotBlueTeam.IsEnabled = Client.isOwnerOfGame; AddBotPurpleTeam.IsEnabled = Client.isOwnerOfGame; PurpleTeamListView.Items.Add(lobbyPlayer); if (Client.Whitelist.Count <= 0) { continue; } if (!Client.Whitelist.Contains(player.SummonerName.ToLower())) { await Client.PVPNet.BanUserFromGame(Client.GameID, player.AccountId); } } else if (playerTeam is BotParticipant) { var botParticipant = playerTeam as BotParticipant; var botPlayer = new BotControl(); botPlayer = RenderBot(botParticipant); PurpleTeamListView.Items.Add(botPlayer); } } foreach (GameObserver observer in dto.Observers) { if (observer.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId) { isSpectator = true; } var spectatorItem = new CustomLobbyObserver(); spectatorItem = RenderObserver(observer); SpectatorListView.Items.Add(spectatorItem); } if (isSpectator) { AddBotPurpleTeam.Visibility = Visibility.Hidden; AddBotBlueTeam.Visibility = Visibility.Hidden; JoinBlueTeamFromSpectator.Visibility = Visibility.Visible; JoinPurpleTeamFromSpectator.Visibility = Visibility.Visible; } else { AddBotPurpleTeam.Visibility = Visibility.Visible; AddBotBlueTeam.Visibility = Visibility.Visible; JoinBlueTeamFromSpectator.Visibility = Visibility.Hidden; JoinPurpleTeamFromSpectator.Visibility = Visibility.Hidden; } } break; case "PRE_CHAMP_SELECT": case "CHAMP_SELECT": if (!LaunchedTeamSelect) { Client.ChampSelectDTO = dto; Client.LastPageContent = Client.Container.Content; Client.SwitchPage(new ChampSelectPage(dto.RoomName, dto.RoomPassword).Load(this)); Client.GameStatus = "championSelect"; Client.SetChatHover(); LaunchedTeamSelect = true; } break; } })); }
/// <summary> /// Removes a specific CustomLobbyPlayer from the list. /// </summary> /// <param name="player">Player to remove from list</param> public void RemovePlayer(CustomLobbyPlayer player) { players.Remove(player); }