| using System; |
| using System; |
| using System.Collections.Generic; |
| using System.Collections.Generic; |
| using TMPro; |
| using TMPro; |
| using UnityEngine; |
| using UnityEngine; |
| |
| |
| public class Tutorial : MonoBehaviour |
| public class Tutorial : MonoBehaviour |
| { |
| { |
| public static Tutorial instance |
| public static Tutorial instance |
| { |
| { |
| get |
| get |
| { |
| { |
| return Tutorial.m_instance; |
| return Tutorial.m_instance; |
| } |
| } |
| } |
| } |
| |
| |
| private void Awake() |
| private void Awake() |
| { |
| { |
| Tutorial.m_instance = this; |
| Tutorial.m_instance = this; |
| this.m_windowRoot.gameObject.SetActive(false); |
| this.m_windowRoot.gameObject.SetActive(false); |
| } |
| } |
| |
| |
| private void Update() |
| private void Update() |
| { |
| { |
| . | if (ZoneSystem.instance && Player.m_localPlayer && DateTime.Now > this.m_lastGlobalKeyCheck + TimeSpan.FromSeconds((double)this.m_GlobalKeyCheckRateSec)) |
| double timeSeconds = ZNet.instance.GetTimeSeconds(); |
| |
| if (ZoneSystem.instance && Player.m_localPlayer && timeSeconds > this.m_lastGlobalKeyCheck + (double)this.m_GlobalKeyCheckRateSec) |
| { |
| { |
| . | this.m_lastGlobalKeyCheck = DateTime.Now; |
| this.m_lastGlobalKeyCheck = timeSeconds; |
| foreach (Tutorial.TutorialText tutorialText in this.m_texts) |
| foreach (Tutorial.TutorialText tutorialText in this.m_texts) |
| { |
| { |
| if (!string.IsNullOrEmpty(tutorialText.m_globalKeyTrigger) && ZoneSystem.instance.GetGlobalKey(tutorialText.m_globalKeyTrigger)) |
| if (!string.IsNullOrEmpty(tutorialText.m_globalKeyTrigger) && ZoneSystem.instance.GetGlobalKey(tutorialText.m_globalKeyTrigger)) |
| { |
| { |
| Player.m_localPlayer.ShowTutorial(tutorialText.m_globalKeyTrigger, false); |
| Player.m_localPlayer.ShowTutorial(tutorialText.m_globalKeyTrigger, false); |
| } |
| } |
| if (!string.IsNullOrEmpty(tutorialText.m_tutorialTrigger) && Player.m_localPlayer.HaveSeenTutorial(tutorialText.m_tutorialTrigger)) |
| if (!string.IsNullOrEmpty(tutorialText.m_tutorialTrigger) && Player.m_localPlayer.HaveSeenTutorial(tutorialText.m_tutorialTrigger)) |
| { |
| { |
| Player.m_localPlayer.ShowTutorial(tutorialText.m_name, false); |
| Player.m_localPlayer.ShowTutorial(tutorialText.m_name, false); |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| |
| public void ShowText(string name, bool force) |
| public void ShowText(string name, bool force) |
| { |
| { |
| Tutorial.TutorialText tutorialText = this.m_texts.Find((Tutorial.TutorialText x) => x.m_name == name); |
| Tutorial.TutorialText tutorialText = this.m_texts.Find((Tutorial.TutorialText x) => x.m_name == name); |
| if (tutorialText != null) |
| if (tutorialText != null) |
| { |
| { |
| this.SpawnRaven(tutorialText.m_name, tutorialText.m_topic, tutorialText.m_text, tutorialText.m_label, tutorialText.m_isMunin); |
| this.SpawnRaven(tutorialText.m_name, tutorialText.m_topic, tutorialText.m_text, tutorialText.m_label, tutorialText.m_isMunin); |
| return; |
| return; |
| } |
| } |
| Debug.Log("Missing tutorial text for: " + name); |
| Debug.Log("Missing tutorial text for: " + name); |
| } |
| } |
| |
| |
| private void SpawnRaven(string key, string topic, string text, string label, bool munin) |
| private void SpawnRaven(string key, string topic, string text, string label, bool munin) |
| { |
| { |
| if (!Raven.IsInstantiated()) |
| if (!Raven.IsInstantiated()) |
| { |
| { |
| UnityEngine.Object.Instantiate<GameObject>(this.m_ravenPrefab, new Vector3(0f, 0f, 0f), Quaternion.identity); |
| UnityEngine.Object.Instantiate<GameObject>(this.m_ravenPrefab, new Vector3(0f, 0f, 0f), Quaternion.identity); |
| } |
| } |
| Raven.AddTempText(key, topic, text, label, munin); |
| Raven.AddTempText(key, topic, text, label, munin); |
| } |
| } |
| |
| |
| public List<Tutorial.TutorialText> m_texts = new List<Tutorial.TutorialText>(); |
| public List<Tutorial.TutorialText> m_texts = new List<Tutorial.TutorialText>(); |
| |
| |
| public int m_GlobalKeyCheckRateSec = 10; |
| public int m_GlobalKeyCheckRateSec = 10; |
| |
| |
| public RectTransform m_windowRoot; |
| public RectTransform m_windowRoot; |
| |
| |
| public TMP_Text m_topic; |
| public TMP_Text m_topic; |
| |
| |
| public TMP_Text m_text; |
| public TMP_Text m_text; |
| |
| |
| public GameObject m_ravenPrefab; |
| public GameObject m_ravenPrefab; |
| |
| |
| private static Tutorial m_instance; |
| private static Tutorial m_instance; |
| |
| |
| private Queue<string> m_tutQueue = new Queue<string>(); |
| private Queue<string> m_tutQueue = new Queue<string>(); |
| |
| |
| . | private DateTime m_lastGlobalKeyCheck; |
| private double m_lastGlobalKeyCheck; |
| |
| |
| [Serializable] |
| [Serializable] |
| public class TutorialText |
| public class TutorialText |
| { |
| { |
| public string m_name; |
| public string m_name; |
| |
| |
| [global::Tooltip("If this global key is set, this tutorial will be shown (is saved in knowntutorials as this global key name as well)")] |
| [global::Tooltip("If this global key is set, this tutorial will be shown (is saved in knowntutorials as this global key name as well)")] |
| public string m_globalKeyTrigger; |
| public string m_globalKeyTrigger; |
| |
| |
| [global::Tooltip("If the specified tutorial has been seen, will trigger this tutorial. (You could chain multiple birds like this, or use together with a location discoverLabel when the exact location cant be set, like for the hildir tower)")] |
| [global::Tooltip("If the specified tutorial has been seen, will trigger this tutorial. (You could chain multiple birds like this, or use together with a location discoverLabel when the exact location cant be set, like for the hildir tower)")] |
| public string m_tutorialTrigger; |
| public string m_tutorialTrigger; |
| |
| |
| public string m_topic = ""; |
| public string m_topic = ""; |
| |
| |
| public string m_label = ""; |
| public string m_label = ""; |
| |
| |
| public bool m_isMunin; |
| public bool m_isMunin; |
| |
| |
| [TextArea] |
| [TextArea] |
| public string m_text = ""; |
| public string m_text = ""; |
| } |
| } |
| } |
| } |
| |
| |