Skip to content

Commit f02e73f

Browse files
committed
Update the system, the readme and the example.
Adding [l] [r] function. Fixing [lr] function. Update readme.
1 parent 424cd87 commit f02e73f

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed

ES_msgSystem/Assets/Scripts/MsgSystem.cs

+20-3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ private enum SpecialCharType { StartChar, CmdChar, EndChar, NormalChar }
3737

3838
void Start()
3939
{
40-
//Init the Keywords Function.
40+
//Register the Keywords Function.
4141
specialCharFuncMap.Add("w", () => StartCoroutine(CmdFun_w_Task()));
42+
specialCharFuncMap.Add("r", () => StartCoroutine(CmdFun_r_Task()));
43+
specialCharFuncMap.Add("l", () => StartCoroutine(CmdFun_l_Task()));
4244
specialCharFuncMap.Add("lr", () => StartCoroutine(CmdFun_lr_Task()));
4345
}
4446

@@ -54,6 +56,21 @@ public void SetText(string _text)
5456
#endregion
5557

5658
#region Keywords Function
59+
private IEnumerator CmdFun_l_Task()
60+
{
61+
IsOnCmdEvent = true;
62+
IsWaitingForNextToGo = true;
63+
yield return new WaitUntil(() => IsWaitingForNextToGo == false);
64+
IsOnCmdEvent = false;
65+
yield return null;
66+
}
67+
private IEnumerator CmdFun_r_Task()
68+
{
69+
IsOnCmdEvent = true;
70+
msgText += '\n';
71+
IsOnCmdEvent = false;
72+
yield return null;
73+
}
5774
private IEnumerator CmdFun_w_Task()
5875
{
5976
IsOnCmdEvent = true;
@@ -68,6 +85,7 @@ private IEnumerator CmdFun_lr_Task()
6885
IsOnCmdEvent = true;
6986
IsWaitingForNextToGo = true;
7087
yield return new WaitUntil(() => IsWaitingForNextToGo == false);
88+
msgText += '\n';
7189
IsOnCmdEvent = false;
7290
yield return null;
7391
}
@@ -94,7 +112,7 @@ private SpecialCharType CheckSpecialChar(char _char)
94112
}
95113
else if (_char == SPECIAL_CHAR_END && IsOnSpecialChar)
96114
{
97-
//execmd!!
115+
//exe cmd!
98116
if (specialCharFuncMap.ContainsKey(specialCmd))
99117
{
100118
specialCharFuncMap[specialCmd]();
@@ -131,7 +149,6 @@ private IEnumerator SetTextTask(string _text)
131149
lastChar = _text[i];
132150
yield return new WaitUntil(() => IsOnCmdEvent == false);
133151
}
134-
135152
IsMsgCompleted = true;
136153
yield return null;
137154
}

ES_msgSystem/Assets/textfile.txt

358 Bytes
Binary file not shown.

README.md

+17-9
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,31 @@
44
- ## **Supported keywords in texts**
55
|Keywords|Commands|
66
|-----------|--------|
7-
|lr|wait for press.|
8-
|w|wait for press, and erase the text.|
7+
|l|Wait for press.|
8+
|r|Change the line.|
9+
|lr|Wait for press, and change the line.|
10+
|w|Wait for press, and erase the text.|
911
- ## **Call keywords commands**
1012
### **Use brackets (by defult) to set the keywords commands.**
1113
- The brackets can be changed to another characters.
1214
- If you want to print the brackets (or the special start command character), just repeat it to make the words not a command.
1315
- ex : ( [[w] -> print "[w]" )
1416
- ## **Use cases**
1517
```
16-
1. text: Hello![lr]World![w]
18+
1. text: Hello![l]World![w]
1719
result: Hello!(wait for press)
18-
result: Hello!World!(wait for apress and erase.)
20+
result: Hello!World!(wait for press)
1921
20-
2. text: Hello![w]World![w]
21-
result: Hello!(wait for press and erase.)
22-
result: World!(wait for press and erase.)
22+
2. text: Hello![r]World![w]
23+
result: Hello!
24+
World!(wait for press)
25+
26+
3. text: Hello![lr]World![w]
27+
result: Hello!(wait for press)
28+
result: Hello!
29+
World!(wait for press)
2330
24-
3. text: This is [[w] and this is [[lr].[w]
25-
result: This is [w] and this is [lr].(wait for press and erase.)
31+
4. text: Hello![w]World![w]
32+
result: Hello!(wait for press)
33+
result: World!(wait for press)
2634
```

0 commit comments

Comments
 (0)