private void RegisterCommands() { // leftCharacter <character> --> runner.AddCommandHandler("leftCharacter", delegate(string[] p) { leftCharacter.DataName = p[0]; }); // rightCharacter <character> --> runner.AddCommandHandler("rightCharacter", delegate(string[] p) { rightCharacter.DataName = p[0]; }); // expression <character> [expression] --> runner.AddCommandHandler("expression", delegate(string[] p) { if (p.Length > 0) { SpeechCharacter sc = GetCharacter(p[0]); if (sc != null) { if (p.Length > 1) { sc.Expression = p[1]; } else { sc.Expression = ""; } } } }); // speaker [character] --> runner.AddCommandHandler("speaker", delegate(string[] p) { SpeechCharacter sc = null; bool lSpeak = false; bool rSpeak = false; speakerName.Text = ""; if (p != null) { if (IsLeftCharacter(p[0])) { sc = leftCharacter; lSpeak = true; speakerName.BoxLocation = SpeakerNameBox.Location.Left; } else if (IsRightCharacter(p[0])) { sc = rightCharacter; rSpeak = true; speakerName.BoxLocation = SpeakerNameBox.Location.Right; } if (sc != null) { speakerName.Text = sc.Data.names[0]; // Tender Till is a special case... --> if (sc.DataName.Equals("TenderTill")) { if (StoryProgress.Instance.GetBool("TenderMet")) { if (StoryProgress.Instance.GetBool("Nicknamed")) { speakerName.Text = sc.Data.names[1]; } } else { speakerName.Text = sc.Data.names[2]; } } } } leftCharacter.Speaking = lSpeak; rightCharacter.Speaking = rSpeak; }); // progress <varName> <value> --> runner.AddCommandHandler("progress", delegate(string[] p) { StoryProgress.Instance.Set(p[0], p[1]); }); // progressInc <varName> --> runner.AddCommandHandler("progressInc", delegate(string[] p) { StoryProgress.Instance.Set(p[0], StoryProgress.Instance.GetInt(p[0]) + 1); }); // action <type> <function> --> runner.AddCommandHandler("action", delegate(string[] p) { // It's still bad!!! --> MonoBehaviour behaviour = (MonoBehaviour)FindObjectOfType(Type.GetType(p[0])); behaviour.Invoke(p[1], 0f); }); // give <item> [quantity] --> runner.AddCommandHandler("give", delegate(string[] p) { Player.Instance.bag.Add(p[0], p.Length > 1 ? int.Parse(p[1]) : 1); }); // take <item> [quantity] --> runner.AddCommandHandler("take", delegate(string[] p) { Item i = Player.Instance.bag.Get(p[0]); if (i == null) { return; } if (p.Length > 1) { Player.Instance.bag.Remove(i.info, int.Parse(p[1])); } else { Player.Instance.bag.Remove(i); } }); // takeAll --> runner.AddCommandHandler("takeAll", delegate(string[] p) { Player.Instance.bag.Clear(); }); // addMoney <amount> --> runner.AddCommandHandler("addMoney", delegate(string[] p) { ScoreManager.Instance.Money += int.Parse(p[0]); }); // addWood <amount> --> runner.AddCommandHandler("addWood", delegate(string[] p) { ScoreManager.Instance.wood += int.Parse(p[0]); }); // addStones <amount> --> runner.AddCommandHandler("addStones", delegate(string[] p) { ScoreManager.Instance.stones += int.Parse(p[0]); }); runner.AddCommandHandler("till", delegate(string[] p) { for (int i = 0; i < p.Length; i++) { p[i] = CheckVars(p[i]); } FindObjectOfType <Till>().HandleYarnCommand(p); }); // music [musicRefName] --> runner.AddCommandHandler("music", delegate(string[] p) { if (p != null) { MusicRef musicRef = Resources.Load <MusicRef>($"MusicRef/{p[0]}"); if (musicRef != null) { FindObjectOfType <MusicPlayer>().PlaySong(musicRef.clip); } } else { LocationController.Instance.PlayCurrentMusic(); } }); // debugChatProgress <progress> --> runner.AddCommandHandler("debugChatProgress", delegate(string[] p) { if (p != null) { StoryProgress.Instance.Set("TTChatProgress", int.Parse(p[0])); } StoryProgress.Instance.OnDayPassed(); }); // maxBagWeight --> runner.AddCommandHandler("maxBagWeight", delegate(string[] p) { Player.Instance.bag.MaxWeight = int.MaxValue; }); }
void Start() { inst = this; }