ConsoleAdventure本体
Revision | 466188ea7d1582d12caaf55208de13fea63c834c (tree) |
---|---|
Time | 2020-08-31 02:24:49 |
Author | yumehiko <yumehik0@iclo...> |
Commiter | yumehiko |
テキスト描画速度を変えるインライン命令[sn](nは任意の数字、小数可)
@@ -32,7 +32,9 @@ namespace Console_Adventure | ||
32 | 32 | //整形済みテキスト |
33 | 33 | Scene myScene = new Scene(); |
34 | 34 | bool initializedGame = false; |
35 | - int speechSpeed = 20; | |
35 | + const int defaultSpeed = 30; | |
36 | + int speechSpeed = defaultSpeed; | |
37 | + double speechMultiplier = 1; | |
36 | 38 | uint flags = 0; |
37 | 39 | |
38 | 40 | public enum GameStats |
@@ -117,7 +119,7 @@ namespace Console_Adventure | ||
117 | 119 | } |
118 | 120 | void SetSpeedConfig() |
119 | 121 | { |
120 | - Console.WriteLine("読む速度(遅延)を入力。単位ms(大きいほどゆっくり。初期値20)"); | |
122 | + Console.WriteLine("読む速度(遅延)を入力。単位ms(大きいほどゆっくり。初期値はdefaultSpeed)"); | |
121 | 123 | Console.Write("遅延(ms):"); |
122 | 124 | string inputCommand = Console.ReadLine(); |
123 | 125 | try |
@@ -126,14 +128,14 @@ namespace Console_Adventure | ||
126 | 128 | } |
127 | 129 | catch |
128 | 130 | { |
129 | - speechSpeed = 20; | |
131 | + speechSpeed = defaultSpeed; | |
130 | 132 | } |
131 | 133 | Console.WriteLine("遅延:{0}", speechSpeed); |
132 | 134 | } |
133 | 135 | |
134 | 136 | void UserInputKey() |
135 | 137 | { |
136 | - Thread.Sleep( speechSpeed * 2 + 1 ); | |
138 | + Thread.Sleep( (int)(speechSpeed * speechMultiplier * 2 + 1) ); | |
137 | 139 | Console.ReadKey(true); |
138 | 140 | switch (stat) |
139 | 141 | { |
@@ -152,9 +154,13 @@ namespace Console_Adventure | ||
152 | 154 | stat = GameStats.speeching; |
153 | 155 | for (int i = 0; i < genLine.Length; i++) |
154 | 156 | { |
155 | - if (stat == GameStats.speeching) | |
157 | + if (genLine[i] == '[') | |
156 | 158 | { |
157 | - await Task.Delay(speechSpeed); | |
159 | + RealtimeOrder(ref genLine, ref i); | |
160 | + } | |
161 | + else if (stat == GameStats.speeching) | |
162 | + { | |
163 | + await Task.Delay( (int)(speechSpeed * speechMultiplier) ); | |
158 | 164 | } |
159 | 165 | Console.Write(genLine[i]); |
160 | 166 | } |
@@ -163,6 +169,17 @@ namespace Console_Adventure | ||
163 | 169 | return 1; |
164 | 170 | } |
165 | 171 | |
172 | + private void RealtimeOrder(ref string genLine, ref int i) | |
173 | + { | |
174 | + int cBPoint = genLine.IndexOf("]", i); | |
175 | + if(genLine[i+1] == 's') | |
176 | + { | |
177 | + double getMultiNum = double.Parse(genLine.Substring(i+2, cBPoint - (i+2))); | |
178 | + speechMultiplier = getMultiNum; | |
179 | + i = cBPoint+1; | |
180 | + } | |
181 | + } | |
182 | + | |
166 | 183 | private int GoToPage(int i) |
167 | 184 | { |
168 | 185 | // [goto n]命令文で指定されたnページを要求する。成功したら0を返す。 |
@@ -1,5 +1,5 @@ | ||
1 | -[flagC 0,32,64][@] | |
2 | -デバッグてきすと。[@]デバッグてきすと。[@]デバッグてきすと。[@] | |
1 | +このあと、[@][s3.5]ものすごくゆっくりと話す。ものすごくゆっくりと話す。ものすごくゆっくりと話す。[@][s1]デバッグてきすと。[@] | |
2 | +このあと、[@][s0.5]ものすごくはやく話す。ものすごくはやく話す。ものすごくはやく話す。[@][s1]デバッグてきすと。[@] | |
3 | 3 | デバッグてきすと。[@]デバッグてきすと。[@]デバッグてきすと。[@] |
4 | 4 | |
5 | 5 | デバッグてきすと。[@]デバッグてきすと。[@]デバッグてきすと。[@] |