コード例 #1
0
ファイル: GameManager.cs プロジェクト: LimitlessRegret/EvoS
        public void AddPlayer(ClientConnection connection, LoginRequest loginReq, AddPlayerMessage msg)
        {
            _players.Add(loginReq.PlayerId, new GamePlayer(connection, loginReq, msg));
            connection.ActiveGame = this;

            var gfPlayer = GameFlow.GetPlayerFromConnectionId(connection.connectionId);

            gfPlayer.m_id                    = (byte)loginReq.PlayerId;
            gfPlayer.m_valid                 = true;
            gfPlayer.m_accountId             = long.Parse(loginReq.AccountId);
            gfPlayer.m_connectionId          = connection.connectionId;
            GameFlow.playerDetails[gfPlayer] = new PlayerDetails(PlayerGameAccountType.Human)
            {
                m_team              = Team.TeamA,
                m_handle            = "test handle",
                m_accountId         = gfPlayer.m_accountId,
                m_lobbyPlayerInfoId = 0
            };

            // This isn't actually correct, but the client logs a warning with what it expected and continues
            connection.Send(14, new CRCMessage
            {
                scripts = new[]
                {
                    new CRCMessageEntry("ActorData", 0),
                    new CRCMessageEntry("BrushCoordinator", 0),
                    new CRCMessageEntry("ActorController", 0),
                    new CRCMessageEntry("AbilityData", 0),
                    new CRCMessageEntry("ActorStats", 0),
                    new CRCMessageEntry("ActorStatus", 0),
                    new CRCMessageEntry("ActorBehavior", 0),
                    new CRCMessageEntry("PlayerData", 0),
                    new CRCMessageEntry("PowerUp", 0),
                    new CRCMessageEntry("GameFlow", 0),
                    new CRCMessageEntry("TeamStatusDisplay", 0),
                    new CRCMessageEntry("BarrierManager", 0),
                    new CRCMessageEntry("GameFlowData", 0),
                    new CRCMessageEntry("ObjectivePoints", 0),
                    new CRCMessageEntry("CoinCarnageManager", 0),
                    new CRCMessageEntry("ActorTeamSensitiveData", 0),
                    new CRCMessageEntry("ActorAdditionalVisionProviders", 0),
                    new CRCMessageEntry("ActorCinematicRequests", 0),
                    new CRCMessageEntry("FreelancerStats", 0),
                    new CRCMessageEntry("Manta_SyncComponent", 0),
                    new CRCMessageEntry("Rampart_SyncComponent", 0),
                    new CRCMessageEntry("SinglePlayerManager", 0)
                }
            });

            connection.RegisterHandler <AssetsLoadingProgress>(61, _players[loginReq.PlayerId], OnAssetLoadingProgress);
            connection.RegisterHandler <AssetsLoadedNotification>(53, _players[loginReq.PlayerId],
                                                                  OnAssetsLoadedNotification);
        }
コード例 #2
0
ファイル: GameManager.cs プロジェクト: jacko12549/EvoS
        public void OnPlayerConnect(GameServerConnection connection)
        {
            //Log.Print(LogType.Debug, $"Connected player {connection.PlayerInfo.GetHandle()} with playerID {connection.PlayerId} as {connection.PlayerInfo.GetCharacterType().ToString()}");

            GamePlayer gamePlayer;

            GamePlayersByPlayerId.TryGetValue(connection.PlayerId, out gamePlayer);

            if (gamePlayer == null)
            {
                //gamePlayer = new GamePlayer(connection, connection.PlayerId, connection.PlayerInfo.GetAccountId());
                AddGamePlayer(connection.PlayerId, gamePlayer);
            }
            else
            {
                int oldConnectionId = gamePlayer.Connection.connectionId;
                connection.connectionId = oldConnectionId;
            }

            //gamePlayer.PlayerInfo = connection.PlayerInfo;
            //connection.ActiveGame = this;


            Player gfPlayer = GameFlow.GetPlayerFromConnectionId(connection.connectionId);

            gfPlayer.m_id    = (byte)connection.PlayerId;
            gfPlayer.m_valid = true;
            //gfPlayer.m_accountId = connection.PlayerInfo.GetAccountId();
            gfPlayer.m_connectionId = connection.connectionId;

            GameFlow.playerDetails[gfPlayer] = new PlayerDetails(PlayerGameAccountType.Human)
            {
                //m_team =  this.TeamInfo.GetPlayer(connection.PlayerInfo.GetAccountId()).TeamId,
                //m_handle = this.TeamInfo.GetPlayer(connection.PlayerInfo.GetAccountId()).Handle,
                m_accountId = gfPlayer.m_accountId,
                //m_lobbyPlayerInfoId = this.TeamInfo.TeamPlayerInfo.FindIndex((LobbyPlayerInfo p)=>{ return p.AccountId == connection.PlayerInfo.GetAccountId(); })
            };

            // This isn't actually correct, but the client logs a warning with what it expected and continues

            connection.Send(14, new CRCMessage
            {
                scripts = new[]
                {
                    new CRCMessageEntry("ActorData", 0),
                    new CRCMessageEntry("BrushCoordinator", 0),
                    new CRCMessageEntry("ActorController", 0),
                    new CRCMessageEntry("AbilityData", 0),
                    new CRCMessageEntry("ActorStats", 0),
                    new CRCMessageEntry("ActorStatus", 0),
                    new CRCMessageEntry("ActorBehavior", 0),
                    new CRCMessageEntry("PlayerData", 0),
                    new CRCMessageEntry("PowerUp", 0),
                    new CRCMessageEntry("GameFlow", 0),
                    new CRCMessageEntry("TeamStatusDisplay", 0),
                    new CRCMessageEntry("BarrierManager", 0),
                    new CRCMessageEntry("GameFlowData", 0),
                    new CRCMessageEntry("ObjectivePoints", 0),
                    new CRCMessageEntry("CoinCarnageManager", 0),
                    new CRCMessageEntry("ActorTeamSensitiveData", 0),
                    new CRCMessageEntry("ActorAdditionalVisionProviders", 0),
                    new CRCMessageEntry("ActorCinematicRequests", 0),
                    new CRCMessageEntry("FreelancerStats", 0),
                    new CRCMessageEntry("SinglePlayerManager", 0)
                }
            });

            connection.RegisterHandler <AssetsLoadingProgress>((short)MyMsgType.ClientAssetsLoadingProgressUpdate, GetGamePlayerByPlayerId(connection.PlayerId), OnAssetLoadingProgress);
            connection.RegisterHandler <AssetsLoadedNotification>((short)MyMsgType.AssetsLoadedNotification, GetGamePlayerByPlayerId(connection.PlayerId), OnAssetsLoadedNotification);

            /*lock (AllPlayersLoadedLock)
             * {
             *  if (AllPlayersLoaded) {
             *      foreach (LobbyPlayerInfo player in TeamInfo.TeamPlayerInfo)
             *      {
             *          if (player.ReadyState == ReadyState.Ready)
             *          {
             *              connection.Send((short)MyMsgType.AssetsLoadedNotification, new AssetsLoadedNotification { AccountId = player.AccountId, PlayerId = player.PlayerId });
             *          }
             *      }
             *  }
             *
             * }
             * //*/
        }