public void PlayerWinAnimation() { if (SelectedTile != null) { Preview.Show(false); SelectedTile.Select(false); SelectedTile = null; } grabPoint = new Vector2(1000, 1000); winType.Run(timeInfo, collectedStars, RespawnManager.Stars.Length, ActionSelected); cts = new CancellationTokenSource(); 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 (current_bi_world > 0 && current_bi_world < next_bi_world) { next_bi = SceneHelpers.WorldCompleteBuildIndex; } // TODO: this if/else can be removed once we've guaranteed that every world has 10 levels // and replaced with just the statement inside the IF if (next_bi < SceneHelpers.SceneCount) { GameManager.Instance.AsyncLoadScene(next_bi, StartCoroutine(WaitActionSelected()), cts, null, false); } else { GameManager.Instance.SaveData.LastPlayedWorld = 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; } }