Beispiel #1
0
    public void Show(string menuScriptName, bool hidePrev = true)
    {
        MenuBase menu = null;

        for (int i = 0; i < Menus.Length; ++i)
        {
            if (Menus[i].GetType().Name == menuScriptName)
            {
                menu = Menus[i];
                break;
            }
        }

        if (menu != null)
        {
            if (currMenu.Count > 0 && hidePrev)
            {
                currMenu.Pop().Hide(false);
            }

            currMenu.Push(menu);
            menu.Show(false);
        }
        else
        {
            Debug.LogError($"Cant find menu with name {menuScriptName}");
        }
    }
Beispiel #2
0
	public void TransitTo(MenuBase menu, bool hidePrev = true) {
		if (hidePrev && currMenu.Count > 0) {
			currMenu.Pop().Hide();
		}

		currMenu.Push(menu);
		menu.Show();
	}
Beispiel #3
0
    public void Show(MenuBase menu, bool hidePrev = true)
    {
        if (hidePrev && currMenu.Count > 0)
        {
            currMenu.Pop().Hide(false);
        }

        currMenu.Push(menu);
        menu.Show(false);
    }
Beispiel #4
0
    public void Back()
    {
        Hide();

        MenuBase _prevMenu = m_PrevMenu;

        m_PrevMenu = null;

        if (_prevMenu)
        {
            _prevMenu.Show();
        }
    }
Beispiel #5
0
    public void Show(MenuBase menu, bool hidePrev = true)
    {
        if (currMenu.Count > 0)
        {
            if (hidePrev)
            {
                currMenu.Pop().Hide(false);
            }
            else
            {
                currMenu.Peek().SaveLastButton();
                currMenu.Peek().DisableAllSelectable();
            }
        }

        currMenu.Push(menu);
        menu.Show(false);
    }
    void Start()
    {
        currMenu = new Stack <MenuBase>();
        currMenu.Push(Menus[FirstMenuId]);
        MenuBase firstMenu = currMenu.Peek();

        TemplateGameManager.Instance.uiinput.SetSelectedButton(null);

        foreach (var menu in Menus)
        {
            if (menu != firstMenu)
            {
                menu.Hide(true);
            }

            if (menu.rt.anchorMin == Vector2.zero && menu.rt.anchorMax == Vector2.one && menu.rt.pivot.x == 0.5f && menu.rt.pivot.y == 0.5f && !(menu is PopupMenuBase))
            {
                menu.rt.transform.localPosition = Vector2.zero;
            }

            menu.MenuManager = this;
        }

        TemplateGameManager.Instance.inputSystem.cancel.action.performed += OnCancelClick;
        TemplateGameManager.Instance.inputSystem.move.action.performed   += OnMoveClick;

        StartCoroutine(DelayedShow());

        IEnumerator DelayedShow()
        {
            yield return(null);

            yield return(null);

            firstMenu.Show(true);
        }
    }
Beispiel #7
0
    IEnumerator CoSwitchAnimWorker(MenuBase baseMenu)
    {
        IsDuringSwitch = true;

        // override local anim
        if (PreviousMenu && PreviousMenu.IsHideAnim)
        {
            PreviousMenu.OnHide.Play();
            yield return(new WaitForSeconds(PreviousMenu.OnHide.Duration));
        }
        else if (Local.Hide.DoPlay)
        {
            Local.Hide.Play();
            switch (Local.Hide.AlphaMode)
            {
            case AlphaMode.Custom:
                yield return(new WaitForSeconds(Local.Hide.Duration));

                break;

            case AlphaMode.Snap:
            {
                yield return(new WaitForSeconds(Local.Hide.Duration));

                if (PreviousMenu)
                {
                    PreviousMenu.Hide();
                }

                break;
            }

            case AlphaMode.Animate:
            {
                if (CurrentMenu)
                {
                    yield return(StartCoroutine(CoHandleAlphaAnim(1, 0, Local.Hide.Duration, PreviousMenu.Canvas)));

                    PreviousMenu.Hide();
                }
                else
                {
                    yield return(new WaitForSeconds(Local.Hide.Duration));
                }

                break;
            }
            }
        }
        else
        {
            if (PreviousMenu)
            {
                PreviousMenu.Hide();
            }
        }

        if (PreviousMenu)
        {
            PreviousMenu.End();
        }

        CurrentMenu = baseMenu;

        if (CurrentMenu)
        {
            CurrentMenu.gameObject.SetActive(true);
        }

        if (CurrentMenu && CurrentMenu.IsShowAnim)
        {
            CurrentMenu.OnShow.Play();
            yield return(new WaitForSeconds(CurrentMenu.OnShow.Duration));
        }
        else if (Local.Show.DoPlay)
        {
            Local.Show.Play();
            switch (Local.Show.AlphaMode)
            {
            case AlphaMode.Custom:
                yield return(new WaitForSeconds(Local.Show.Duration));

                break;

            case AlphaMode.Snap:
            {
                yield return(new WaitForSeconds(Local.Show.Duration));

                if (CurrentMenu)
                {
                    CurrentMenu.Show();
                }

                break;
            }

            case AlphaMode.Animate:
            {
                if (CurrentMenu)
                {
                    yield return(StartCoroutine(CoHandleAlphaAnim(1, 0, Local.Show.Duration, CurrentMenu.Canvas)));

                    CurrentMenu.Show();
                }
                else
                {
                    yield return(new WaitForSeconds(Local.Show.Duration));
                }

                break;
            }
            }
        }
        else
        {
            if (CurrentMenu)
            {
                CurrentMenu.Show();
            }
        }

        if (CurrentMenu)
        {
            CurrentMenu.Begin();
        }

        IsDuringSwitch = false;
    }