예제 #1
0
        public IEnumerator StartGameHandler(RuleSettings selectedRuleset, bool isReplay = false)
        {
            Crashlytics.Log($"Start game handler, {selectedRuleset.PuzzleNameKey}");

            if (selectedRuleset != null)
            {
                if (selectedRuleset.IsFtue)
                {
                    SceneActivationBehaviour <OverlayUISceneActivator> .Instance.ScreenWipeTransition(new List <GameWindow> {
                        GameWindow.CollectionScreen
                    }, new List <GameWindow> {
                        GameWindow.BoardUI
                    });

                    yield return(new WaitForSeconds(0.5f));

                    ShowAndHideScenesForGame();

                    if (player.FtuePassed)
                    {
                        sessionScript.CreateGameAndStart(player, selectedRuleset, isReplay);
                    }
                    else
                    {
                        ftueController.StartFtueGame(player, selectedRuleset);
                    }
                }
                else
                {
                    if (selectedRuleset.IsGold || isReplay)
                    {
                        SceneActivationBehaviour <OverlayUISceneActivator> .Instance.ScreenWipeTransition(new List <GameWindow> {
                            GameWindow.CollectionScreen
                        }, new List <GameWindow> {
                            GameWindow.BoardUI
                        });

                        yield return(new WaitForSeconds(0.5f));

                        ShowAndHideScenesForGame();

                        sessionScript.CreateGameAndStart(player, selectedRuleset, isReplay);
                        StartCoroutine(SceneActivationBehaviour <OverlayUISceneActivator> .Instance.ShowTargetScreen());

                        yield break;
                    }
                    else
                    {
                        if (player.Film > 0)
                        {
                            SceneActivationBehaviour <OverlayUISceneActivator> .Instance.ScreenWipeTransition(new List <GameWindow> {
                                GameWindow.CollectionScreen
                            }, new List <GameWindow> {
                                GameWindow.BoardUI
                            });

                            yield return(new WaitForSeconds(0.5f));

                            ShowAndHideScenesForGame();

                            sessionScript.CreateGameAndStart(player, selectedRuleset, isReplay);
                            StartCoroutine(SceneActivationBehaviour <OverlayUISceneActivator> .Instance.ShowTargetScreen());

                            yield break;
                        }
                        else
                        {
                            SceneActivationBehaviour <OverlayUISceneActivator> .Instance.ToggleBlocker(false);

                            // out of film pop up
                            SceneActivationBehaviour <PopUpFilmActivator> .Instance.ShowOutOfFilmPanel(selectedRuleset, () =>
                            {
                                // coin purchase
                                int playerCoins = Player.Coins - globalSettings.Film.MoreFilmPurchaseCost;
                                SceneActivationBehaviour <UICoinCounterActivator> .Instance.CoinCounterClaim(playerCoins, (globalSettings.Film.MoreFilmPurchaseCost), 0f);
                                CoinsSpentHandler(globalSettings.Film.MoreFilmPurchaseCost, CoinSourceType.FilmPurchase);

                                SceneActivationBehaviour <UIFilmCounterActivator> .Instance.GrantFilm(globalSettings.Film.FilmRewardCount);
                                analyticsController.FilmEarned(globalSettings.Film.FilmRewardCount, FilmSourceType.CoinPurchase);

                                SceneActivationBehaviour <PopUpFilmActivator> .Instance.ShowThankyouPanel(() =>
                                {
                                    StartCoroutine(StartGameHandler(selectedRuleset));
                                    return;
                                });
                            }, () =>
                            {
                                // watch video
                                return;
                            }, () =>
                            {
                                // exit
                                return;
                            });

                            yield break;
                        }
                    }
                }
            }
            else
            {
                InterfaceController.Instance.Show(GameWindow.MainMenu);
                yield break;
            }
        }