void Start() { forest = new DialogueForest(); forest.ParseFromFile(fileName); ResetRoot(); }
public override void Awake() { base.Awake(); this.PlayerEnteredRange.Action = delegate() { Phone phone = PlayerDataFactory.Instance.Get <Phone>(); if (!string.IsNullOrEmpty(this.Initial)) { DialogueForest forest = WorldFactory.Instance.Get <World>().DialogueForest; DialogueForest.Node n = forest.GetByName(this.Initial); if (n == null) { Log.d(string.Format("Could not find dialogue node {0}", this.Initial)); } else { if (n.type == DialogueForest.Node.Type.Choice) { throw new Exception("Cannot start dialogue tree with a choice"); } phone.Execute(n); } if (phone.Schedules.Length > 0) // We sent a message. That means this signal tower cannot execute again. { this.Initial.Value = null; } AkSoundEngine.PostEvent(AK.EVENTS.PLAY_SIGNAL_TOWER_ACTIVATE, this.Entity); } PlayerFactory.Instance.Get <Player>().SignalTower.Value = this.Entity; }; this.PlayerExitedRange.Action = delegate() { Phone phone = PlayerDataFactory.Instance.Get <Phone>(); if (!string.IsNullOrEmpty(this.Initial)) // The player did not interact. { phone.ActiveAnswers.Clear(); } if (PlayerFactory.Instance != null) { PlayerFactory.Instance.Get <Player>().SignalTower.Value = null; } }; if (!this.main.EditorEnabled) { AkSoundEngine.PostEvent(AK.EVENTS.PLAY_SIGNAL_TOWER_LOOP, this.Entity); } SignalTower.All.Add(this); }
public static void Run(Entity script) { Property <string> lastNode = property <string>(script, "LastNode"); Property <string> nextNode = property <string>(script, "NextNode"); Phone phone = PlayerDataFactory.Instance.Get <Phone>(); script.Add(new CommandBinding(phone.OnVisit(lastNode), new Command { Action = delegate() { DialogueForest forest = WorldFactory.Instance.Get <World>().DialogueForest; DialogueForest.Node n = forest.GetByName(nextNode); phone.Execute(n); } })); }
// Use this for initialization void Start() { dialogueBox = GameObject.Find("Dialog Box"); if (dialogueBox != null) { dialogueBox.SetActive(false); } DirectoryInfo dilogDirectory = new DirectoryInfo(Application.dataPath + "/StreamingAssets/bin/dialog"); FileInfo[] dilogFiles = dilogDirectory.GetFiles("*.json"); //Getting Text files foreach (FileInfo file in dilogFiles) { string name = System.IO.Path.GetFileNameWithoutExtension(file.Name); DialogueForest df = new DialogueForest(); df.Load(File.ReadAllText(file.FullName)); AllDialogues[name] = df; } }
public override void Start() { if (!this.main.EditorEnabled && !string.IsNullOrEmpty(this.Name)) { Phone phone = PlayerDataFactory.Instance.GetOrCreate <Phone>("Phone"); try { DialogueForest forest = WorldFactory.Instance.Get <World>().DialogueForest; forest.Load(File.ReadAllText(Path.Combine(this.main.Content.RootDirectory, this.Name + ".dlz"))); #if DEBUG forest.Validate(this.main.Strings); #endif phone.Bind(forest); } catch (IOException) { Log.d("Failed to load dialogue file: " + this.Name); } } }
public void Bind(DialogueForest forest) { this.forest = forest; }