Hey,
I am creating dialogue system for my game and I am wondering how should I approach one thing.
I would like to create parser which changes dialogue parameters based on the markers in the string e.g.
“Hey! [w1] You changed since the last time we have seen each other. [e2] [s2] I mean… [w1] In a positive way!”
where:
[w1] means Wait 1.0f,
[e2] means Display expression 2
I would like to create a Dictionary<int, Marker> where “int” is a indexOf marker and I am wondering what would be the most optimal way to do it.
The index should point the the place in message without markers (that means after parsing the dialogue line should be “Hey! You changed since the last time we have seen each other. I mean… In a positive way!”.
My idea is to (in pseudo code):
for character in fullMessage:
find index of "[" in fullMessage
find index of enclosing "]" in fullMessage
put in dictionary found above index of "[" and marker
remove marker (the whole "[w1]") from the fullMessage
adjust loop (e.g. iteration index) to accomodate string length change
I am sure this will work but it just does not seem to be the “cleanest” solution. Any suggestions how differently I could approach the parsing?