public void LoadAll () { if (diagDefs != null) { DialogParser dp = new DialogParser (); dp.Start (diagDefs.text); Debug.Log("Dialog Definitions successfully Loaded"); } else { Debug.LogError("File not reached: Non existent"); } if (speechDefs != null) { SpeechParser sp = new SpeechParser (); sp.Start (speechDefs.text); Debug.Log("Speech Definitions successfully Loaded"); } else { Debug.LogError("File not reached: Non existent"); } if (questDefs != null) { QuestParser qp = new QuestParser (); qp.Start (questDefs.text); Debug.Log("Quest Definitions successfully Loaded"); } else { Debug.LogError("File not reached: Non existent"); } }
void Start() { var a = new FileReader("\\t\\", "t.txt"); Hero[] h = { new Hero("asd", new Appearance(Color.white, Color.white, Color.white), 1f) }; var d = new DialogParser(a, h); a = new FileReader("\\t\\", "c.txt"); StartCoroutine(new DialogViewer().ctor(writers, a, d)); }
private void Start() { triggerHighlight = GetComponent <TriggerHighlight>(); parser = GetComponent <DialogParser>(); voix = GetComponent <AudioSource>(); dialogId = 0; lineId = 0; cursorId = 0; currentDialog = null; textUI = null; endOfLineCursorImg = null; showLineProgressively = false; timeSinceLastChar = 1 / GameController.GetInstance().dialogSpeed; waitingForNextLine = false; endOfLineCursorFlashSpeed = 2; timeSinceLastCursorFlash = 0; goTriggerAutomatically = false; }
public void OnGameEnd(bool isSuccessful) { gameObject.SetActive(true); canBeClick = true; if (isSuccessful) { dialogParser = new DialogParser("Dialog/GameEnd_S"); dialogParser.OnDialogEnd = OnDialogNext; DialogOnclick(); } else { dialogParser = new DialogParser("Dialog/GameEnd_US"); dialogParser.OnDialogEnd = OnDialogEnd; DialogOnclick(); } }
void Start() { enemyMessageControl = GameObject.Find("Enemy").transform.GetComponent <EnemyMessageControl>(); dialogControl = transform.GetComponent <DialogControl>(); uiControl = GameObject.Find("/Canvas").GetComponent <UIControl>(); int SceneIndex = SceneManager.GetActiveScene().buildIndex; if (SceneIndex == 1) { dialogParser = new DialogParser("Dialog/GameStart"); } else if (SceneIndex == 2) { dialogParser = new DialogParser("Dialog/GameStart2"); } dialogParser.OnDialogEnd = OnDialogEnd; OnGameStart(); }
public void FRead(string path) { // #if !UNITY_EDITOR // // if (Application.platform == RuntimePlatform.Android) // { // basePath = Application.persistentDataPath; // basePath = basePath.Substring(0, basePath.LastIndexOf('/') + 1); // } // else if (Application.platform == RuntimePlatform.IPhonePlayer) // { // basePath = Application.dataPath.Substring(0, Application.dataPath.Length - 5); // basePath = basePath.Substring(0, basePath.LastIndexOf('/') + 1); // basePath = Path.Combine(basePath, "Documents/"); // } // #endif var finalPath = basePath + currentLanguage.ToString() + "/" + path; var json = Resources.Load <TextAsset>(finalPath); currentDialog = DialogParser.Parse(json.text); }
public void DialgParserTestXMLSimple() { DialogParser dialogParser = new DialogParser(); Option optChosen = null; List <NPC> npcs = midgardNPCSorig.npcListe; Mission mission = npcs [0].missionen [0]; //Initialize dialogParser.StartNode = new DialogNode <object> (); dialogParser.StartNode.nodeElement = mission; dialogParser.StartNode.typeNodeElement = typeof(Mission); dialogParser.StartNode.typeParentNodeElement = null; dialogParser.StartNode.parentNode = null; //Erster Charakter ist Osrick //Paket 1 List <Info> infos = dialogParser.GetInfos(); Assert.AreEqual(3, infos.Count); //Paket 2 infos = dialogParser.GetInfos(); Assert.AreEqual(3, infos.Count); //Paket 3 infos = dialogParser.GetInfos(); Assert.AreEqual(2, infos.Count); //Paket 4 infos = dialogParser.GetInfos(); Assert.AreEqual(4, infos.Count); //Paket 5 infos = dialogParser.GetInfos(); Assert.AreEqual(1, infos.Count); //Kein Paket mehr ->sense infos = dialogParser.GetInfos(); Assert.IsNull(dialogParser.StartNode); }
void SyncData() { SaveTmpXMLFile(); dialogues = DialogParser.parse(tempXmlFile.text); }
// Use this for initialization void Start() { dialogues = DialogParser.parse(xmlFile.text); }
public Queue <DialogData> GetParsingDialogQueue(string path) { var json = Resources.Load <TextAsset>(basePath + currentLanguage.ToString() + "/" + path); return(DialogParser.Parse(json.text)); }
private void FindPidsInDialog(BackgroundWorker worker, string filename, List <Tuple <int, int> > pids) { if (!filename.HaveExtension("fodlg")) { return; } DialogParser fodlg = new DialogParser(filename); if (fodlg == null) { return; } if (fodlg.Parse()) { bool header = false; string headerText = "? (" + Path.GetFileName(filename) + ")\r\n\r\n"; Dialog dialog = fodlg.GetDialog(); if (dialog == null) { return; } string lNode = "" + dialog.Nodes.Count.ToString().Length; foreach (Node node in dialog.Nodes) { int answerId = 0; string lAnswer = "" + node.Answers.Count.ToString().Length; foreach (Answer answer in node.Answers) { answerId++; int demandId = 0; int resultId = 0; string lDemand = "" + answer.Demands.Count.ToString().Length; string lResult = "" + answer.Results.Count.ToString().Length; foreach (Demand demand in answer.Demands) { demandId++; if (demand.Item != null) { int pid = -1; if (itemPids.Defines.TryGetValue(demand.Item.PidDefine, out pid) && pids.IsWantedObject(objectItem, pid)) { if (!header) { if (resultsLog.Text.Length > 0) { worker.SendResult("\r\n"); } worker.SendResult(headerText); header = true; } worker.SendResult(string.Format("\t[Node {0," + lNode + "} Answer {1," + lAnswer + "} Demand {2," + lDemand + "}] {3} {4} {5}\r\n", node.Id, answerId, demandId, demand.Item.PidDefine, demand.Operator == "=" ? "==" : demand.Operator, demand.Value)); worker.SendResult("Dialogs" + "|" + Path.GetFileName(filename) + "|Node " + node.Id + "^" + node.Text["engl"] + "|Answer " + answerId + "^" + answer.Text["engl"] + "|Demand " + demandId + ": " + demand.Item.PidDefine + " " + (demand.Operator == "=" ? "==" : demand.Operator) + " " + demand.Value); } } } foreach (Result result in answer.Results) { resultId++; if (result.Item != null) { int pid = -1; if (itemPids.Defines.TryGetValue(result.Item.PidDefine, out pid) && pids.IsWantedObject(objectItem, pid)) { if (!header) { if (resultsLog.Text.Length > 0) { worker.SendResult("\r\n"); } worker.SendResult(headerText); header = true; } worker.SendResult(string.Format("\t[Node {0," + lNode + "} Answer {1," + lAnswer + "} Result {2," + lResult + "}] {3} {4} {5}\r\n", node.Id, answerId, resultId, result.Item.PidDefine, result.Operator, result.Value)); worker.SendResult("Dialogs" + "|" + Path.GetFileName(filename) + "|Node " + node.Id + "^" + node.Text["engl"] + "|Answer " + answerId + "^" + answer.Text["engl"] + "|Result " + resultId + ": " + result.Item.PidDefine + " " + result.Operator + " " + result.Value); } } } } } } }
public void DialgParserTestXML2() { DialogParser dialogParser = new DialogParser(); Option optChosen = null; List <NPC> npcs = midgardNPCS2.npcListe; Mission mission = npcs[0].missionen[0]; dialogParser.StartNode = new DialogNode <object> (); dialogParser.StartNode.nodeElement = mission; dialogParser.StartNode.typeNodeElement = typeof(Mission); dialogParser.StartNode.typeParentNodeElement = null; dialogParser.StartNode.parentNode = null; //Hier sind im Paket zwei Infos und ein Optionspaket List <Info> infos = dialogParser.GetInfos(); Assert.AreEqual(3, infos.Count); Assert.AreEqual("Mission 1: Du sollst den geflohenen Esel fangen.", infos [0].content); infos = dialogParser.GetInfos(); if (infos == null) { if (dialogParser.IsOption) { dialogParser.StartNode = dialogParser.optionalStartNodes[0]; optChosen = dialogParser.StartNode.nodeElement as Option; infos = dialogParser.GetInfos(); Assert.AreEqual(2, infos.Count); } } infos = dialogParser.GetInfos(); if (dialogParser.IsOption) { dialogParser.StartNode = dialogParser.optionalStartNodes[0]; optChosen = dialogParser.StartNode.nodeElement as Option; infos = dialogParser.GetInfos(); Assert.AreEqual(1, infos.Count); } infos = dialogParser.GetInfos(); if (dialogParser.IsOption) { dialogParser.StartNode = dialogParser.optionalStartNodes[1]; optChosen = dialogParser.StartNode.nodeElement as Option; Assert.AreEqual("Ich lasse den Eimer stehen.", optChosen.Beschreibung); infos = dialogParser.GetInfos(); Assert.AreEqual(1, infos.Count); } infos = dialogParser.GetInfos(); if (dialogParser.IsOption) { dialogParser.StartNode = dialogParser.optionalStartNodes[0]; optChosen = dialogParser.StartNode.nodeElement as Option; Assert.AreEqual("Es nervt mich furchtbar... Ich pfeffere das Ding in den Brunnen.", optChosen.Beschreibung); infos = dialogParser.GetInfos(); Assert.AreEqual(1, infos.Count); Assert.AreEqual("Der Eimer verschwindet mit einem hohlen Gebrüll im Brunnen.", infos [0].content); } infos = dialogParser.GetInfos(); Assert.AreEqual("Grausig. Vielleicht sollte ich den Eimer doch an mich nehmen?", infos [0].content); infos = dialogParser.GetInfos(); Assert.AreEqual("Du bist jetzt recht außer Atem nach dem Szenario mit dem Eimer", infos [0].content); infos = dialogParser.GetInfos(); Assert.AreEqual("Da an der Ecke steht endlich der Esel!", infos [0].content); }
public IEnumerator ctor(Writer[] texts, FileReader code, DialogParser source) { Queue <Writer> deactivationQueue; int lengthQueue = int.MaxValue; var Lines = new List <string[]>(); foreach (var line in code.Lines) { Lines.Add(line.Split(' ')); } for (int i = 0; i < Lines.Count;) { if (Lines[i].Length == 0 || Lines[i][0] == "") { Lines.RemoveAt(i); } else { i++; } } yield return(new WaitForEndOfFrame()); { if (Lines[0][0].ToLower() != "mode") { Debug.LogError("first line must contain mode instruction"); } if (Lines[0][1].ToLower() == "u") { deactivationQueue = new Queue <Writer>(texts.Length); } else { lengthQueue = int.Parse(Lines[0][2].ToLower()); deactivationQueue = new Queue <Writer>(lengthQueue); } if (Lines[1][0].ToLower() != "length") { Debug.LogError("second line must contain length instruction"); } Debug.Log(texts.Length); if (int.Parse(Lines[1][1].ToLower()) > texts.Length) { Debug.LogError("Length error"); } } Writer currentText = null; for (int i = 2; i < Lines.Count; i++) { switch (Lines[i][0].ToLower()) { case "phrase": if ((currentText) == null) { Debug.LogError("Phrase error"); } while (currentText.isWriting != 0) { yield return(new WaitForSeconds(0.01f)); } yield return(currentText.WriteText(source.Phrases[0], Lines[i].Length == 1)); source.Phrases.RemoveAt(0); break; case "set": currentText = texts[int.Parse(Lines[i][1])]; currentText.TurnOn(); deactivationQueue.Enqueue(currentText); if (deactivationQueue.Count > lengthQueue && !deactivationQueue.Peek().CurrentGameObject.Equals(currentText.CurrentGameObject)) { while (deactivationQueue.Peek().isWriting != 0) { yield return(new WaitForSeconds(0.01f)); } deactivationQueue.Dequeue().TurnOff(); } break; } } }