protected override void Start() { base.Start(); textField = GetComponentInChildren <Text>(); exampleUI = FindObjectOfType <Yarn.Unity.Example.ExampleDialogueUI>(); dialogueRunner = FindObjectOfType <DialogueRunner>(); playerInteractionalController = FindObjectOfType <InteractionControllerBehaviour>(); }
public static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (scene.buildIndex == 1) { GameObject.Find("NewGameButton").GetComponent <Button>().onClick.AddListener(NewGame); savedGamesMenu = GameObject.Find("SavedGamesMenu"); for (int i = 0; i < 6; i++) { GameObject saveButton = GameObject.Find("SavedGameButton" + i.ToString()); if (File.Exists(Application.dataPath + ("/Saved_Game_" + i.ToString() + ".xml"))) { int saveDelegate = i; saveButton.GetComponent <Button>().onClick.AddListener(delegate { LoadGame(saveDelegate); }); XmlDocument tempDoc = new XmlDocument(); tempDoc.Load(Application.dataPath + ("/Saved_Game_" + i.ToString() + ".xml")); XPathNavigator tempNav = tempDoc.CreateNavigator(); XPathNavigator textNode = tempNav.SelectSingleNode("/Game/LoadText"); saveButton.GetComponentInChildren <Text>().text = textNode.GetAttribute("Text", ""); } else { saveButton.SetActive(false); } } savedGamesMenu.SetActive(false); } else if (scene.buildIndex == 2) { if (loadingGame) { //TODO: add more loading functionality? currentGameDoc.Load(Application.dataPath + ("/Saved_Game_" + saveNo.ToString() + ".xml")); loadingGame = false; } else { for (int i = 0; i < 6; i++) { if (!File.Exists(Application.dataPath + "/Saved_Game_" + i.ToString() + ".xml")) { saveNo = i; break; } } currentGameDoc.Load(Application.streamingAssetsPath + "/Save_Template_XML.xml"); } currentGameNav = currentGameDoc.CreateNavigator(); ExampleDialogueUI example = FindObjectOfType <ExampleDialogueUI>(); example.SaveMethod = SaveConversation; example.DialogueRetriever = RetrieveConversation; //example.dialogueStarted.AddListener(SendConversation); } }