public Lobby_Match(ushort matchID, ushort maxPlayersInMatch, Lobby_Player matchOwner) { this.matchID = matchID; this.maxPlayersInMatch = maxPlayersInMatch; this.matchOwner = matchOwner; this.AddPlayerToMatch(matchOwner); }
public void ChangeLobbyReadyStatus(Lobby_Player lobby_Player) { this.matchPlayers[lobby_Player] = !this.matchPlayers[lobby_Player]; foreach (Lobby_Player lp in this.matchPlayers.Keys) { Lobby_Match.SendLobbyReadyStatusToPlayer(this.matchPlayers[lobby_Player], lp); } }
public void FinishMatch(Lobby_Player matchWinner) { foreach (Lobby_Player player in matchPlayers.Keys) { RemovePlayerFromMatch(player, true); } //TODO: Set Match Winner }
public static void SendLobbyReadyStatusToPlayer(bool readyStatus, Lobby_Player playerToSend) { using (DarkRiftWriter w = DarkRiftWriter.Create()) { w.Write(readyStatus); using (Message mes = Message.Create(UDRMS_Tags.connectLobbyMatch, w)) playerToSend.client.SendMessage(mes, SendMode.Reliable); } }
public bool AddPlayerToMatch(Lobby_Player playerToAdd) { if (matchPlayers.Count >= maxPlayersInMatch) { return(false); } else { matchPlayers.Add(playerToAdd, false); } playerToAdd.AssignMatch(this); return(true); }
public void RemovePlayerFromMatch(Lobby_Player playerToRemove, bool finishedMatch = false) { this.matchPlayers.Remove(playerToRemove); //TODO: Dont overflow with change host if (matchOwner == playerToRemove) { //TODO: Destroy Match or Change Owner } if (matchPlayers.Count <= 0) { //TODO: Destroy Match } }
public static void SendToPlayerLobbyMatchInformation(Lobby_Player lobby_Player) { Lobby_Match match = lobby_Player.getCurrentMatch(); using (DarkRiftWriter w = DarkRiftWriter.Create()) { foreach (var item in match.matchPlayers.Keys) { w.Write(item.client.ID); //ID do Player //w.Write(item) w.Write(match.matchPlayers[item]); //Status (Ready) } using (Message m = Message.Create(UDRMS_Tags.getLobbyMatchInfo, w)) lobby_Player.client.SendMessage(m, SendMode.Reliable); } }