diff --git a/isometric-park-fna/Content/dialog.ink b/isometric-park-fna/Content/dialog.ink --- a/isometric-park-fna/Content/dialog.ink +++ b/isometric-park-fna/Content/dialog.ink @@ -2,7 +2,8 @@ VAR GovernorOpinion = 0 //-> IntroGovernor -This is a test. +//-> IntroAssistant +//This is a test. -> END === Once === @@ -41,3 +42,14 @@ -> END +=== IntroAssistant === + +\#assistantName\#: \#whatever\# + * Hi + + \#assistantName\#: Bye + -> END + * How are you? + + \#assistantName\#: \#howdoing\# + -> END \ No newline at end of file diff --git a/isometric-park-fna/Content/dialog.json b/isometric-park-fna/Content/dialog.json --- a/isometric-park-fna/Content/dialog.json +++ b/isometric-park-fna/Content/dialog.json @@ -1,1 +1,1 @@ -{"inkVersion":20,"root":[["^This is a test.","\n","end",["done",{"#f":5,"#n":"g-0"}],null],"done",{"Once":[["^Once upon a time...","\n",["ev",{"^->":"Once.0.2.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-0","flg":18},{"s":["^There were two choices.",{"->":"$r","var":true},null]}],["ev",{"^->":"Once.0.3.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-1","flg":18},{"s":["^There were four lines of content.",{"->":"$r","var":true},null]}],{"c-0":["ev",{"^->":"Once.0.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.2.s"},[{"#n":"$r2"}],"\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["ev",{"^->":"Once.0.c-1.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.3.s"},[{"#n":"$r2"}],"\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^They lived happily ever after.","\n","end",{"#f":5}]}],{"#f":1}],"IntroGovernor":[["^Governor: Welcome to your new park, director! You can use the mouse or arrow keys to move around, and the plus and minus keys to zoom in and out. B opens the budget and F lets you adjust Forest Policy.","\n","ev","str","^Okay","/str","/ev",{"*":".^.c-0","flg":20},{"c-0":["\n","^Governor: Make sure that you keep visitors happy and the budget in the black! You're currently getting an annual grant out of my budget—it'd sure be nice if you park were self-sufficient so we could drop that expense!","\n",["ev","str","^And I need to keep the forest healthy, too, right?","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Sounds good!","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ","\n","ev",{"VAR?":"GovernorOpinion"},1,"-","/ev",{"VAR=":"GovernorOpinion","re":true},"^Governor: Ummm, yeah","\n",[["ev",{"^->":"IntroGovernor.0.c-0.3.c-0.10.0.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-0","flg":18},{"s":["^...",{"->":"$r","var":true},null]}],{"c-0":["ev",{"^->":"IntroGovernor.0.c-0.3.c-0.10.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.0.s"},[{"#n":"$r2"}],"\n","end",{"#f":5}]}],{"#f":5}],"c-1":["\n","ev",{"VAR?":"GovernorOpinion"},1,"+","/ev",{"VAR=":"GovernorOpinion","re":true},"^Governor: I'll check in soon.","\n","end",{"#f":5}]}],{"#f":5}]}],{"#f":1}],"global decl":["ev",0,{"VAR=":"GovernorOpinion"},"/ev","end",null],"#f":1}],"listDefs":{}} \ No newline at end of file +{"inkVersion":20,"root":[["end",["done",{"#f":5,"#n":"g-0"}],null],"done",{"Once":[["^Once upon a time...","\n",["ev",{"^->":"Once.0.2.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-0","flg":18},{"s":["^There were two choices.",{"->":"$r","var":true},null]}],["ev",{"^->":"Once.0.3.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-1","flg":18},{"s":["^There were four lines of content.",{"->":"$r","var":true},null]}],{"c-0":["ev",{"^->":"Once.0.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.2.s"},[{"#n":"$r2"}],"\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["ev",{"^->":"Once.0.c-1.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.3.s"},[{"#n":"$r2"}],"\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^They lived happily ever after.","\n","end",{"#f":5}]}],{"#f":1}],"IntroGovernor":[["^Governor: Welcome to your new park, director! You can use the mouse or arrow keys to move around, and the plus and minus keys to zoom in and out. B opens the budget and F lets you adjust Forest Policy.","\n","ev","str","^Okay","/str","/ev",{"*":".^.c-0","flg":20},{"c-0":["\n","^Governor: Make sure that you keep visitors happy and the budget in the black! You're currently getting an annual grant out of my budget—it'd sure be nice if you park were self-sufficient so we could drop that expense!","\n",["ev","str","^And I need to keep the forest healthy, too, right?","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Sounds good!","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ","\n","ev",{"VAR?":"GovernorOpinion"},1,"-","/ev",{"VAR=":"GovernorOpinion","re":true},"^Governor: Ummm, yeah","\n",[["ev",{"^->":"IntroGovernor.0.c-0.3.c-0.10.0.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-0","flg":18},{"s":["^...",{"->":"$r","var":true},null]}],{"c-0":["ev",{"^->":"IntroGovernor.0.c-0.3.c-0.10.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.0.s"},[{"#n":"$r2"}],"\n","end",{"#f":5}]}],{"#f":5}],"c-1":["\n","ev",{"VAR?":"GovernorOpinion"},1,"+","/ev",{"VAR=":"GovernorOpinion","re":true},"^Governor: I'll check in soon.","\n","end",{"#f":5}]}],{"#f":5}]}],{"#f":1}],"IntroAssistant":[["^#assistantName#: #whatever#","\n","ev","str","^Hi","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^How are you?","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["\n","^#assistantName#: Bye","\n","end",{"#f":5}],"c-1":["\n","^#assistantName#: #howdoing#","\n","end",{"#f":5}]}],{"#f":1}],"global decl":["ev",0,{"VAR=":"GovernorOpinion"},"/ev","end",null],"#f":1}],"listDefs":{}} \ No newline at end of file diff --git a/isometric-park-fna/Engines/Spawners/DialogSpawner.cs b/isometric-park-fna/Engines/Spawners/DialogSpawner.cs --- a/isometric-park-fna/Engines/Spawners/DialogSpawner.cs +++ b/isometric-park-fna/Engines/Spawners/DialogSpawner.cs @@ -55,8 +55,8 @@ AddComponent(newDialog, new DialogComponent { Knot = message.Path, - CurrentDialog = dialog, - CurrentSpeaker = speaker, + CurrentDialog = this.Grammar.Flatten(dialog), + CurrentSpeaker = this.Grammar.Flatten(speaker), Options = this.Story.currentChoices .Select(option => option.text) .ToList()}); diff --git a/isometric-park-fna/Engines/Spawners/GameSpawner.cs b/isometric-park-fna/Engines/Spawners/GameSpawner.cs --- a/isometric-park-fna/Engines/Spawners/GameSpawner.cs +++ b/isometric-park-fna/Engines/Spawners/GameSpawner.cs @@ -111,7 +111,8 @@ #region dialog SendMessage(new SpawnDialogMessage { Path = "IntroGovernor"}); - SendMessage(new SpawnDialogMessage { Path = "Once"}); + // SendMessage(new SpawnDialogMessage { Path = "Once"}); + SendMessage(new SpawnDialogMessage { Path = "IntroAssistant"}); #endregion this.simulation.Subsidy = message.Difficulty switch { DifficultyLevel.Hard => 0M, diff --git a/isometric-park-fna/Engines/UIEngine.cs b/isometric-park-fna/Engines/UIEngine.cs --- a/isometric-park-fna/Engines/UIEngine.cs +++ b/isometric-park-fna/Engines/UIEngine.cs @@ -6,6 +6,7 @@ using Encompass; using Ink.Runtime; +using TraceryNet; using isometricparkfna.Messages; using isometricparkfna.Components; @@ -30,10 +31,12 @@ class UIEngine : Engine { public Story Story; + public Grammar grammar; - public UIEngine(Story story) + public UIEngine(Story story, Grammar grammar) { this.Story = story; + this.grammar = grammar; } public override void Update(double dt) @@ -125,16 +128,15 @@ //Update the dialog component with the new speaker, dialog, and options: var continuation = this.Story.ContinueMaximally(); var parts = Regex.Split(continuation, ":", 0); - var speaker = (parts.Length == 2) ? parts[0] : ""; - var dialog = (parts.Length == 2) ? parts[1] : continuation; + var speaker = (parts.Length == 2) ? this.grammar.Flatten(parts[0]) : "Dialog"; + var dialog = (parts.Length == 2) ? this.grammar.Flatten(parts[1]) : continuation; SetComponent(choiceMessage.Entity, new DialogComponent { - CurrentDialog = dialog, - CurrentSpeaker = speaker, - Options = this.Story.currentChoices - .Select(option => option.text) - .ToList()}); - } + CurrentDialog = dialog, + CurrentSpeaker = speaker, + Options = this.Story.currentChoices + .Select(option => option.text) + .ToList()});} else { Logging.Debug(String.Format("Destroying Dialog (Entity ID {0}).", choiceMessage.Entity.ID)); @@ -169,8 +171,8 @@ Story.ChoosePathString(Knot); var continuation = this.Story.ContinueMaximally(); var parts = Regex.Split(continuation, ":", 0); - var speaker = (parts.Length == 2) ? parts[0] : ""; - var dialog = (parts.Length == 2) ? parts[1] : continuation; + var speaker = (parts.Length == 2) ? this.grammar.Flatten(parts[0]) : "Dialog"; + var dialog = (parts.Length == 2) ? this.grammar.Flatten(parts[1]) : continuation; SetComponent(lowestEntity, new DialogComponent { Knot = Knot, CurrentDialog = dialog, diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -249,7 +249,7 @@ Logging.Debug(this.Story.ContinueMaximally()); WorldBuilder.AddEngine(new InputEngine(Menu.MENU_BAR_HEIGHT, this.camera, gdm)); - WorldBuilder.AddEngine(new UIEngine(this.Story)); + WorldBuilder.AddEngine(new UIEngine(this.Story, this.grammar)); var gameBridgeEngine = new GameBridgeEngine(this);