File tree 1 file changed +40
-1
lines changed
1 file changed +40
-1
lines changed Original file line number Diff line number Diff line change 4
4
using TMPro ;
5
5
using System ;
6
6
7
- public class TextBoxController : MonoBehaviour
7
+ public class TextBoxController : MonoBehaviour , IListen < NPCController >
8
8
{
9
9
public List < DialogData > dialogData ;
10
10
public event Action < bool > OnShowTextBox ;
@@ -127,4 +127,43 @@ private IEnumerator ShowBox()
127
127
yield return new WaitForSecondsRealtime ( 0.5f ) ;
128
128
}
129
129
}
130
+
131
+ public ( List < int > , Action < dynamic > ) HandleEvent ( NPCController component , IEvent < NPCController > @event )
132
+ {
133
+ return @event switch
134
+ {
135
+ NPCController . Event_Say e => (
136
+ new List < int > ( ) { 100 } ,
137
+ ( payload ) =>
138
+ {
139
+ string [ ] tokens = payload . Split ( "." ) ;
140
+ var character = tokens [ 1 ] ;
141
+ var message = tokens [ 3 ] ;
142
+ switch ( message )
143
+ {
144
+ case "intro" :
145
+ {
146
+ var id = tokens [ 4 ] ;
147
+ SayIntroDialog ( int . Parse ( id ) ) ;
148
+ break ;
149
+ }
150
+ case "valid_recipe" :
151
+ {
152
+ var id = tokens [ 4 ] ;
153
+ SayCorrectIngredientDialog ( int . Parse ( id ) ) ;
154
+ break ;
155
+ }
156
+ case "invalid_recipe" :
157
+ {
158
+ var id = tokens [ 4 ] ;
159
+ SayWrongIngredientDialog ( int . Parse ( id ) ) ;
160
+ break ;
161
+ }
162
+ }
163
+
164
+ }
165
+ ) ,
166
+ _ => ( null , null )
167
+ } ;
168
+ }
130
169
}
You can’t perform that action at this time.
0 commit comments