Example #1
0
        public void AddPlayer(LobbyPlayer player)
        {
            if (_players.Contains(player))
            {
                return;
            }
            player.GetComponent <LobbyPlayer>().PlayerNumber = PlayerNumberCount;
            _players.Add(player);
            PlayerNumberCount++;
            player.transform.SetParent(playerListContentTransform, false);
            addButtonRow.transform.SetAsLastSibling();

            PlayerListModified();
        }
Example #2
0
        public override GameObject OnLobbyServerCreateGamePlayer(NetworkConnection conn, short playerControllerId)
        {
            //Control the color and assing a prefab for each color
            //to update with spash art of players
            int index = -1;

            for (int i = 0; i < lobbySlots.Length; ++i)
            {
                LobbyPlayer p = lobbySlots[i] as LobbyPlayer;

                if (p != null)
                {
                    if (p.connectionToClient.connectionId == conn.connectionId)
                    {
                        if (p.GetComponent <LobbyPlayer>().playerColor == Color.red)
                        {
                            index = 0;
                        }
                        else if (p.GetComponent <LobbyPlayer>().playerColor == Color.blue)
                        {
                            index = 1;
                        }
                        else if (p.GetComponent <LobbyPlayer>().playerColor == Color.green)
                        {
                            index = 2;
                        }
                    }
                }
            }

            GameObject _temp = Instantiate(spawnPrefabs[index], startPositions[conn.connectionId].position, Quaternion.identity);

            NetworkServer.ReplacePlayerForConnection(conn, _temp, playerControllerId);

            return(_temp);
        }