/// <summary> /// Filter the navigation from a scene to the next based on the first contact requirements /// </summary> public AppScene FilterNavigation(AppScene fromScene, AppScene toScene, out bool keepPrevAsBackable) { keepPrevAsBackable = false; if (IsSequenceFinished()) { return(toScene); } if (toScene == AppScene.PlayerCreation || toScene == AppScene.ReservedArea) { return(toScene); // These scenes cannot be skipped } // Check whether this transition is completing a phase TransitionCompletePhaseOn(FirstContactPhase.Intro, fromScene == AppScene.Intro); TransitionCompletePhaseOn(FirstContactPhase.AnturaSpace_Exit, fromScene == AppScene.AnturaSpace); TransitionCompletePhaseOn(FirstContactPhase.Map_PlayFirstSession, fromScene == AppScene.PlaySessionResult); TransitionCompletePhaseOn(FirstContactPhase.Map_GoToAnturaSpace, fromScene == AppScene.Map && toScene == AppScene.AnturaSpace); TransitionCompletePhaseOn(FirstContactPhase.Map_GoToBook, fromScene == AppScene.Map && toScene == AppScene.Book); TransitionCompletePhaseOn(FirstContactPhase.Map_GoToMinigames, fromScene == AppScene.Map && toScene == AppScene.Book); TransitionCompletePhaseOn(FirstContactPhase.Map_GoToProfile, fromScene == AppScene.Map && toScene == AppScene.Book); // Check whether this transition needs to be filtered (i.e. it must go to a specific scene) FilterTransitionOn(FirstContactPhase.Reward_FirstBig, fromScene == AppScene.Intro, ref toScene, AppScene.Rewards); FilterTransitionOn(FirstContactPhase.AnturaSpace_TouchAntura, fromScene == AppScene.Rewards, ref toScene, AppScene.AnturaSpace); FilterTransitionOn(FirstContactPhase.AnturaSpace_Shop, fromScene == AppScene.PlaySessionResult, ref toScene, AppScene.AnturaSpace); // Force the game to re-start from the scene of the current tutorial phase if needed // @note: we always filter if we are coming from home, to handle the fact that the player can shut down the game during a tutorial foreach (FirstContactPhase phase in state.EnumeratePhases()) { FilterTransitionOn(phase, fromScene == AppScene.Home, ref toScene, GetSceneForTutorialOfPhase(phase)); } return(toScene); }
public void PlaySceneIntroduction(AppScene scene) { switch (scene) { default: break; } }
public LogInfoData(int appSession, InfoEvent _event, AppScene _scene, string additionalData) { AppSession = appSession; Event = _event; Scene = _scene; AdditionalData = additionalData; Timestamp = GenericHelper.GetTimestampForNow(); }
// TODO refactor: scene names should match AppScene so that this can be removed public static string GetSceneName(AppScene scene, MiniGameData minigameData = null) { switch (scene) { case AppScene.Bootstrap: return("app_Bootstrap"); case AppScene.Home: return("app_Home"); case AppScene.AnturaSpace: return("app_AnturaSpace"); case AppScene.Book: return("app_Book"); case AppScene.Map: return("app_Map"); case AppScene.Mood: return("app_Mood"); case AppScene.GameSelector: return("app_GamesSelector"); case AppScene.Intro: return("app_Intro"); case AppScene.MiniGame: return(minigameData.Scene); case AppScene.PlayerCreation: return("app_PlayerCreation"); case AppScene.PlaySessionResult: return("app_PlaySessionResult"); case AppScene.Rewards: return("app_Rewards"); case AppScene.ReservedArea: return("app_ReservedArea"); case AppScene.Ending: return("app_Ending"); case AppScene.DailyReward: return("app_DailyReward"); case AppScene.Kiosk: return("app_Kiosk"); default: return(""); } }
private void FilterTransitionOn(FirstContactPhase phase, bool condition, ref AppScene toScene, AppScene newScene) { if (newScene == AppScene.NONE) { return; } if (IsPhaseUnlockedAndNotCompleted(phase) && condition) { toScene = newScene; } }
/// <summary> /// Internal GoTo to handle custom transitions. /// </summary> private void CustomGoTo(AppScene targetScene, bool debugMode = false) { if (debugMode || HasCustomTransitionTo(targetScene)) { Debug.LogFormat(" ---- NAV MANAGER ({0}) scene {1} to {2} ---- ", "CustomGoTo", NavData.CurrentScene, targetScene); GoToScene(targetScene, debugMode: debugMode); } else { throw new Exception("Cannot go to " + targetScene + " from " + NavData.CurrentScene); } }
public List <FirstContactPhase> GetPhasesForScene(AppScene scene) { List <FirstContactPhase> correctPhases = new List <FirstContactPhase>(); foreach (FirstContactPhase phase in state.EnumeratePhases()) { if (GetSceneForTutorialOfPhase(phase) == scene) { correctPhases.Add(phase); } } return(correctPhases); }
private void UpdatePrevSceneStack(AppScene newScene) { // The stack is updated only for some transitions if (backableTransitions.Contains(new KeyValuePair <AppScene, AppScene>(NavData.CurrentScene, newScene))) { if (NavData.PrevSceneStack.Count == 0 || NavData.PrevSceneStack.Peek() != NavData.CurrentScene) { if (ApplicationConfig.I.DebugLogEnabled) { Debug.Log("Added BACKABLE transition " + NavData.CurrentScene + " to " + newScene); } NavData.PrevSceneStack.Push(NavData.CurrentScene); } } }
private void LoadScene(AppScene appScene, System.Action <bool /* success */> callback = null) { LoadSceneMode loadSceneMode = LoadSceneMode.Single; string sceneName = null; switch (appScene) { case AppScene.LOBBY_SCENE: sceneName = kLobbySceneName; loadSceneMode = LoadSceneMode.Single; break; case AppScene.GAME_SCENE: sceneName = kGameSceneName; loadSceneMode = LoadSceneMode.Single; break; default: DebugLog.LogErrorColor("Invalid scene: " + appScene, LogColor.red); return; } SceneLoader.Instance.LoadSceneAsync(sceneName, loadSceneMode, (loadedSceneName, success) => { if (!success) { DebugLog.LogErrorColor("Failed to load scene: " + appScene, LogColor.red); if (callback != null) { callback.Invoke(false); } } else { if (callback != null) { callback.Invoke(true); } } }); }
public string GetSceneName(AppScene scene, Db.MiniGameData minigameData = null) { switch (scene) { case AppScene.Home: return("_Start"); case AppScene.Mood: return("app_Mood"); case AppScene.Map: return("app_Map"); case AppScene.Book: return("app_PlayerBook"); case AppScene.Intro: return("app_Intro"); case AppScene.GameSelector: return("app_GamesSelector"); case AppScene.MiniGame: return(minigameData.Scene); case AppScene.Assessment: return("app_Assessment"); case AppScene.AnturaSpace: return("app_AnturaSpace"); case AppScene.Rewards: return("app_Rewards"); case AppScene.PlaySessionResult: return("app_PlaySessionResult"); default: return(""); } }
private void GoToScene(AppScene wantedNewScene, MiniGameData minigameData = null, bool debugMode = false) { AppScene filteredNewScene = wantedNewScene; if (!debugMode) { bool keepPrevAsBackable = false; filteredNewScene = FirstContactManager.I.FilterNavigation(GetCurrentScene(), wantedNewScene, out keepPrevAsBackable); if (keepPrevAsBackable) { UpdatePrevSceneStack(wantedNewScene); } if (FirstContactManager.I.IsSequenceFinished()) { // Additional general checks when entering specific scenes switch (filteredNewScene) { case AppScene.Map: // When coming back to the map, we need to check whether a new daily reward is needed if (CheckDailySceneTrigger()) { GoToScene(AppScene.Mood); return; } break; } } } // Scene switch UpdatePrevSceneStack(filteredNewScene); NavData.CurrentScene = filteredNewScene; // check to have closed any possible Keeper Dialog KeeperManager.I.ResetKeeper(); GoToSceneByName(SceneHelper.GetSceneName(filteredNewScene, minigameData)); }
public AppScenesControler(IMemoryCache memoryCache) { _cache = memoryCache; bool loadDefaults = true; if (!_cache.TryGetValue("AppScenes", out List <AppScene> cacheEntry)) { string file = Environment.GetEnvironmentVariable("CONFIG_FOLDER") + "/" + Environment.GetEnvironmentVariable("APPSCENE_PATH"); // Key not in cache, so get data. if (!loadDefaults) { cacheEntry = Common.LoadFromXML <List <AppScene> >(file); cacheEntry.ForEach(e => e.initComputed()); } else { cacheEntry = AppScene.buildDefaultList(); Common.SaveToXML(cacheEntry, file); } var cacheEntryOptions = new MemoryCacheEntryOptions() // Set cache entry size by extension method. .SetSize(1) // Keep in cache for this time, reset time if accessed. .SetSlidingExpiration(TimeSpan.FromHours(24)); // Set cache entry size via property. // cacheEntryOptions.Size = 1; // Save data in cache. _cache.Set("AppScenes", cacheEntry, cacheEntryOptions); } this.appScenes = cacheEntry; }
public bool IsTutorialToBePlayed(AppScene scene) { return(GetPhasesForScene(scene).Any(phase => IsPhaseUnlockedAndNotCompleted(phase))); //return GetSceneForTutorialOfPhase(CurrentPhaseInSequence) == scene; }
private bool HasCustomTransitionTo(AppScene targetScene) { return(customTransitions.Contains(new KeyValuePair <AppScene, AppScene>(NavData.CurrentScene, targetScene))); }
public void GoToScene(AppScene newScene) { var nextSceneName = GetSceneName(newScene); GoToScene(nextSceneName); }
public void Setup() { CurrentScene = SceneHelper.GetCurrentAppScene(); PrevSceneStack = new Stack <AppScene>(); }