-
Notifications
You must be signed in to change notification settings - Fork 1
/
result.cpp
459 lines (410 loc) · 14 KB
/
result.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
# include "Result.hpp"
Result::Result(const InitData& init)
: IScene{ init }
{
// INIファイル
// 全てのセクションを列挙
for (const auto& section : Result_ini.sections())
{
if (section.section == U"Audio") // Audioセクション
{
// セクション内のすべてのキーを列挙
for (const auto& key : section.keys)
{
if (key.name == U"Result_Win_BGM") // ResultWinキー
{
Result_Audio_WinBGM_num = Parse<uint8>(key.value);
}
else if (key.name == U"Result_Lose_BGM")
{
Result_Audio_LoseBGM_num = Parse<uint8>(key.value);
}
}
}
}
// 文字格納
Result_Who_Win = String{ U"...." };
// ストップウォッチ
Result_stopwatch = Stopwatch{ StartImmediately::Yes };
// Player1,Player2の総合スコア
// リセット
Result_TotalScore_Player1 = 0;
Result_TotalScore_Player2 = 0;
// マス目カウント
for (auto i : step(getData().ClearMaze.width()))
{
for (auto j : step(getData().ClearMaze.height()))
{
if (getData().ClearMaze[i][j] == 3)
{
Result_TotalScore_Player1++;
}
else if (getData().ClearMaze[i][j] == 4)
{
Result_TotalScore_Player2++;
}
}
}
// ボーナスポイント
if (getData().goal[0] != getData().goal[1])
{
Result_TotalScore_Player1 += (Result_Bonus_Point * getData().goal[0]);
Result_TotalScore_Player2 += (Result_Bonus_Point * getData().goal[1]);
}
// Bar計算
// Player1とPlayer2の合計スコア
Result_TotalScore_Player1_and_2 = Result_TotalScore_Player1 + Result_TotalScore_Player2;
// Player1のパーセント
Result_percent_Player1 = double(Result_TotalScore_Player1) / Result_TotalScore_Player1_and_2;
// Player2のパーセント
Result_percent_Player2 = double(Result_TotalScore_Player2) / Result_TotalScore_Player1_and_2;
// 勝利者
if (Result_TotalScore_Player1 > Result_TotalScore_Player2)
{
if (getData().pnum == 1)
{
Result_Winner = 1;
}
else if (getData().pnum == 2)
{
Result_Winner = 2;
}
}
else if (Result_TotalScore_Player1 < Result_TotalScore_Player2)
{
if (getData().pnum == 1)
{
Result_Winner = 2;
}
else if (getData().pnum == 2)
{
Result_Winner = 1;
}
}
else if (Result_TotalScore_Player1 == Result_TotalScore_Player2)
{
Result_Winner = 0;
}
// Game時間
// Player1のゲーム時間
Result_GameTime_Player1 = getData().ClearTime[0];
// Player2のゲーム時間
Result_GameTime_Player2 = getData().ClearTime[1];
// 合計プレイ時間
if (getData().goal[0] * getData().goal[1] == 1) // AND
{
if (Result_GameTime_Player1 >= Result_GameTime_Player2)
{
Result_GameTime_All = Result_GameTime_Player1;
}
else
{
Result_GameTime_All = Result_GameTime_Player2;
}
}
else if (getData().goal[0] + getData().goal[1] == 0) // NOR
{
// Gameの最大時間
Result_GameTime_All = int(getData().ChangeMaze.size());
}
else
{
if (getData().goal[0])
{
if (Result_GameTime_Player1 + Result_Time_Countdown < getData().ChangeMaze.size())
{
// 1Pのクリア時間+その後のカウントダウン
Result_GameTime_All = Result_GameTime_Player1 + Result_Time_Countdown;
}
else
{
// Gameの最大時間
Result_GameTime_All = getData().ChangeMaze.size();
}
}
else
{
if (Result_GameTime_Player2 + Result_Time_Countdown < getData().ChangeMaze.size())
{
// 2Pのクリア時間+その後のカウントダウン
Result_GameTime_All = Result_GameTime_Player2 + Result_Time_Countdown;
}
else
{
// Gameの最大時間
Result_GameTime_All = getData().ChangeMaze.size();
}
}
}
// Map
// Mapのドットサイズ
Result_Map_DotSize = 350 / (double)getData().maze.width();
// Map1マスの描画時間
Result_GameTime_Dot = Resukt_Bar_END / Result_GameTime_All;
}
Result::~Result()
{
}
void Result::update()
{
// 音楽
if (Result_Winner == 0 || Result_Winner == 1)
{
// 曲が流れてるか判定
if (AudioAsset(U"Result_Win_BGM" + Format(Result_Audio_WinBGM_num)).isPlaying() == false)
{
if (Result_stopwatch.sF() > Resukt_Bar_END)
{
AudioAsset(U"Result_Win_BGM" + Format(Result_Audio_WinBGM_num)).play(MixBus0);
}
}
else
{
if (Result_stopwatch.sF() <= Resukt_Bar_END)
{
AudioAsset(U"Result_Win_BGM" + Format(Result_Audio_WinBGM_num)).stop();
}
}
}
else if (Result_Winner == 2)
{
// 曲が流れてるか判定
if (AudioAsset(U"Result_Lose_BGM" + Format(Result_Audio_LoseBGM_num)).isPlaying() == false)
{
if (Result_stopwatch.sF() > Resukt_Bar_END)
{
AudioAsset(U"Result_Lose_BGM" + Format(Result_Audio_LoseBGM_num)).play(MixBus0);
}
}
else
{
if (Result_stopwatch.sF() <= Resukt_Bar_END)
{
AudioAsset(U"Result_Lose_BGM" + Format(Result_Audio_LoseBGM_num)).stop();
}
}
}
// Enterで
if (KeyEnter.down() && Result_stopwatch.sF() > Resukt_Bar_END)
{
// 音楽停止
AudioAsset(U"Result_Win_BGM" + Format(Result_Audio_WinBGM_num)).stop();
AudioAsset(U"Result_Lose_BGM" + Format(Result_Audio_LoseBGM_num)).stop();
net->opLeaveRoom();
// タイトルシーンに遷移
changeScene(State::Title);
}
if (net != nullptr)
{
net->update();
}
}
void Result::draw() const
{
// 名前の表示
if (getData().pnum == 1)
{
FontAsset(U"Medium_50")(getData().UserName).drawAt(100, 50);
FontAsset(U"Medium_50")(getData().Opponent_name).drawAt(700, 50);
}
else if (getData().pnum == 2)
{
FontAsset(U"Medium_50")(getData().UserName).drawAt(700, 50);
FontAsset(U"Medium_50")(getData().Opponent_name).drawAt(100, 50);
}
// 勝ち負けの表示
if (Result_stopwatch.sF() > 1.0 && Result_stopwatch.sF() < Resukt_Bar_END)
{
FontAsset(U"Medium_75")(Result_Who_Win.substr(0, static_cast<size_t>((Result_stopwatch.sF() - 1.0) / (Resukt_Bar_END / 4)))).drawAt(400, 50);
}
else if (Result_stopwatch.sF() > Resukt_Bar_END)
{
if (Result_Winner == 0) // 引き分け
{
FontAsset(U"Medium_75")(U"Drow").drawAt(400, 50);
}
else if (Result_Winner == 1) // 勝利時
{
FontAsset(U"Medium_75")(U"Win").drawAt(400, 50);
}
else if (Result_Winner == 2) // 敗北時
{
FontAsset(U"Medium_75")(U"Lose").drawAt(400, 50);
}
}
// 経過時間の表示
if (Result_stopwatch.sF() > Resukt_Bar_END)
{
// 左の人
if (getData().goal[0])
{
FontAsset(U"Medium_40")(Format(Result_GameTime_Player1 / 60) + U" : " + U"{:0>2}"_fmt(Format(Result_GameTime_Player1 % 60))).drawAt(100, 210);
}
else
{
FontAsset(U"Medium_40")(U"Over").drawAt(100, 210);
}
// 右の人
if (getData().goal[1])
{
FontAsset(U"Medium_40")(Format(Result_GameTime_Player2 / 60) + U" : " + U"{:0>2}"_fmt(Format(Result_GameTime_Player2 % 60))).drawAt(700, 210);
}
else
{
FontAsset(U"Medium_40")(U"Over").drawAt(700, 210);
}
}
// ScoreBar
// ScoreBarそのもの
RoundRect{ Arg::center(400, 150), 400, 60, 10 }.draw(Color(0, 0, 0, 127)).drawFrame(0, 3, Color(0, 0, 0, 255));
// 最初のスライド(暗転終了(1.0[s])から途中停止(3.5[s])まで)
if (Result_stopwatch.sF() > 1.0 && Result_stopwatch.sF() < Resukt_Bar_END - 0.25)
{
// 左の人
RoundRect{ 200, 120, 40 * (Result_stopwatch.sF() - 1.0), 60, 10 }.draw(Color(255, 0, 0, 127));
// 右の人
RoundRect{ 600 - 40 * (Result_stopwatch.sF() - 1.0), 120, 40 * (Result_stopwatch.sF() - 1.0), 60, 10 }.draw(Color(0, 0, 255, 127));
// Barのポイント
// 左の人
FontAsset(U"Medium_40")(Format(int(20 * (Result_stopwatch.sF() - 1.0))) + U"pt").drawAt(100, 150);
// 右の人
FontAsset(U"Medium_40")(Format(int(20 * (Result_stopwatch.sF() - 1.0))) + U"pt").drawAt(700, 150);
}
else if (Result_stopwatch.sF() > Resukt_Bar_END - 0.25 && Result_stopwatch.sF() < Resukt_Bar_END)
{
// Barの中身
// 左の人
RoundRect{ 200, 120, (((Result_percent_Player1 * 400) - 100) * ((Result_stopwatch.sF() - 3.5) * 4) + 100), 60, 10 }.draw(Color(255, 0, 0, 127));
// 右の人
RoundRect{ 600 - (((Result_percent_Player2 * 400) - 100) * ((Result_stopwatch.sF() - 3.5) * 4) + 100), 120, (((Result_percent_Player2 * 400) - 100) * ((Result_stopwatch.sF() - 3.5) * 4) + 100), 60, 10 }.draw(Color(0, 0, 255, 127));
// Barのポイント
// 左の人
FontAsset(U"Medium_40")(Format(int(((Result_TotalScore_Player1 - 50) * ((Result_stopwatch.sF() - 3.5) * 4)) + 50)) + U"pt").drawAt(100, 150);
// 右の人
FontAsset(U"Medium_40")(Format(int(((Result_TotalScore_Player2 - 50) * ((Result_stopwatch.sF() - 3.5) * 4)) + 50)) + U"pt").drawAt(700, 150);
}
else if (Result_stopwatch.sF() > Resukt_Bar_END)
{
// Barの中身
// 左の人
RoundRect{ 200, 120, (Result_percent_Player1 * 400), 60, 10 }.draw(Color(0, 0, 255, 127));
// 右の人
RoundRect{ 600 - (Result_percent_Player2 * 400), 120, (Result_percent_Player2 * 400), 60, 10 }.draw(Color(255, 0, 0, 127));
// 左の人
FontAsset(U"Medium_40")(Format(Result_TotalScore_Player1) + U"pt").drawAt(100, 150);
// 右の人
FontAsset(U"Medium_40")(Format(Result_TotalScore_Player2) + U"pt").drawAt(700, 150);
}
// Map表示
// 全体マップの表示場所
Rect(Arg::center(400, 400), 400, 400).draw(Color(139, 69, 19, 255));
// 全体マップ
// 外枠フレーム
RectF(400 - (double)getData().ClearMaze.width() / 2 * Result_Map_DotSize,
400 - (double)getData().ClearMaze.width() / 2 * Result_Map_DotSize, Result_Map_DotSize * getData().ClearMaze.width(),
Result_Map_DotSize * getData().ClearMaze.height()).drawFrame(0, Result_Map_DotSize / 2, Palette::Black);
// Mapの中身
if (Result_stopwatch.sF() <= Resukt_Bar_END)
{
for (auto i : step(getData().ClearMaze.width()))
{
for (auto j : step(getData().ClearMaze.height()))
{
if (getData().ChangeMaze[int(Result_stopwatch.sF() / Result_GameTime_Dot)][i][j] == 0) // 塗られていない床
{
RectF(400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + i * Result_Map_DotSize,
400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + j * Result_Map_DotSize,
Result_Map_DotSize, Result_Map_DotSize).draw(Palette::White);
}
else if (getData().ChangeMaze[int(Result_stopwatch.sF() / Result_GameTime_Dot)][i][j] == 1) // 壁
{
RectF(400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + i * Result_Map_DotSize,
400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + j * Result_Map_DotSize,
Result_Map_DotSize, Result_Map_DotSize).draw(Palette::Brown);
}
else if (getData().ChangeMaze[int(Result_stopwatch.sF() / Result_GameTime_Dot)][i][j] == 2) // ゴール
{
RectF(400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + i * Result_Map_DotSize,
400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + j * Result_Map_DotSize,
Result_Map_DotSize, Result_Map_DotSize).draw(Palette::Gold);
}
else if (getData().ChangeMaze[int(Result_stopwatch.sF() / Result_GameTime_Dot)][i][j] == 3) // 青の塗ったマス
{
RectF(400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + i * Result_Map_DotSize,
400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + j * Result_Map_DotSize,
Result_Map_DotSize, Result_Map_DotSize).draw(Palette::Blue);
}
else if (getData().ChangeMaze[int(Result_stopwatch.sF() / Result_GameTime_Dot)][i][j] == 4) // 赤の塗ったマス
{
RectF(400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + i * Result_Map_DotSize,
400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + j * Result_Map_DotSize,
Result_Map_DotSize, Result_Map_DotSize).draw(Palette::Red);
}
}
}
}
else
{
for (auto i : step(getData().ClearMaze.width()))
{
for (auto j : step(getData().ClearMaze.height()))
{
if (getData().ClearMaze[i][j] == 0) // 塗られていない床
{
RectF(400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + i * Result_Map_DotSize,
400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + j * Result_Map_DotSize,
Result_Map_DotSize, Result_Map_DotSize).draw(Palette::White);
}
else if (getData().ClearMaze[i][j] == 1) // 壁
{
RectF(400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + i * Result_Map_DotSize,
400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + j * Result_Map_DotSize,
Result_Map_DotSize, Result_Map_DotSize).draw(Palette::Brown);
}
else if (getData().ClearMaze[i][j] == 2) // ゴール
{
RectF(400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + i * Result_Map_DotSize,
400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + j * Result_Map_DotSize,
Result_Map_DotSize, Result_Map_DotSize).draw(Palette::Gold);
}
else if (getData().ClearMaze[i][j] == 3) // 青の塗ったマス
{
RectF(400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + i * Result_Map_DotSize,
400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + j * Result_Map_DotSize,
Result_Map_DotSize, Result_Map_DotSize).draw(Palette::Blue);
}
else if (getData().ClearMaze[i][j] == 4) // 赤の塗ったマス
{
RectF(400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + i * Result_Map_DotSize,
400 - getData().ClearMaze.width() / (double)2 * Result_Map_DotSize + j * Result_Map_DotSize,
Result_Map_DotSize, Result_Map_DotSize).draw(Palette::Red);
}
}
}
}
// Item
// 上が数 下が画像
if (Result_stopwatch.sF() > 3.75)
{
for (int i = 0; i < 6; i++)
{
// 左の人
FontAsset(U"Medium_40")(U" : " + Format(getData().Used1[i])).drawAt(100, 275 + i * 50);
TextureAsset(U"Item_Image" + Format(i)).resized(45).drawAt(50, 275 + i * 50);
// 右の人
FontAsset(U"Medium_40")(U" : " + Format(getData().Used2[i])).drawAt(700, 275 + i * 50);
TextureAsset(U"Item_Image" + Format(i)).resized(45).drawAt(650, 275 + i * 50);
}
}
// MenuBar
// Exitキー
// 文字
if (Result_stopwatch.sF() > 3.75)
{
FontAsset(U"Medium_40")(U"EXIT").drawAt(Scene::Center().movedBy(300, 275), Color{ 255, 255, 255, 255 });
}
else
{
FontAsset(U"Medium_40")(U"EXIT").drawAt(Scene::Center().movedBy(300, 275), Color{ 255, 255, 255, 127 });
}
}