public static void Set(UIState.State state, bool showed) { var key = GetKey(state); PlayerPrefs.SetInt(key, showed ? 1 : 0); PlayerPrefs.Save(); }
IEnumerator ShowLines(UIState.State state, List <string> lines) { dialogParent.SetActive(true); foreach (var l in lines) { if (CancelDialogDown) { break; } var line = l; dialogText.text = line; yield return(StartCoroutine(RevealCharacters(dialogText))); var t = Time.time; while (!SkipTextDown && !CancelDialogDown && Time.time - t < 6) { yield return(null); } if (CancelDialogDown) { break; } yield return(null); } OnTutorialEnd(); }
public void Show(UIState.State state, string[] lines) { if (lines != null && lines.Length > 0) { Show(state, lines.ToList()); } }
public void Show(UIState.State state, List <string> lines) { if (lines == null || lines.Count == 0) { return; } StartCoroutine(ShowLines(state, lines)); }
public string[] GetTutorialForState(UIState.State state) { switch (state) { case UIState.State.Title: return(Title); case UIState.State.Game: return(Game); case UIState.State.Tutorial: return(Tutorial); } return(null); }
public static bool ShowTutorialIfNeeded(UIState.State state, System.Action action) { // show once, depending on the State if (!Get(state) || // Always show the tutorial one tho state == UIState.State.Tutorial) { Set(state, true); action?.Invoke(); return(true); } return(false); }
public static bool Get(UIState.State state) { var key = GetKey(state); return(PlayerPrefs.HasKey(key) && PlayerPrefs.GetInt(key, 0) == 1); }
static string GetKey(UIState.State state) { var id = GetId(state); return($"{prefsPrefix}.{id}"); }
static int GetId(UIState.State state) { return((int)state); }
public static void ClearPrefForState(UIState.State state) => PlayerPrefs.DeleteKey(GetKey(state));
void OnStateChanged(UIState.State state) { // check if we should start a dialog TutorialShowedStatus.ShowTutorialIfNeeded(state, () => Show(state, dialog.tutorials.GetTutorialForState(state))); }