예제 #1
0
        private void StartGame(PendingGame game)
        {
            game.GameInfo.GameServerProcessCode = "LobbyQueueManager.StartGame";
            foreach (LobbyPlayerInfo playerInfo in game.TeamInfo.TeamPlayerInfo)
            {
                if (!playerInfo.IsNPCBot)
                {
                    LobbyServerConnection      player          = LobbyServer.GetPlayerByAccountId(playerInfo.AccountId);
                    GameAssignmentNotification assNotification = new GameAssignmentNotification
                    {
                        GameInfo          = game.GameInfo,
                        GameResult        = GameResult.NoResult,
                        GameplayOverrides = DummyLobbyData.CreateLobbyGameplayOverrides(),
                        PlayerInfo        = player.GetLobbyPlayerInfo().Clone(),
                        Reconnection      = false,
                        Observer          = false
                    };
                    assNotification.PlayerInfo.ControllingPlayerId = 0;
                    player.SendMessage(assNotification);;
                }
            }
            game.GameStatus = GameStatus.Launching; // Put in wait state until game server starts
            game.SendNotification();

            new Task(() => {
                //GameManagerHolder.CreateGameManager(game.GameInfo, game.TeamInfo, game.PlayerSessionTokens); // Launch new game
                game.GameStatus = GameStatus.Launched; // Put in wait state until game server starts
                game.SendNotification();

                PendingGames.Remove(game);
            }).Start();
        }
예제 #2
0
        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);
            }
        }