Пример #1
0
 public override void Awake()
 {
     requestCode   = RequestCode.Room;
     actionCode    = ActionCode.QuitRoom;
     roomInfoPanel = GetComponent <RoomInfoPanel>();
     base.Awake();
 }
Пример #2
0
 public override void Awake()
 {
     requestCode   = RequestCode.Game;
     actionCode    = ActionCode.StartGame;
     roomInfoPanel = GetComponent <RoomInfoPanel>();
     base.Awake();
 }
Пример #3
0
    void Start()
    {
        AssignRefs();
        ConnectionStatusText.text = "Connecting";

        PlayerNameInput.text = (PlayerPrefs.HasKey("playerName")) ?
                               PlayerPrefs.GetString("playerName") :
                               "Player " + Random.Range(1000, 10000);
        PhotonNetwork.ConnectUsingSettings();
        LobbyInfoPanel.SetActive(false);
        RoomInfoPanel.SetActive(false);
        SceneManager.sceneLoaded += OnSceneLoaded;
    }
Пример #4
0
    public override void OnJoinedRoom()
    {
        if (SceneManager.GetActiveScene().buildIndex == 0)
        {
            ConnectionStatusText.text = "In Room: " + PhotonNetwork.CurrentRoom.Name;
            LobbyInfoPanel.SetActive(false);
            RoomInfoPanel.SetActive(true);
            SetRoomGoalType(defaultGoalType);
            SetRoomRoundDuration(defaultRoomDuration);
        }

        if (playerListEntries == null)
        {
            playerListEntries = new Dictionary <int, GameObject>();
        }

        // Create and add PlayerListEntryPrefabs for every player in the room to scrollview
        foreach (PhotonPlayer p in PhotonNetwork.PlayerList)
        {
            GameObject entry = CreateEntry(p);

            if (p.CustomProperties.TryGetValue("PLAYER_READY_KEY", out object isPlayerReady))
            {
                entry.GetComponent <PlayerListEntry>().SetPlayerReady((bool)isPlayerReady);
            }

            playerListEntries.Add(p.ActorNumber, entry);
        }
        if (PhotonNetwork.IsMasterClient)
        {
            StartGameButton.gameObject.SetActive(true);
            StartGameButton.interactable = CheckPlayersReady();
            SetRoomSettingsUI(true);
        }
        else
        {
            StartGameButton.gameObject.SetActive(false);
            SetRoomSettingsUI(false);
        }

        PhotonHashtable props = new PhotonHashtable {
            { "PLAYER_LOADED_LEVEL_KEY", false }
        };

        PhotonNetwork.LocalPlayer.SetCustomProperties(props);

        object temp;

        if (PhotonNetwork.CurrentRoom.CustomProperties.TryGetValue("RoomGoalType", out temp))
        {
            if (temp is byte)
            {
                GoalType type = (GoalType)System.Enum.ToObject(typeof(GoalType), temp);
                switch (type)
                {
                case GoalType.REGULAR:
                    RegGoalToggle.isOn = true;
                    break;

                case GoalType.VERITCAL_WALL:
                    VWallGoalToggle.isOn = true;
                    break;

                case GoalType.HORIZONTAL_WALL:
                    HWallGoalToggle.isOn = true;
                    break;
                }
            }
        }
        if (PhotonNetwork.CurrentRoom.CustomProperties.TryGetValue("RoomRoundDuration", out temp))
        {
            int duration = (int)temp;
            RoundDurationText.text    = duration.ToString() + (duration == 1 ? " minute" : " minutes");
            RoundDurationSlider.value = duration;
        }
    }
Пример #5
0
 public override void OnJoinedLobby()
 {
     ConnectionStatusText.text = "In Lobby: " + PhotonNetwork.CloudRegion + " Region";
     LobbyInfoPanel.SetActive(true);
     RoomInfoPanel.SetActive(false);
 }
Пример #6
0
 public void SetPanel(BasePanel panel)
 {
     roomInfoPanel = panel as RoomInfoPanel;
 }