コード例 #1
0
ファイル: GameManager.cs プロジェクト: LimitlessRegret/EvoS
        private void SpawnPlayerCharacter(LobbyServerPlayerInfo playerInfo)
        {
            // TODO would normally check playerInfo.CharacterInfo.CharacterType

            SpawnObject <ActorTeamSensitiveData>(MiscLoader, "ActorTeamSensitiveData_Friendly",
                                                 out var scoundrelFriendly);
            SpawnObject(AssetsLoader, "Scoundrel", out var scoundrel);
            var scoundrelActor      = scoundrel.GetComponent <ActorData>();
            var scoundrelPlayerData = scoundrel.GetComponent <PlayerData>();

            scoundrelActor.SetClientFriendlyTeamSensitiveData(scoundrelFriendly);
            scoundrelPlayerData.m_player    = GameFlow.GetPlayerFromConnectionId(1); // TODO hardcoded connection id
            scoundrelPlayerData.PlayerIndex = 0;

            scoundrelActor.ServerLastKnownPosSquare = Board.GetBoardSquare(5, 5);
            scoundrelActor.InitialMoveStartSquare   = Board.GetBoardSquare(5, 5);
            scoundrelActor.UpdateDisplayName("Foo bar player");
            scoundrelActor.ActorIndex  = 0;
            scoundrelActor.PlayerIndex = 0;
            scoundrelFriendly.SetActorIndex(scoundrelActor.ActorIndex);
            scoundrelActor.SetTeam(Team.TeamA);

            GameFlowData.AddPlayer(scoundrel);

            var netChar = scoundrel.GetComponent <NetworkIdentity>();
            var netAtsd = scoundrelFriendly.GetComponent <NetworkIdentity>();

            foreach (var player in _players.Values)
            {
                netChar.AddObserver(player.Connection);
                netAtsd.AddObserver(player.Connection);
            }
        }
コード例 #2
0
ファイル: GameManager.cs プロジェクト: jacko12549/EvoS
        private void SpawnPlayerCharacter(LobbyPlayerInfo playerInfo)
        {
            //#
            Log.Print(LogType.Error, "SpawnPlayerCharacter " + playerInfo.CharacterInfo.CharacterType.ToString());

            GamePlayer gamePlayer = GetGamePlayerByPlayerId(playerInfo.PlayerId);



            SpawnObject <ActorTeamSensitiveData>(MiscLoader, "ActorTeamSensitiveData_Friendly", out ActorTeamSensitiveData characterFriendly);
            SpawnObject(AssetsLoader, playerInfo.CharacterInfo.CharacterType.ToString(), out GameObject character);

            ActorData characterActorData = character.GetComponent <ActorData>();

            characterActorData.SetClientFriendlyTeamSensitiveData(characterFriendly);
            characterActorData.ServerLastKnownPosSquare = Board.GetBoardSquare(5, 5);
            characterActorData.InitialMoveStartSquare   = Board.GetBoardSquare(5, 5);
            characterActorData.UpdateDisplayName(playerInfo.Handle);
            characterActorData.PlayerIndex = playerInfo.PlayerId;
            //characterActorData.ActorIndex = playerInfo.PlayerId;

            PlayerData characterPlayerData = character.GetComponent <PlayerData>();

            characterPlayerData.m_player    = GameFlow.GetPlayerFromConnectionId(gamePlayer.Connection.connectionId); // TODO hardcoded connection id
            characterPlayerData.PlayerIndex = playerInfo.PlayerId;



            characterFriendly.SetActorIndex(characterActorData.ActorIndex);



            characterActorData.SetTeam(playerInfo.TeamId);

            GameFlowData.AddPlayer(character);

            var netChar = character.GetComponent <NetworkIdentity>();
            var netAtsd = characterFriendly.GetComponent <NetworkIdentity>();

            lock (GamePlayersByPlayerId) {
                foreach (GamePlayer player in GamePlayersByPlayerId.Values)
                {
                    netChar.AddObserver(player.Connection);
                    netAtsd.AddObserver(player.Connection);
                }
            }
        }