예제 #1
0
        public override void InitUI()
        {
            base.InitUI();

            Properties = new UIProperties(
                UIframework.UIManager.SceneUIs.RoomBrowserUI,
                UIframework.UIManager.DisplayUIMode.Normal,
                UIframework.UIManager.UITypes.UnderBlurEffect,
                false, true);

            // Keep track the room count everytime the room list update.
            m_LastUpdateRoomCount = 0;

            m_RoomList    = GetComponentInChildren <RoomList>();
            m_RoomPreview = GetComponentInChildren <RoomPreview>();
            m_NoRoomAvailablePopupWindow = GetComponentInChildren <PupupWindowUI>();
            m_Animator = GetComponent <Animator>();


#if UNITY_EDITOR
            if (m_RoomList == null)
            {
                Debug.LogError("Couldn't find room list compoment under " + this.gameObject.name);
            }
            if (m_RoomPreview == null)
            {
                Debug.LogError("Couldn't find room preview compoment under " + this.gameObject.name);
            }
            if (m_NoRoomAvailablePopupWindow == null)
            {
                Debug.LogError("Couldn't find PopupWindow UI compoment under " + this.gameObject.name);
            }
#endif
            SetLanguage(GameLanguageManager.CurrentLanguage);
        }
예제 #2
0
        /// <summary>
        /// Receive boradcast message form the network manager when the room list updated.
        /// </summary>
        private void UpdateRoomListAndPerview()
        {
            // No need to update the room list when it is not displaying or not connected to the server.
            if (!IsDisplaying || !NetworkManager.IsConnectedToServer)
            {
                return;
            }

            if (!m_RoomList || !m_RoomPreview || !m_NoRoomAvailablePopupWindow)
            {
                m_RoomList    = GetComponentInChildren <RoomList>();
                m_RoomPreview = GetComponentInChildren <RoomPreview>();
                m_NoRoomAvailablePopupWindow = GetComponentInChildren <PupupWindowUI>();
            }

            // Get the room info form the server,
            // and populate the room detail element in the room browser's room list.
            m_RoomList.UpdateList();

            // If room count at previous update is ZERO but now there has new room.
            if (m_LastUpdateRoomCount == 0 && HasAvailableRoom)
            {
                // Show room preview.
                m_RoomPreview.ShowRoomPreview(true);
            }
            // If room count at previous update is non-zero but now there has no room available.
            else if (m_LastUpdateRoomCount > 0 && !HasAvailableRoom)
            {
                // Hide the room preview.
                m_RoomPreview.ShowRoomPreview(false);
            }

            // If we have available room at this moment...
            if (HasAvailableRoom)
            {
                m_NoRoomAvailablePopupWindow.PullBack();

                // First check if the room still exist after the update.
                if (string.IsNullOrEmpty(m_RoomPreview.SelectedRoomName) || !CheckSelectedRoomStillExist())
                {
                    // Manually set the first room element in the list as the default option.
                    m_RoomList.GetRoomDetails(0).OnClickRoomListElementButton();
                }
            }
            else
            {
                m_NoRoomAvailablePopupWindow.Popup();
            }

            // Keep track the room count.
            m_LastUpdateRoomCount = PhotonNetwork.GetRoomList().Length;
        }
예제 #3
0
        public override void PageDisplayContorl(LobbyManager.LobbyPageCategory type)
        {
            base.PageDisplayContorl(type);

            if (GetPage() == type)
            {
                if (!m_RoomList || !m_RoomPreview)
                {
                    m_RoomList    = GetComponentInChildren <RoomList>();
                    m_RoomPreview = GetComponentInChildren <RoomPreview>();
                }

                // Update the room list when display this page
                UpdateRoomListAndPerview();
            }
        }