コード例 #1
0
        private void SetupComplete()
        {
            LobbyService.Instance.SetLobbyMaster(this);
            LobbyService.Instance.Initialize(NetworkManager.Instance.Networker);

            //If I am the host, then I should show the kick button for all players here
            LobbyPlayerItem item = GetNewPlayerItem();             //This will just auto generate the 10 items we need to start with

            item.SetParent(Grid);
            PutBackToPool(item);

            _myself = GrabPlayer(LobbyService.Instance.MyMockPlayer);
            if (!LobbyPlayers.Contains(_myself))
            {
                LobbyPlayers.Add(_myself);
            }
            Myself.Init(this);
            Myself.Setup(_myself, true);

            List <IClientMockPlayer> currentPlayers = LobbyService.Instance.MasterLobby.LobbyPlayers;

            for (int i = 0; i < currentPlayers.Count; ++i)
            {
                IClientMockPlayer currentPlayer = currentPlayers[i];
                if (currentPlayer == _myself)
                {
                    continue;
                }
                OnFNPlayerConnected(currentPlayers[i]);
            }
        }
コード例 #2
0
        public void OnFNPlayerConnected(IClientMockPlayer player)
        {
            LobbyPlayer convertedPlayer = GrabPlayer(player);

            if (convertedPlayer == _myself || _myself == null)
            {
                return;                 //Ignore re-adding ourselves
            }
            bool playerCreated = false;

            for (int i = 0; i < _lobbyPlayersPool.Count; ++i)
            {
                if (_lobbyPlayersPool[i].AssociatedPlayer.NetworkId == player.NetworkId)
                {
                    playerCreated = true;
                }
            }

            playerCreated = convertedPlayer.Created;
            if (playerCreated)
            {
                return;
            }

            convertedPlayer.Created = true;

            if (!LobbyPlayers.Contains(convertedPlayer))
            {
                _lobbyPlayers.Add(convertedPlayer);
            }
            if (_lobbyPlayersMap.ContainsKey(convertedPlayer.NetworkId))
            {
                _lobbyPlayersMap[convertedPlayer.NetworkId] = convertedPlayer;
            }
            else
            {
                _lobbyPlayersMap.Add(convertedPlayer.NetworkId, convertedPlayer);
            }

            OnFNTeamChanged(convertedPlayer);

            MainThreadManager.Run(() =>
            {
                LobbyPlayerItem item = GetNewPlayerItem();
                item.Setup(convertedPlayer, false);
                if (LobbyService.Instance.IsServer)
                {
                    item.KickButton.SetActive(true);
                }
                item.SetParent(Grid);
            });
        }