Example #1
0
    /// <summary>
    /// Show a particular menu screen
    /// </summary>
    /// <param name="screen">The screen to show</param>
    /// <param name="fade">The transition time.</param>
    /// <param name="callback">A Callback function to call once the transition is complete</param>
    public void ShowScreen(MenuScreen screen, float fade = 0.5f, SimpleTween.Callback callback = null)
    {
        if (screen == null)
        {
            Debug.LogWarning("Attempting to show null Menu Screen");
            return;
        }

        MenuScreen currentScreen = CurrentScreen;

        // add the new screen to the history
        screenHistory.Push(screen);

        // hide the current screen before showing the new one
        if (currentScreen != null)
        {
            currentScreen.Hide(fade, MenuScreen.TransitionDirection.Forward, () => {
                screen.Show(fade, MenuScreen.TransitionDirection.Forward, callback);
            });
        }
        else
        {
            screen.Show(fade, MenuScreen.TransitionDirection.Forward, callback);
        }
    }
Example #2
0
    /// <summary>
    /// Exits all of the menus without going back through the history
    /// </summary>
    /// <param name="fade">Transition time</param>
    /// <param name="callback">Callback function to call when the transition is complete</param>
    public void ExitAll(float fade = 0.5f, SimpleTween.Callback callback = null)
    {
        if (screenHistory.Count == 0)
        {
            return;
        }

        // hide the current menu screen
        MenuScreen currentScreen = screenHistory.Pop();

        currentScreen.Hide(fade, MenuScreen.TransitionDirection.Back, callback);

        // clear the history, since we have now completely exited the menus.
        screenHistory.Clear();
    }
Example #3
0
    /// <summary>
    /// Return to the previous menu screen in the history
    /// </summary>
    /// <param name="fade">Transition time</param>
    /// <param name="callback">Callback funtion to call when the transition is complete</param>
    public void GoBack(float fade = 0.5f, SimpleTween.Callback callback = null)
    {
        if (screenHistory.Count == 0)
        {
            return;
        }

        MenuScreen currentScreen = screenHistory.Pop();
        MenuScreen prevScreen    = screenHistory.Count == 0 ? null : screenHistory.Peek();

        // hide the current screen and then show the previous screen (if there is one).
        if (prevScreen != null)
        {
            currentScreen.Hide(fade, MenuScreen.TransitionDirection.Back, () => {
                prevScreen.Show(fade, MenuScreen.TransitionDirection.Back, callback);
            });
        }
        else
        {
            currentScreen.Hide(fade, MenuScreen.TransitionDirection.Back, callback);
        }
    }
Example #4
0
    public override void Show(float fade, TransitionDirection direction, SimpleTween.Callback callback)
    {
        availableFunds.text = GameManager.TotalCredits.ToString();

        base.Show(fade, direction, callback);
    }