void StartNewPlayer(PlayerConnectMessageArgs e)
        {
            NetPlayerState netPlayerState = new NetPlayerState(e.netPlayer, e.data);
            string         id             = e.netPlayer.GetSessionId();

            if (id.Length > 0)
            {
                // Check if there is a slot with this id
                for (int pndx = 0; pndx < m_playerState.Length; ++pndx)
                {
                    PlayerState playerState = m_playerState[pndx];
                    if (playerState.id == id)
                    {
                        if (playerState.netPlayer == null)
                        {
                            StartActivePlayer(m_getGameObject(pndx), playerState, netPlayerState);
                            return;
                        }
                        else
                        {
                            m_log.Error("Player with same ID joined but they're already playing???");
                        }
                    }
                }
            }

            // Add player to list of all people connected
            AddWaitingPlayer(netPlayerState);
            StartWaitingPlayers();
        }
コード例 #2
0
 void StartNewPlayer(object sender, PlayerConnectMessageArgs e)
 {
     ExampleSimpleGameSettings settings = ExampleSimpleGameSettings.settings();
     Vector3 position = new Vector3(m_rand.Next(settings.areaWidth), 0, m_rand.Next(settings.areaHeight));
     // Spawn a new player then add a script to it.
     GameObject gameObject = (GameObject)Instantiate(prefabToSpawnForPlayer, position, Quaternion.identity);
     // Add the ExampleSimplePlayer script to this object. Note: We could possible add this to the prefab.
     // Not sure which is best.
     ExampleSimplePlayer player = gameObject.AddComponent<ExampleSimplePlayer>();
     player.Init(e.netPlayer);
 }
コード例 #3
0
 void StartNewPlayer(PlayerConnectMessageArgs e)
 {
     StartPlayer(e.netPlayer, e.data);
 }
コード例 #4
0
 void StartNewPlayer(object sender, PlayerConnectMessageArgs e)
 {
     StartPlayer(e.netPlayer, e.data);
 }
コード例 #5
0
        void StartNewPlayer(object sender, PlayerConnectMessageArgs e)
        {
            NetPlayerState netPlayerState = new NetPlayerState(e.netPlayer, e.data);
            string id = e.netPlayer.GetSessionId();
            if (id.Length > 0) {
            // Check if there is a slot with this id
            for (int pndx = 0; pndx < m_playerState.Length; ++pndx) {
                PlayerState playerState = m_playerState[pndx];
                if (playerState.id == id) {
                    if (playerState.netPlayer == null) {
                        StartActivePlayer(m_getGameObject(pndx), playerState, netPlayerState);
                        return;
                    } else {
                        m_log.Error("Player with same ID joined but they're already playing???");
                    }
                }
            }
            }

            // Add player to list of all people connected
            AddWaitingPlayer(netPlayerState);
            StartWaitingPlayers();
        }