Exemple #1
0
        public void OnFNPlayerNameChanged(IClientMockPlayer player)
        {
            LobbyPlayer convertedPlayer = GrabPlayer(player);

            convertedPlayer.Name = player.Name;
            if (_myself == convertedPlayer)
            {
                Myself.ChangeName(convertedPlayer.Name);
            }
            else
            {
                LobbyPlayerItem item = GrabLobbyPlayerItem(convertedPlayer);
                if (item != null)
                {
                    item.ChangeName(convertedPlayer.Name);
                }
            }
        }
        public void OnFNAvatarIDChanged(IClientMockPlayer player)
        {
            LobbyPlayer convertedPlayer = GrabPlayer(player);

            convertedPlayer.AvatarID = player.AvatarID;
            if (_myself == convertedPlayer)
            {
                Myself.ChangeAvatarID(convertedPlayer.AvatarID);
            }
            else
            {
                LobbyPlayerItem item = GrabLobbyPlayerItem(convertedPlayer);
                if (item != null)
                {
                    item.ChangeAvatarID(convertedPlayer.AvatarID);
                }
            }
        }
        public void OnFNPlayerDisconnected(IClientMockPlayer player)
        {
            LobbyPlayer convertedPlayer = GrabPlayer(player);

            MainThreadManager.Run(() =>
            {
                if (LobbyPlayers.Contains(convertedPlayer))
                {
                    _lobbyPlayers.Remove(convertedPlayer);
                    _lobbyPlayersMap.Remove(convertedPlayer.NetworkId);

                    LobbyPlayerItem item = GrabLobbyPlayerItem(convertedPlayer);
                    if (item != null)
                    {
                        PutBackToPool(item);
                    }
                }
            });
        }
 public void ChangeTeam(LobbyPlayerItem item, int nextTeam)
 {
     LobbyService.Instance.SetTeamId(nextTeam);
 }
 public void ChangeAvatarID(LobbyPlayerItem item, int nextID)
 {
     LobbyService.Instance.SetAvatar(nextID);
 }
        public void KickPlayer(LobbyPlayerItem item)
        {
            LobbyPlayer playerKicked = item.AssociatedPlayer;

            LobbyService.Instance.KickPlayer(playerKicked.NetworkId);
        }
 public void ChangeName(LobbyPlayerItem item, string newName)
 {
     LobbyService.Instance.SetName(newName);
 }
Exemple #8
0
        public void OnFNPlayerConnected(IClientMockPlayer player)
        {
            LobbyPlayer convertedPlayer = GrabPlayer(player);

            if (convertedPlayer == _myself || _myself == null)
            {
                return;                 //Ignore re-adding ourselves
            }
            MainThreadManager.Run(() =>
            {
                bool foundPlayer = false;
                for (int i = 0; i < _lobbyPlayersPool.Count; ++i)
                {
                    if (_lobbyPlayersPool[i].AssociatedPlayer.NetworkId == player.NetworkId)
                    {
                        foundPlayer = true;
                    }
                }

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

                    OnFNTeamChanged(convertedPlayer, 0);
                    LobbyPlayerItem item = GetNewPlayerItem();
                    //TODO: Replace isServer with an actual user check
                    item.Setup(convertedPlayer, LobbyService.Instance.IsServer);
                    if (LobbyService.Instance.IsServer)
                    {
                        item.KickButton.SetActive(true);
                    }
                    item.SetParent(Grid);
                }
                else
                {
                    if (!LobbyPlayers.Contains(convertedPlayer))
                    {
                        _lobbyPlayers.Add(convertedPlayer);
                        if (_lobbyPlayersMap.ContainsKey(convertedPlayer.NetworkId))
                        {
                            _lobbyPlayersMap[convertedPlayer.NetworkId] = convertedPlayer;
                        }
                        else
                        {
                            _lobbyPlayersMap.Add(convertedPlayer.NetworkId, convertedPlayer);
                        }
                        OnFNTeamChanged(convertedPlayer, 0);
                        LobbyPlayerItem item = GetNewPlayerItem();
                        //TODO: Replace isServer with an actual user check
                        item.Setup(convertedPlayer, LobbyService.Instance.IsServer);
                        if (LobbyService.Instance.IsServer)
                        {
                            item.KickButton.SetActive(true);
                        }
                        item.SetParent(Grid);
                    }
                }
            });
        }