Exemplo n.º 1
0
    public virtual bool SelectAction(WinTypeAction w)
    {
        if (ActionSelected)
        {
            return(false);
        }

        ActionSelected = true;
        IsAnimating    = true;
        OnActionSelected?.Invoke(w);
        return(true);
    }
Exemplo n.º 2
0
    public void ActionSelected(WinTypeAction w)
    {
        AcceptingInputs = false;

        int currentScene = SceneHelpers.GetCurrentLevelBuildIndex();

        // if we're not going to the next scene, cancel the load of the next scene
        if (w != WinTypeAction.Next)
        {
            cts.Cancel();
        }
        MMVibrationManager.Haptic(HapticTypes.Selection);
        switch (w)
        {
        case WinTypeAction.Menu:
            GameManager.Instance.LoadScene(SceneHelpers.MenuBuildIndex, StartCoroutine(winType.WhenTilesOffScreen()));
            break;

        case WinTypeAction.Reset:
            GameManager.Instance.ShowAd();
            Reset(false);
            break;

        case WinTypeAction.LevelSelect:
            GoToLevelSelect(false);
            break;

        case WinTypeAction.Next:
            // TODO: All this logic can be removed once we've guaranteed that every world has 10 levels
            int current_bi       = SceneHelpers.GetCurrentLevelBuildIndex();
            int current_bi_world = SceneHelpers.GetWorldFromBuildIndex(current_bi);
            int next_bi          = SceneHelpers.GetNextLevelBuildIndex();
            int next_bi_world    = SceneHelpers.GetWorldFromBuildIndex(next_bi);
            if (next_bi < SceneHelpers.SceneCount || (current_bi_world > 0 && current_bi_world < next_bi_world))
            {
                GameManager.Instance.ShowAd();

                // hide objects in the current level so that as the wintype animation is playing, we see the next level
                HideLevel();

                // once the tiles are offscreen, we can finally unload the level
                StartCoroutine(winType.WhenTilesOffScreen(() => {
                    GameManager.Instance.UnloadScene(currentScene, null);
                }));
            }
            else
            {
                GoToLevelSelect(false);
            }
            break;
        }
    }