Beispiel #1
0
        public void SetupPlayer()
        {
            BoltConsole.Write("SetupPlayer", Color.green);

            LobbyPlayerList._instance.AddPlayer(this);
            localPlayer = this;

            nameInput.interactable = true;
            remoteIcone.gameObject.SetActive(false);
            localIcone.gameObject.SetActive(true);

            removePlayerButton.gameObject.SetActive(false);
            removePlayerButton.interactable = false;

            ChangeReadyButtonColor(JoinColor);

            readyButton.transform.GetChild(0).GetComponent <Text>().text = "JOIN";
            readyButton.interactable = true;

            //we switch from simple name display to name input
            colorButton.interactable = true;
            nameInput.interactable   = true;

            nameInput.onEndEdit.RemoveAllListeners();
            nameInput.onEndEdit.AddListener(OnNameChanged);

            colorButton.onClick.RemoveAllListeners();
            colorButton.onClick.AddListener(OnColorClicked);

            readyButton.onClick.RemoveAllListeners();
            readyButton.onClick.AddListener(OnReadyClicked);

            OnClientReady(state.Ready);
        }
Beispiel #2
0
        public override void Disconnected(BoltConnection connection)
        {
            LobbyPhotonPlayer player = connection.GetLobbyPlayer();

            if (player != null)
            {
                BoltLog.Info("Disconnected");

                player.RemovePlayer();
            }
        }
Beispiel #3
0
        public override void EntityAttached(BoltEntity entity)
        {
            BoltConsole.Write("EntityAttached");

            if (!entity.isControlled)
            {
                LobbyPhotonPlayer photonPlayer = entity.gameObject.GetComponent <LobbyPhotonPlayer>();

                if (photonPlayer != null)
                {
                    photonPlayer.SetupOtherPlayer();
                }
            }
        }
Beispiel #4
0
        public void AddPlayer(LobbyPhotonPlayer player)
        {
            if (_players.Contains(player))
            {
                return;
            }

            _players.Add(player);

            player.transform.SetParent(playerListContentTransform, false);
            addButtonRow.transform.SetAsLastSibling();

            PlayerListModified();
        }
Beispiel #5
0
    public static void Spawn()
    {
        var        pos          = new Vector3(Random.Range(-16, 16), 0.6f, Random.Range(-16, 16));
        BoltEntity playerEntity = BoltNetwork.Instantiate(BoltPrefabs.BomberPlayer, pos, Quaternion.identity);

        playerEntity.TakeControl();

        BomberPlayerController playerController = playerEntity.GetComponent <BomberPlayerController>();

        Photon.Lobby.LobbyPhotonPlayer lobbyPlayer = Photon.Lobby.LobbyPhotonPlayer.localPlayer;

        if (lobbyPlayer)
        {
            playerController.Setup(lobbyPlayer.playerName, lobbyPlayer.playerColor);
        }
        else
        {
            playerController.Setup("Player #" + Random.Range(1, 100), Random.ColorHSV());
        }
    }
Beispiel #6
0
        public override void Connected(BoltConnection connection)
        {
            if (BoltNetwork.IsClient)
            {
                BoltConsole.Write("Connected Client: " + connection, Color.blue);

                infoPanel.gameObject.SetActive(false);
                ChangeTo(lobbyPanel);
            }
            else if (BoltNetwork.IsServer)
            {
                BoltConsole.Write("Connected Server: " + connection, Color.blue);

                BoltEntity entity = BoltNetwork.Instantiate(BoltPrefabs.PlayerInfo);

                LobbyPhotonPlayer lobbyPlayer = entity.GetComponent <LobbyPhotonPlayer>();
                lobbyPlayer.connection = connection;

                connection.UserData = lobbyPlayer;
                connection.SetStreamBandwidth(1024 * 1024);

                entity.AssignControl(connection);
            }
        }
Beispiel #7
0
        public void RemovePlayer(LobbyPhotonPlayer player)
        {
            _players.Remove(player);

            PlayerListModified();
        }