public void SendNotification() { foreach (LobbyPlayerInfo playerInfo in TeamInfo.TeamPlayerInfo) { if (!playerInfo.IsNPCBot) { LobbyServerConnection player = LobbyServer.GetPlayerByAccountId(playerInfo.AccountId); LobbyTeamInfo teamInfoClone = TeamInfo.Clone(); foreach (LobbyPlayerInfo pi in teamInfoClone.TeamPlayerInfo) { if (pi.PlayerId == playerInfo.PlayerId) { pi.ControllingPlayerId = 0; } } LobbyPlayerInfo playerInfoClone = playerInfo.Clone(); playerInfoClone.ControllingPlayerId = 0; //Log.Print(LogType.Debug, $"Sending notification to {Players[i]}"); GameInfoNotification gameInfoNotification = new GameInfoNotification() { GameInfo = GameInfo, PlayerInfo = playerInfoClone, TeamInfo = teamInfoClone }; _ = player.SendMessage(gameInfoNotification); } } }
public static GameInfoNotification CreatePracticeGameInfoNotification(ClientConnection connection) { var response = new GameInfoNotification { GameInfo = CreatePracticeGameLobbyInfo(), PlayerInfo = CreateLobbyPlayerInfo(connection), TeamInfo = new LobbyTeamInfo { TeamPlayerInfo = new List <LobbyPlayerInfo> { CreateLobbyPlayerInfo(connection) } } }; response.GameInfo.GameServerAddress = "ws://127.0.0.1:6061"; response.GameInfo.GameStatus = GameStatus.Launched; response.GameInfo.GameServerHost = "Practice Game Host"; return(response); }
public static void StartPractice(LobbyServerProtocolBase client) { LobbyGameInfo practiceGameInfo = new LobbyGameInfo { AcceptedPlayers = 1, AcceptTimeout = new TimeSpan(0, 0, 0), ActiveHumanPlayers = 1, ActivePlayers = 1, CreateTimestamp = DateTime.Now.Ticks, GameConfig = new LobbyGameConfig { GameOptionFlags = GameOptionFlag.NoInputIdleDisconnect & GameOptionFlag.NoInputIdleDisconnect, GameServerShutdownTime = -1, GameType = GameType.Practice, InstanceSubTypeBit = 1, IsActive = true, Map = Maps.VR_Practice, ResolveTimeoutLimit = 1600, // TODO ? RoomName = "", Spectators = 0, SubTypes = GameModeManager.GetGameTypeAvailabilities()[GameType.Practice].SubTypes, TeamABots = 0, TeamAPlayers = 1, TeamBBots = 2, TeamBPlayers = 0 } }; LobbyTeamInfo teamInfo = new LobbyTeamInfo(); teamInfo.TeamPlayerInfo = new List <LobbyPlayerInfo> { SessionManager.GetPlayerInfo(client.AccountId), CharacterManager.GetPunchingDummyPlayerInfo(), CharacterManager.GetPunchingDummyPlayerInfo() }; teamInfo.TeamPlayerInfo[0].TeamId = Team.TeamA; teamInfo.TeamPlayerInfo[0].PlayerId = 1; teamInfo.TeamPlayerInfo[1].PlayerId = 2; teamInfo.TeamPlayerInfo[2].PlayerId = 3; string serverAddress = ServerManager.GetServer(practiceGameInfo, teamInfo); if (serverAddress == null) { Log.Print(LogType.Error, "No available server for practice gamemode"); } else { practiceGameInfo.GameServerAddress = "ws://" + serverAddress; practiceGameInfo.GameStatus = GameStatus.Launching; GameAssignmentNotification notification1 = new GameAssignmentNotification { GameInfo = practiceGameInfo, GameResult = GameResult.NoResult, Observer = false, PlayerInfo = teamInfo.TeamPlayerInfo[0], Reconnection = false, GameplayOverrides = client.GetGameplayOverrides() }; client.Send(notification1); practiceGameInfo.GameStatus = GameStatus.Launched; GameInfoNotification notification2 = new GameInfoNotification() { TeamInfo = teamInfo, GameInfo = practiceGameInfo, PlayerInfo = teamInfo.TeamPlayerInfo[0] }; client.Send(notification2); } }