Esempio n. 1
0
        /// <inheritdoc />
        public IScreenPanel PushNewPanel(ScreenPanelTypes type)
        {
            if (!mPanelTypeToObjectMap.ContainsKey(type))
            {
                return(null);
            }

            IScreenPanel panel = mPanelTypeToObjectMap[type];
            GameObject   go    = panel.gameObject;

            go.SetActive(true);
            panel.OnEnablePanel();

            if (panel.disablesInput)
            {
                ServiceLocator.Get <IInput>()
                .DisableInputLevel(InputLevel.Gameplay)
                .DisableInputLevel(InputLevel.HideCursor);
            }

            mActivePanels.Push(panel);
            go.transform.SetAsLastSibling();

            return(panel);
        }
Esempio n. 2
0
        /// <inheritdoc />
        public IUIManager UnregisterPanel(IScreenPanel panelObject)
        {
            if (!mPanelObjectToTypeMap.ContainsKey(panelObject))
            {
                return(this);
            }

            ScreenPanelTypes type = mPanelObjectToTypeMap[panelObject];

            mPanelObjectToTypeMap.Remove(panelObject);
            mPanelTypeToObjectMap.Remove(type);

            mActivePanels.Remove(panelObject);

            return(this);
        }
Esempio n. 3
0
        public IScreenPanel TogglePanel(ScreenPanelTypes type)
        {
            if (!mPanelTypeToObjectMap.ContainsKey(type))
            {
                return(null);
            }

            IScreenPanel panel = mPanelTypeToObjectMap[type];

            if (!mActivePanels.Contains(panel))
            {
                return(PushNewPanel(type));
            }

            PopPanel(type);
            return(panel);
        }
Esempio n. 4
0
        /// <inheritdoc />
        public IUIManager RegisterPanel(IScreenPanel panelObject, ScreenPanelTypes type, bool disablePanel = true)
        {
            if (mPanelTypeToObjectMap.ContainsKey(type) || mPanelObjectToTypeMap.ContainsKey(panelObject))
            {
                throw new ArgumentException("Registering a panel for more than one type, or more than one panel for a type!");
            }

            mPanelObjectToTypeMap[panelObject] = type;
            mPanelTypeToObjectMap[type]        = panelObject;

            if (disablePanel)
            {
                panelObject.gameObject.SetActive(false);
            }

            return(this);
        }
Esempio n. 5
0
        /// <inheritdoc />
        public IUIManager PopPanel(ScreenPanelTypes type)
        {
            if (!mPanelTypeToObjectMap.ContainsKey(type))
            {
                return(this);
            }

            IScreenPanel panel = mPanelTypeToObjectMap[type];
            GameObject   go    = panel.gameObject;

            panel.OnDisablePanel();
            go.SetActive(false);
            mActivePanels.Remove(panel);

            if (!mActivePanels.Any(x => x.disablesInput))             // no active panels that disable input
            {
                ServiceLocator.Get <IInput>()
                .EnableInputLevel(InputLevel.Gameplay)
                .EnableInputLevel(InputLevel.HideCursor);
            }

            return(this);
        }