示例#1
0
    public void Show(bool hasPlayerWon, ConfirmationContext context)
    {
        _context = context;
        var congratulations = hasPlayerWon ? "Yay, you've won!, so great!" :
                              "Yay, you've ALMOST won! Neat!";

        label.text = congratulations;
        gameObject.SetActive(true);
    }
示例#2
0
    private IEnumerator QuitConfirmRoutine()
    {
        var context = new ConfirmationContext();

        confirmPopup.Setup("Are you sure you want to quit?", context);

        while (!context.IsFinished)
        {
            yield return(null);
        }

        if (context.IsConfirmed)
        {
            DoQuit();
        }
    }
示例#3
0
    public void ShowInGame(ConfirmationContext doesUserWantToQuit)
    {
        _onLeftButtonClick = () =>
        {
            gameObject.SetActive(false);
            doesUserWantToQuit.Cancel();
        };

        leftButtonLabel.text = "OK";
        leftButton.gameObject.SetActive(true);

        _onRightButtonClick   = () => StartQuitConfirmFlow(doesUserWantToQuit);
        rightButtonLabel.text = "Quit";
        rightButton.gameObject.SetActive(true);

        gameObject.SetActive(true);
    }
示例#4
0
    private IEnumerator QuitConfirmationFlowRoutine(ConfirmationContext doesUserWantToQuit)
    {
        var menuManager = ManagerLocator.TryGet <MenuUIManager>();
        var quitConfirm = new ConfirmationContext();

        menuManager.ShowConfirmPopup("Back to main menu?", quitConfirm);

        while (!quitConfirm.IsFinished)
        {
            yield return(null);
        }

        if (quitConfirm.IsConfirmed)
        {
            gameObject.SetActive(false);
            doesUserWantToQuit.Confirm();
        }
    }
示例#5
0
    private IEnumerator GameOverRoutine(GameController.GameResult playerHasWon)
    {
        var gc = ManagerLocator.TryGet <GameController>();

        gc.PauseGame(true);

        if (playerHasWon != GameController.GameResult.PlayerQuit)
        {
            var playerWon = playerHasWon == GameController.GameResult.PlayerWon;
            var context   = new ConfirmationContext();
            gameOverPopup.Show(playerWon, context);

            while (!context.IsFinished)
            {
                yield return(null);
            }
        }

        gc.AbortGameServices();

        ShowMainMenu();
    }
示例#6
0
    private IEnumerator PauseGameRoutine(GameController gc)
    {
        gc.PauseGame(true);

        var doesUserWantToQuit = new ConfirmationContext();

        settingsPopup.ShowInGame(doesUserWantToQuit);

        while (!doesUserWantToQuit.IsFinished)
        {
            yield return(null);
        }

        if (doesUserWantToQuit.IsConfirmed)
        {
            gc.HandlePlayerQuit();
        }
        else
        {
            gc.PauseGame(false);
        }
    }
示例#7
0
 public void Setup(string thingToConfirm, ConfirmationContext context)
 {
     label.text = thingToConfirm;
     _context   = context;
     gameObject.SetActive(true);
 }
示例#8
0
 private void Teardown()
 {
     _context = null;
     gameObject.SetActive(false);
 }
示例#9
0
 public void ShowConfirmPopup(string text, ConfirmationContext confirmContext)
 {
     confirmPopup.Setup(text, confirmContext);
 }
示例#10
0
 private void StartQuitConfirmFlow(ConfirmationContext doesUserWantToQuit)
 {
     StartCoroutine(QuitConfirmationFlowRoutine(doesUserWantToQuit));
 }