-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscene_game.cpp
1484 lines (1303 loc) · 45.1 KB
/
scene_game.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
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//////////////////////////////////////////////////
// ゲームメイン シーン
// 作成:
//////////////////////////////////////////////////
#include "main.h"
GameScene::GameScene() {
mode = GameSceneMode::map;
state = play;
frameCounter = 0;
//////////////////////////////////////////////////
player = new Player;
stage = new Stage;
weaponA = new weapon;
weaponB = new second_weapon;
gameUI = new GameUI;
//////////////////////////////////////////////////
map = new Map;
weaponSelect = new Weapon_Selection(weapon_selected);
weaponLevelup = new WeaponLevelUp;
blacksmith = new Blacksmith;
rest = new Rest;
//////////////////////////////////////////////////
minotaur = new Minotaur;
devilKing = new Devil_king;
//////////////////////////////////////////////////
swordHitFlg = false;
bookFlg = false;
devilKingHitFlg = false;
weapon_selected = false;
// レベルアップ画面用
restor_cursor_position = true;
//////////////////////////////////////////////////
hp = 100;
exp = 0;
level = 0;
point = 0;
activeFlg = true;
pauseFlg = false;
currentFloor = 0;
//currentStage = 0;
battleMode = 0;
bossState = 0;
restCnt = 2;
map->ResetStage();
gameUI->setBanner(std::to_string(currentFloor + 1) + "F - 冒険の始まり", "全てのモンスターを倒し、塔の最上階を目指せ!", 1);
// 仮 - 敵をどのステージでどれだけ出すかのデータ生成
std::map<std::string, int> data;
data["slime"] = 10;
data["skeleton"] = 0;
data["wizard"] = 0;
shimabukuro.push_back(data);
for (int i = 1; i < 20; i++) {
data["slime"] = 0;
data["skeleton"] = 0;
data["wizard"] = 0;
shimabukuro.push_back(data);
};
enemySpawnData = shimabukuro[currentFloor];
// 仮 - 経験値の最大値データ生成
for (int i = 1; i < 20; i++) {
expData.push_back(100 * i + (100 * 0.2 * i * i));
};
attackBuf_img = LoadGraph("resources/images/attack_buf.png");
arrow_img = LoadGraph("resources/images/arrow_red.png");
};
GameScene::~GameScene() {
delete player;
delete stage;
delete weaponA;
delete weaponB;
delete gameUI;
delete map;
delete weaponSelect;
delete weaponLevelup;
delete blacksmith;
delete rest;
delete minotaur;
delete devilKing;
};
Scene* GameScene::update() {
activeFlg = (GetMainWindowHandle() == GetForegroundWindow());
// ポーズ
if (InputCtrl::GetButtonState(XINPUT_BUTTON_START) == PRESS || !activeFlg && !pauseFlg) {
if (state)
{
state = 0;
pauseFlg = true;
}
else
{
state++;
pauseFlg = false;
}
}
if (state == pause)
{
SoundManager::StopSoundBGMs();
SoundManager::StopSoundSEs();
return this;
}
//////////////////////////////////////////////////
// 武器のレベルアップ画面(プレイヤーが動けるようになってから)
if (mode >= GameSceneMode::main && gameUI->getState() == playerUI) {
if (mode == GameSceneMode::weaponLevelup && weaponLevelup->GetCloseMode() == 2)
{
restor_cursor_position = true;
mode = GameSceneMode::main;
}
// 武器のレベルアップ画面
if (InputCtrl::GetButtonState(XINPUT_BUTTON_X) == PRESS) {
SoundManager::StopSoundSE("se_player_move"); //プレイヤーの移動SE Stop
if (restor_cursor_position == true)
{
weaponLevelup->SetCloseMode(0);
}
mode = GameSceneMode::weaponLevelup;
};
};
#if 0
if (InputCtrl::GetKeyState(KEY_INPUT_ESCAPE)) return new DebugScene(); // 仮
// 鍛冶ステージテスト用
if (InputCtrl::GetKeyState(KEY_INPUT_B) == PRESS) {
SoundManager::StopSoundBGMs();
if (mode == GameSceneMode::blacksmith) mode = GameSceneMode::main;
else mode = GameSceneMode::blacksmith;
};
//// 強制ゲームクリア
//if (InputCtrl::GetButtonState(XINPUT_BUTTON_Y) == PRESS) {
// SoundManager::StopSoundBGMs();
// SoundManager::SetSoundBGMsPosition(0);
// return new GameClearScene(weaponA, weaponB, map);
//}
// デバッグ - Oキーで強制ボス戦
if (InputCtrl::GetKeyState(KEY_INPUT_O) == PRESS) {
SoundManager::StopSoundBGMs();
SoundManager::SetSoundBGMsPosition(0);
battleMode = GameSceneBattleMode::boss;
};
// デバッグ - Iキーで強制中ボス戦
if (InputCtrl::GetKeyState(KEY_INPUT_I) == PRESS) {
SoundManager::StopSoundBGMs();
SoundManager::SetSoundBGMsPosition(0);
battleMode = GameSceneBattleMode::midBoss;
};
// デバッグ - Uキーで強制ノーマル戦
if (InputCtrl::GetKeyState(KEY_INPUT_U) == PRESS) {
SoundManager::StopSoundBGMs();
SoundManager::SetSoundBGMsPosition(0);
battleMode = GameSceneBattleMode::normal;
};
// デバッグ - レベルアップポイント操作
if (InputCtrl::GetKeyState(KEY_INPUT_UP) == PRESS) point++;
if (InputCtrl::GetKeyState(KEY_INPUT_DOWN) == PRESS) point--;
// デバッグ - HP操作
if (InputCtrl::GetKeyState(KEY_INPUT_RIGHT) == PRESS) player->SetPlayerHP(player->GetPlayer_HP() + 1);
if (InputCtrl::GetKeyState(KEY_INPUT_LEFT) == PRESS) player->SetPlayerHP(player->GetPlayer_HP() - 1);
//武器デバッグ
if (InputCtrl::GetKeyState(KEY_INPUT_1)) {
weaponA->SetWeaponType(dagger);
}
if (InputCtrl::GetKeyState(KEY_INPUT_2)) {
weaponA->SetWeaponType(sword);
}
if (InputCtrl::GetKeyState(KEY_INPUT_3)) {
weaponA->SetWeaponType(greatSword);
}
if (InputCtrl::GetKeyState(KEY_INPUT_4)) {
weaponB->SetWeaponType(spear);
}
if (InputCtrl::GetKeyState(KEY_INPUT_5)) {
weaponB->SetWeaponType(frail);
}
if (InputCtrl::GetKeyState(KEY_INPUT_6)) {
weaponB->SetWeaponType(book);
}
#endif
//////////////////////////////////////////////////
//////////////////////////////////////////////////
// GameUI 仮
if (mode >= GameSceneMode::rest && mode <= GameSceneMode::main) gameUI->update(/*this*/);
gameUI->setStageType(mode);
gameUI->setBattleMode(battleMode);
if (totalAttackBuf > 1.0f) gameUI->setAbilityEnhance(1);
else gameUI->setAbilityEnhance(0);
hp = player->GetPlayer_HP();
int maxHP = player->GetMaxPlayer_hp();
int maxEXP = expData[level];
int coolTime = (int)player->GetCoolTimeCounter(), maxCoolTime = player->GetAvoidance_limit() * 60;
gameUI->setCoolTime(coolTime, maxCoolTime);
gameUI->setHP(hp, maxHP, ((float)hp / (float)maxHP) * 100);
gameUI->setEXP(exp, maxEXP, ((float)exp / (float)maxEXP) * 100);
gameUI->setPoint(point);
gameUI->setFloor(currentFloor + 1);
gameUI->setEnemy(getEnemyNum(0), getEnemyMax(0));
gameUI->setWeapon({ weaponA->GetWeaponType(), weaponA->GetWeaponLevel(), false, weaponA->GetCoolTime(), weaponA->GetMaxCoolTime() }, { weaponB->GetWeaponType(), weaponB->GetWeaponLevel(), false, weaponB->GetCoolTime(), weaponB->GetMaxCoolTime() });
//////////////////////////////////////////////////
if (mode == GameSceneMode::main) {
if (battleMode == GameSceneBattleMode::normal)
{
SoundManager::PlaySoundBGM("bgm_normal");
}
if (battleMode == GameSceneBattleMode::midBoss)
{
SoundManager::PlaySoundBGM("bgm_middleboss");
}
if (battleMode == GameSceneBattleMode::boss)
{
SoundManager::PlaySoundBGM("bgm_boss");
}
if (gameUI->getState() >= banner_playerUI) {
if (restCnt <= 0)
{
rest->SetRestBufFlg(false);
}
//敵
HitCheck();
if (battleMode == GameSceneBattleMode::normal) SlimeUpdate();
if (battleMode == GameSceneBattleMode::normal) SkeletonUpdate();
if (battleMode == GameSceneBattleMode::normal) WizardUpdate();
if (battleMode == GameSceneBattleMode::midBoss) MinotaurUpdate();
if (battleMode == GameSceneBattleMode::boss) DevilKingUpdate();
weaponA->SetAttackBuf(rest->GetRestBufFlg());
totalAttackBuf = weaponA->GetAttackBuf() * weaponB->GetAttackBufRate();
pl = player->GetLocation();
//武器と敵の当たり判定
if (true/*currentFloor == 1*/) {
if (battleMode == GameSceneBattleMode::normal) {
for (int i = 0; i < enemySpawnData["slime"]; i++) {
if (slime[i] != nullptr) {
if (weaponA->WeaponCollision(slime[i]->GetEnemyLocation(), slime[i]->GetEnemyRadius())) {
if (slime[i]->GetHitFrameCnt() == 0) {
SoundManager::PlaySoundSE("se_enemy_damage", false);
slime[i]->SetHitWeaponFlg();
//ダメージアップ
slime[i]->SetHitHP(weaponA->GetDamage() * totalAttackBuf);
slime[i]->SetHit1stFrameFlg(true);
if (weaponA->GetIsAttacking() && !swordHitFlg) {
swordHitFlg = true;
weaponA->SetHitCnt(true);
weaponA->SwordLevel8(player);
weaponA->SwordLevel8Heel(player);
}
weaponA->AddTotalDamage();
}
}
if (weaponB->WeaponCollision(slime[i]->GetEnemyLocation(), slime[i]->GetEnemyRadius())) {
if (slime[i]->GetHitFrameCnt() == 0) {
SoundManager::PlaySoundSE("se_enemy_damage", false);
slime[i]->SetHitWeaponFlg();
slime[i]->SetHitHP(weaponB->GetDamage() * totalAttackBuf);
slime[i]->SetHit1stFrameFlg(true);
if (weaponB->GetWeaponType() == spear && weaponB->GetWeaponLevel() == 8) {
weaponB->SetThunderLocation(slime[i]->GetEnemyLocation());
if (weaponB->SpearThunderCollision(slime[i]->GetEnemyLocation(), slime[i]->GetEnemyRadius())) {
slime[i]->SetHitHP(weaponB->GetThunderDamage());
weaponB->AddTotalDamageThunder();
}
}
weaponB->AddTotalDamage();
}
}
if (weaponA->DustCollision(slime[i]->GetEnemyLocation(), slime[i]->GetEnemyRadius())) {
if (slime[i]->GetHitFrameCnt() == 0) {
SoundManager::PlaySoundSE("se_enemy_damage", false);
slime[i]->SetHitWeaponFlg();
//ダメージアップ
slime[i]->SetHitHP(weaponA->GetDustDamage());
slime[i]->SetHit1stFrameFlg(true);
slime[i]->SetCloudOfDustHitFlg(true);
weaponA->AddTotalDamageDust();
}
}
}
}
for (int i = 0; i < enemySpawnData["skeleton"]; i++) {
if (skeleton[i] != nullptr) {
if (weaponA->WeaponCollision(skeleton[i]->GetEnemyLocation(), skeleton[i]->GetEnemyRadius())) {
if (skeleton[i]->GetHitFrameCnt() == 0) {
SoundManager::PlaySoundSE("se_enemy_damage", false);
skeleton[i]->SetHitWeaponFlg();
skeleton[i]->SetHitHP(weaponA->GetDamage() * totalAttackBuf);
skeleton[i]->SetHit1stFrameFlg(true);
if (weaponA->GetIsAttacking() && !swordHitFlg) {
swordHitFlg = true;
weaponA->SetHitCnt(true);
weaponA->SwordLevel8(player);
weaponA->SwordLevel8Heel(player);
}
weaponA->AddTotalDamage();
}
}
if (weaponB->WeaponCollision(skeleton[i]->GetEnemyLocation(), skeleton[i]->GetEnemyRadius())) {
if (skeleton[i]->GetHitFrameCnt() == 0) {
SoundManager::PlaySoundSE("se_enemy_damage", false);
skeleton[i]->SetHitWeaponFlg();
skeleton[i]->SetHitHP(weaponB->GetDamage() * totalAttackBuf);
skeleton[i]->SetHit1stFrameFlg(true);
if (weaponB->GetWeaponType() == spear && weaponB->GetWeaponLevel() == 8) {
weaponB->SetThunderLocation(skeleton[i]->GetEnemyLocation());
if (weaponB->SpearThunderCollision(skeleton[i]->GetEnemyLocation(), skeleton[i]->GetEnemyRadius())) {
skeleton[i]->SetHitHP(weaponB->GetThunderDamage());
weaponB->AddTotalDamageThunder();
}
}
weaponB->AddTotalDamage();
}
}
if (weaponA->DustCollision(skeleton[i]->GetEnemyLocation(), skeleton[i]->GetEnemyRadius())) {
if (skeleton[i]->GetHitFrameCnt() == 0) {
SoundManager::PlaySoundSE("se_enemy_damage", false);
skeleton[i]->SetHitWeaponFlg();
//ダメージアップ
skeleton[i]->SetHitHP(weaponA->GetDustDamage());
skeleton[i]->SetHit1stFrameFlg(true);
skeleton[i]->SetCloudOfDustHitFlg(true);
weaponA->AddTotalDamageDust();
}
}
}
}
for (int i = 0; i < enemySpawnData["wizard"]; i++) {
if (wizard[i] != nullptr) {
if (weaponA->WeaponCollision(wizard[i]->GetEnemyLocation(), wizard[i]->GetEnemyRadius())) {
if (wizard[i]->GetHitFrameCnt() == 0) {
SoundManager::PlaySoundSE("se_enemy_damage", false);
wizard[i]->SetHitWeaponFlg();
//ダメージアップ
wizard[i]->SetHitHP(weaponA->GetDamage() * totalAttackBuf);
wizard[i]->SetHit1stFrameFlg(true);
if (weaponA->GetIsAttacking() && !swordHitFlg) {
swordHitFlg = true;
weaponA->SetHitCnt(true);
weaponA->SwordLevel8(player);
}
weaponA->AddTotalDamage();
}
}
if (weaponB->WeaponCollision(wizard[i]->GetEnemyLocation(), wizard[i]->GetEnemyRadius())) {
if (wizard[i]->GetHitFrameCnt() == 0) {
SoundManager::PlaySoundSE("se_enemy_damage", false);
wizard[i]->SetHitWeaponFlg();
wizard[i]->SetHitHP(weaponB->GetDamage() * totalAttackBuf);
wizard[i]->SetHit1stFrameFlg(true);
if (weaponB->GetWeaponType() == spear && weaponB->GetWeaponLevel() == 8) {
weaponB->SetThunderLocation(wizard[i]->GetEnemyLocation());
if (weaponB->SpearThunderCollision(wizard[i]->GetEnemyLocation(), wizard[i]->GetEnemyRadius())) {
wizard[i]->SetHitHP(weaponB->GetThunderDamage());
weaponB->AddTotalDamageThunder();
}
}
weaponB->AddTotalDamage();
}
}
if (weaponA->DustCollision(wizard[i]->GetEnemyLocation(), wizard[i]->GetEnemyRadius())) {
if (wizard[i]->GetHitFrameCnt() == 0) {
SoundManager::PlaySoundSE("se_enemy_damage", false);
wizard[i]->SetHitWeaponFlg();
//ダメージアップ
wizard[i]->SetHitHP(weaponA->GetDustDamage());
wizard[i]->SetHit1stFrameFlg(true);
wizard[i]->SetCloudOfDustHitFlg(true);
weaponA->AddTotalDamageDust();
}
}
}
}
};
//ミノタウロス
if (battleMode == GameSceneBattleMode::midBoss) {
if (minotaur != nullptr) {
if (weaponA->WeaponCollision(minotaur->GetEnemyLocation(), minotaur->GetEnemyRadius())) {
if (minotaur->GetHitFrameCnt() == 0) {
SoundManager::PlaySoundSE("se_enemy_damage", false);
minotaur->SetHitWeaponFlg();
//ダメージアップ
minotaur->SetHitHP(weaponA->GetDamage() * totalAttackBuf);
minotaur->SetHit1stFrameFlg(true);
if (weaponA->GetIsAttacking() && !swordHitFlg) {
swordHitFlg = true;
weaponA->SetHitCnt(true);
weaponA->SwordLevel8(player);
}
weaponA->AddTotalDamage();
}
}
if (weaponB->WeaponCollision(minotaur->GetEnemyLocation(), minotaur->GetEnemyRadius())) {
if (minotaur->GetHitFrameCnt() == 0) {
SoundManager::PlaySoundSE("se_enemy_damage", false);
minotaur->SetHitWeaponFlg();
minotaur->SetHitHP(weaponB->GetDamage() * totalAttackBuf);
minotaur->SetHit1stFrameFlg(true);
if (weaponB->GetWeaponType() == spear && weaponB->GetWeaponLevel() == 8) {
weaponB->SetThunderLocation(minotaur->GetEnemyLocation());
if (weaponB->SpearThunderCollision(minotaur->GetEnemyLocation(), minotaur->GetEnemyRadius())) {
minotaur->SetHitHP(weaponB->GetThunderDamage());
weaponB->AddTotalDamageThunder();
}
}
weaponB->AddTotalDamage();
}
}
if (weaponA->DustCollision(minotaur->GetEnemyLocation(), minotaur->GetEnemyRadius())) {
if (minotaur->GetHitFrameCnt() == 0) {
SoundManager::PlaySoundSE("se_enemy_damage", false);
minotaur->SetHitWeaponFlg();
//ダメージアップ
minotaur->SetHitHP(weaponA->GetDustDamage());
minotaur->SetHit1stFrameFlg(true);
minotaur->SetCloudOfDustHitFlg(true);
weaponA->AddTotalDamageDust();
}
}
}
};
//魔王
if (battleMode == GameSceneBattleMode::boss) {
if (devilKing != nullptr) {
if (weaponA->WeaponCollision(devilKing->GetEnemyLocation(), devilKing->GetEnemyRadius())) {
if (devilKing->GetShieldFlg() == true) {//シールドが0なら
if (devilKing->GetHitFrameCnt() == 0) {
SoundManager::PlaySoundSE("se_enemy_damage", false);
devilKing->SetHitWeaponFlg();
//ダメージアップ
devilKing->SetHitHP(weaponA->GetDamage() * totalAttackBuf);
devilKing->SetHit1stFrameFlg(true);
if (weaponA->GetIsAttacking() && !swordHitFlg) {
swordHitFlg = true;
weaponA->SetHitCnt(true);
weaponA->SwordLevel8(player);
}
weaponA->AddTotalDamage();
}
}
}
if (weaponB->WeaponCollision(devilKing->GetEnemyLocation(), devilKing->GetEnemyRadius()) /*&& !devilKingHitFlg*/) {
devilKingHitFlg = true;
if (devilKing->GetShieldFlg() == true) {//シールドが0なら
if (devilKing->GetHitFrameCnt() == 0) {
SoundManager::PlaySoundSE("se_enemy_damage", false);
devilKing->SetHitWeaponFlg();
devilKing->SetHitHP(weaponB->GetDamage() * totalAttackBuf);
devilKing->SetHit1stFrameFlg(true);
if (weaponB->GetWeaponType() == spear && weaponB->GetWeaponLevel() == 8) {
weaponB->SetThunderLocation(devilKing->GetEnemyLocation());
if (weaponB->SpearThunderCollision(devilKing->GetEnemyLocation(), devilKing->GetEnemyRadius())) {
devilKing->SetHitHP(weaponB->GetThunderDamage());
weaponB->AddTotalDamageThunder();
}
}
weaponB->AddTotalDamage();
}
}
}
else {
devilKingHitFlg = false;
}
if (weaponA->DustCollision(devilKing->GetEnemyLocation(), devilKing->GetEnemyRadius())) {
if (devilKing->GetShieldFlg() == true) {//シールドが0なら
if (devilKing->GetHitFrameCnt() == 0) {
SoundManager::PlaySoundSE("se_enemy_damage", false);
devilKing->SetHitWeaponFlg();
//ダメージアップ
devilKing->SetHitHP(weaponA->GetDustDamage());
devilKing->SetHit1stFrameFlg(true);
devilKing->SetCloudOfDustHitFlg(true);
weaponA->AddTotalDamageDust();
}
}
}
}
//魔王の弾
for (int i = 0; i < MAX_BULLET_NUM; i++) {
if (bigEnemyBullet[i] != nullptr) {
if (weaponA->WeaponCollision(bigEnemyBullet[i]->GetEnemyLocation(), bigEnemyBullet[i]->GetEnemyRadius())) {
//weaponAと魔王の弾の当たり判定
bigEnemyBullet[i]->SetHitWeapon(true);
if (true);
}
if (weaponB->WeaponCollision(bigEnemyBullet[i]->GetEnemyLocation(), bigEnemyBullet[i]->GetEnemyRadius())) {
//weaponBと魔王の弾の当たり判定
/*bigEnemyBullet[i]->SetHitWeapon(true);*/
}
}
}
//幽霊
for (int i = 0; i < MAX_GHOST_NUM; i++) {
if (ghost[i] != nullptr) {
if (weaponA->WeaponCollision(ghost[i]->GetEnemyLocation(), ghost[i]->GetEnemyRadius())) {
if (ghost[i]->GetHitFrameCnt() == 0) {
SoundManager::PlaySoundSE("se_enemy_damage", false);
ghost[i]->SetHitWeaponFlg();
//ダメージアップ
ghost[i]->SetHitHP(weaponA->GetDamage() * totalAttackBuf);
ghost[i]->SetHit1stFrameFlg(true);
if (weaponA->GetIsAttacking() && !swordHitFlg) {
swordHitFlg = true;
weaponA->SetHitCnt(true);
weaponA->SwordLevel8(player);
}
weaponA->AddTotalDamage();
}
if (true);
}
if (weaponB->WeaponCollision(ghost[i]->GetEnemyLocation(), ghost[i]->GetEnemyRadius())) {
if (ghost[i]->GetHitFrameCnt() == 0) {
SoundManager::PlaySoundSE("se_enemy_damage", false);
ghost[i]->SetHitWeaponFlg();
ghost[i]->SetHitHP(weaponB->GetDamage() * totalAttackBuf);
ghost[i]->SetHit1stFrameFlg(true);
if (weaponB->GetWeaponType() == spear && weaponB->GetWeaponLevel() == 8) {
weaponB->SetThunderLocation(ghost[i]->GetEnemyLocation());
if (weaponB->SpearThunderCollision(ghost[i]->GetEnemyLocation(), ghost[i]->GetEnemyRadius())) {
ghost[i]->SetHitHP(weaponB->GetThunderDamage());
weaponB->AddTotalDamageThunder();
}
}
weaponB->AddTotalDamage();
}
}
if (weaponA->DustCollision(ghost[i]->GetEnemyLocation(), ghost[i]->GetEnemyRadius())) {
if (ghost[i]->GetHitFrameCnt() == 0) {
SoundManager::PlaySoundSE("se_enemy_damage", false);
ghost[i]->SetHitWeaponFlg();
//ダメージアップ
ghost[i]->SetHitHP(weaponA->GetDustDamage());
ghost[i]->SetHit1stFrameFlg(true);
ghost[i]->SetCloudOfDustHitFlg(true);
weaponA->AddTotalDamageDust();
}
}
}
}
};
}
if (!weaponA->GetIsAttacking() && weaponA->GetOldIsAttacking()) {
if (!swordHitFlg) {
weaponA->SetHitCnt(false);
}
swordHitFlg = false;
}
//バリア
if (weaponB->GetWeaponType() == book && weaponB->GetWeaponLevel() == 7 && weaponB->GetCoolTime() == 0) {
weaponA->SetCoolTime(0.1f, true);
weaponB->SetBarrierFlg(true);
bookFlg = true;
}
else if (weaponB->GetCoolTime() < INIT_COOLTIME_BOOK_LEVEL7 * 0.5f && bookFlg == true) {
weaponA->SetCoolTime(1.0f, false);
weaponB->SetBarrierFlg(false);
bookFlg = false;
}
////////////
player->SetLeftTop(stage->GetStageArray(0));
player->SetRightBottom(stage->GetStageArray(8));
stage->update(player->Player_MoveX(), player->Player_MoveY());
player->update(minotaur->GetRoarHitFlg());
weaponA->Update(player->Player_AimingX(), player->Player_AimingY(), player->Player_Location(), player);
Vector tmpV = { player->Player_MoveX(),player->Player_MoveY(),0 };
weaponB->Update(player->Player_AimingX(), player->Player_AimingY(), player->Player_Location(), tmpV, player);
EnemyInc();//敵のダメージストップ関係
//////////////////////////////////////////////////
// GameUI 仮
if (getEnemyNum(0) <= 0 && frameCounter) {
SoundManager::StopSoundSE("se_player_move");
if (battleMode == GameSceneBattleMode::normal) gameUI->setBanner("すべてのモンスターを倒した!", std::to_string(currentFloor + 1) + "F - 魔王の手下たちの部屋 制覇", 0);
if (battleMode == GameSceneBattleMode::midBoss) gameUI->setBanner("ミノタウロスを倒した!", std::to_string(currentFloor + 1) + "F - ミノタウロスの部屋 制覇", 0);
if (battleMode == GameSceneBattleMode::boss) gameUI->setBanner("勝利! 魔王討伐完了", "戦塔を制覇!", 0);
if (gameUI->getState() == playerUI) {
gameUI->init();
gameUI->setState(banner);
};
if (gameUI->getState() == banner_playerUI) {
// 黒帯消滅後に発火
map->ClearStage();
currentFloor++;
if (rest->GetRestBufFlg())
{
restCnt--;
}
SoundManager::StopSoundBGMs();
SoundManager::SetSoundBGMsPosition(0);
SoundManager::StopSoundSEs();
if (battleMode == GameSceneBattleMode::midBoss)
{
mode = GameSceneMode::weaponSelect;
}
else if (battleMode == GameSceneBattleMode::boss)
{
return new GameClearScene(weaponA, weaponB, map);
}
else
{
mode = GameSceneMode::map;
}
};
weaponA->SetAvoidanceDamageFlg(false);
};
if (hp <= 0) {
gameUI->setBanner("敗北", "体力が尽きた.....", 0);
if (gameUI->getState() == playerUI) {
gameUI->init();
gameUI->setState(banner);
};
if (gameUI->getState() == banner_playerUI) {
// 黒帯消滅後に発火
SoundManager::StopSoundBGMs();
SoundManager::SetSoundBGMsPosition(0);
return new GameOverScene(weaponA, weaponB, map);
};
};
//////////////////////////////////////////////////
if (battleMode == GameSceneBattleMode::midBoss) gameUI->setEnemyHP("この塔の門番 - ミノタウロス", (int)(minotaur->GetHP()), MINOTAUR_MAX_HP, (int)((minotaur->GetHP() / MINOTAUR_MAX_HP) * 100.0f));
if (battleMode == GameSceneBattleMode::boss) {
if (devilKing != nullptr) {
if (devilKing->GetShieldFlg()) gameUI->setEnemyHP ("この塔を統べる - 魔王", (int)(devilKing->GetHP()), DEVILKING_MAX_HP, (int)((devilKing->GetHP() / DEVILKING_MAX_HP) * 100.0f));
if (!devilKing->GetShieldFlg()) gameUI->setShieldHP("この塔を統べる - 魔王", (int)(devilKing->GetShield()), MAX_SHIELD, (int)((devilKing->GetShield() / MAX_SHIELD) * 100.0f));
};
};
//printfDx("%d\n", static_cast<int>((SLIME_1_STAGE_NUM / c) * 100.0f));
//printfDx("%f\n", (c / SLIME_1_STAGE_NUM) * 100.0f);
//////////////////////////////////////////////////
// 経験値、レベル、ポイント処理
if (exp >= expData[level]) {
exp = 0;
level++;
point++;
gameUI->notification("武器強化可能!", "Xボタンで確認", "btnX");
};
if (battleMode == GameSceneBattleMode::midBoss) bossState = 1; // 中ボス遭遇済み
};
frameCounter++;
};
if (mode == GameSceneMode::weaponSelect) {
weaponSelect->update(weaponA, weaponB, weapon_selected, mode);
return this;
};
if (mode == GameSceneMode::weaponLevelup) {
if (battleMode == GameSceneBattleMode::normal)
{
SoundManager::PlaySoundBGM("bgm_normal");
}
if (battleMode == GameSceneBattleMode::midBoss)
{
SoundManager::PlaySoundBGM("bgm_middleboss");
}
if (battleMode == GameSceneBattleMode::boss)
{
SoundManager::PlaySoundBGM("bgm_boss");
}
weaponLevelup->update(weaponA, weaponB, player, restor_cursor_position, point);
return this;
};
//////////////////////////////////////////////////
if (mode == GameSceneMode::map) {
map->update(mode, battleMode, weapon_selected);
if (mode >= GameSceneMode::main) init();
return this;
};
if (mode == GameSceneMode::blacksmith) {
blacksmith->update(weaponA, weaponB, weaponLevelup, player, point, mode, currentFloor);
//if (mode >= GameSceneMode::map) map->ClearStage();
return this;
};
if (mode == GameSceneMode::rest) {
rest->update(player, mode, currentFloor, restCnt, hp);
//if (mode >= GameSceneMode::map) map->ClearStage();
return this;
};
#if 0
clsDx();
printfDx("[ GameMain ] 上下キー: ポイント操作、左右キー: HP、P: ポーズ、O: ボス戦、I: 中ボス戦、U: ノーマル戦、S: GameUI Skip\n");
//printfDx("敵最大数:(スラ: %d)(スケ: %d)(ウィザ: %d)(ミノ: %d)\n", getEnemyMax(1), getEnemyMax(2), getEnemyMax(3), getEnemyMax(4));
//printfDx("残りの敵:(スラ: %d)(スケ: %d)(ウィザ: %d)(ミノ: %d)\n", getEnemyNum(1), getEnemyNum(2), getEnemyNum(3), getEnemyNum(4));
#endif
return this;
};
void GameScene::draw() const {
if (mode >= GameSceneMode::main) {
stage->draw();
player->draw();
weaponA->Draw();
weaponB->Draw();
if (totalAttackBuf > 1.0f) {
DrawRotaGraph2(pl.x - 25, pl.y - 47, 250, 250, 0.07, 0, attackBuf_img, TRUE, TRUE);
DrawRotaGraph2(pl.x + 5, pl.y - 47, 250, 250, 0.05, M_PI / 2 + M_PI, arrow_img, TRUE, TRUE);
if (totalAttackBuf > 2.0f) {
DrawRotaGraph2(pl.x - 5, pl.y - 47, 250, 250, 0.05, M_PI / 2 + M_PI, arrow_img, TRUE, TRUE);
}
}
// 敵
if (battleMode == GameSceneBattleMode::normal) SlimeDraw();
if (battleMode == GameSceneBattleMode::normal) SkeletonDraw();
if (battleMode == GameSceneBattleMode::normal) WizardDraw();
if (battleMode == GameSceneBattleMode::normal) EnemyBulletDraw();
if (battleMode == GameSceneBattleMode::midBoss) MinotaurDraw();
if (battleMode == GameSceneBattleMode::boss) DevilKingDraw();
if (battleMode == GameSceneBattleMode::boss) BigEnemyBulletDraw();
if (battleMode == GameSceneBattleMode::boss) SmallEnemyBulletDraw();
if (battleMode == GameSceneBattleMode::boss) GhostDraw();
//////////////////////////////////////////////////
if (mode == GameSceneMode::weaponSelect) {
weaponSelect->draw(weapon_selected);
}
else {
gameUI->draw(0);
if (battleMode == GameSceneBattleMode::midBoss) gameUI->drawEnemyHP(); // ボスの体力ゲージ
if (battleMode == GameSceneBattleMode::boss) {
if (devilKing != nullptr) {
if (devilKing->GetShieldFlg()) gameUI->drawEnemyHP();
if (!devilKing->GetShieldFlg()) gameUI->drawShieldHP();
};
};
};
if (mode == GameSceneMode::weaponLevelup) weaponLevelup->draw();
};
//////////////////////////////////////////////////
if (mode == GameSceneMode::map) map->draw();
if (mode == GameSceneMode::blacksmith) blacksmith->draw(weaponLevelup);
if (mode == GameSceneMode::rest) {
rest->draw();
gameUI->draw(1);
};
//////////////////////////////////////////////////
if (state == pause) gameUI->drawPause();
};
void GameScene::init() {
delete player;
player = new Player();
player->SetPlayerHP(hp);
delete stage;
stage = new Stage();
weaponA->InitWeapon();
weaponB->InitWeapon(1);
for (int i = 0; i < MAX_SLIME_NUM; i++) {
slime[i] = nullptr;
};
tmpSlimeNum = 0;
for (int i = 0; i < MAX_SKELETON_NUM; i++) {
skeleton[i] = nullptr;
};
tmpSkeletonNum = 0;
for (int i = 0; i < MAX_WIZARD_NUM; i++) {
wizard[i] = nullptr;
};
tmpWizardNum = 0;
for (int i = 0; i < MAX_BULLET_NUM; i++) {
enemyBullet[i] = nullptr;
};
tmpBulletNum = 0;
if (battleMode == GameSceneBattleMode::normal) gameUI->setBanner(std::to_string(currentFloor + 1) + "F - 魔王の手下の部屋", "全てのモンスターを倒せ!", 1);
else if (battleMode == GameSceneBattleMode::midBoss) gameUI->setBanner(std::to_string(currentFloor + 1) + "F - ミノタウロスの部屋", "打ち勝て!", 1);
else if (battleMode == GameSceneBattleMode::boss) gameUI->setBanner("最上階 - ラスボス 魔王の部屋", "魔王「我に勝てるかな?」"/*"特に何もしていない魔王を討伐してください"*/, 1);
gameUI->init();
gameUI->setState(banner);
// 仮 - 敵をどのステージでどれだけ出すかのデータ生成(中ボス以降版)
std::map<std::string, int> data;
for (int i = currentFloor + 1; i < 20; i++) {
data["slime"] = shimabukuro[i - 1]["slime"] + 10;
data["skeleton"] = 0;
data["wizard"] = 0;
if ((battleMode == GameSceneBattleMode::midBoss) || bossState) data["skeleton"] = shimabukuro[i - 1]["skeleton"] + 5;
if ((battleMode == GameSceneBattleMode::midBoss) || bossState) data["wizard"] = shimabukuro[i - 1]["wizard"] + 3;
shimabukuro[i] = data;
};
enemySpawnData = shimabukuro[currentFloor];
//exp = 0;
};
int GameScene::getEnemyMax(int type) {
int slimeNum = 0;
int skeletonNum = 0;
int wizardNum = 0;
int minotourNum = 0;
int bossNum = 0;
if (battleMode == GameSceneBattleMode::normal) slimeNum = enemySpawnData["slime"];
if (battleMode == GameSceneBattleMode::normal) skeletonNum = enemySpawnData["skeleton"];
if (battleMode == GameSceneBattleMode::normal) wizardNum = enemySpawnData["wizard"];
if (battleMode == GameSceneBattleMode::midBoss) minotourNum = 1;
if (battleMode == GameSceneBattleMode::boss) bossNum = 1;
if (type == 0) return (slimeNum + skeletonNum + wizardNum + minotourNum + bossNum);
if (type == 1) return slimeNum;
if (type == 2) return skeletonNum;
if (type == 3) return wizardNum;
if (type == 4) return minotourNum;
if (type == 5) return bossNum;
};
int GameScene::getEnemyNum(int type) {
int slimeNum = 0;
int skeletonNum = 0;
int wizardNum = 0;
int minotourNum = 0;
int bossNum = 0;
if (battleMode == GameSceneBattleMode::normal) {
for (int i = 0; i < MAX_SLIME_NUM; i++) {
if (slime[i] != nullptr) slimeNum++;
};
for (int i = 0; i < MAX_SKELETON_NUM; i++) {
if (skeleton[i] != nullptr) skeletonNum++;
};
for (int i = 0; i < MAX_WIZARD_NUM; i++) {
if (wizard[i] != nullptr) wizardNum++;
};
};
if (battleMode == GameSceneBattleMode::midBoss && (minotaur->GetHP() > 0.0f)) minotourNum = 1;
if (devilKing != nullptr) {
if (battleMode == GameSceneBattleMode::boss && (devilKing->GetHP() > 0.0f)) bossNum = 1;
}
else {
bossNum = 0;
};
if (type == 0) return (slimeNum + skeletonNum + wizardNum + minotourNum + bossNum);
if (type == 1) return slimeNum;
if (type == 2) return skeletonNum;
if (type == 3) return wizardNum;
if (type == 4) return minotourNum;
if (type == 5) return bossNum;
};
//////////////////////////////////////////////////
// 当たり判定・敵の処理
//////////////////////////////////////////////////
void GameScene::HitCheck() {
if (battleMode == GameSceneBattleMode::normal) {
//スライムの当たり判定
for (int i = 0; i < MAX_SLIME_NUM; i++) {
if (slime[i] != nullptr) {
HitEnemy(slime[i]);//プレイヤーとの当たり判定
for (int j = 0; j < MAX_SLIME_NUM; j++) {
if (slime[j] != nullptr && i != j) {
if (slime[i]->CheckCollision(static_cast<SphereCollider>(*slime[j]), player) == HIT) {//当たっている
slime[i]->SetHitFlg(HIT);
slime[j]->SetHitFlg(HIT);
slime[i]->HitVectorCale(static_cast<SphereCollider>(*slime[j]), player);
slime[j]->HitVectorCale(static_cast<SphereCollider>(*slime[i]), player);
}
}
}
}
}
//スケルトンの当たり判定
for (int i = 0; i < MAX_SKELETON_NUM; i++) {
if (skeleton[i] != nullptr) {
HitEnemy(skeleton[i]);//プレイヤーとの当たり判定
for (int j = 0; j < MAX_SKELETON_NUM; j++) {
if (skeleton[j] != nullptr && i != j) {
if (skeleton[i]->CheckCollision(static_cast<SphereCollider>(*skeleton[j]), player) == HIT) {
skeleton[i]->SetHitFlg(HIT);
skeleton[j]->SetHitFlg(HIT);
skeleton[i]->HitVectorCale(static_cast<SphereCollider>(*skeleton[j]), player);
skeleton[j]->HitVectorCale(static_cast<SphereCollider>(*skeleton[i]), player);
}
}
}
}
}
//魔法使いの当たり判定
for (int i = 0; i < MAX_WIZARD_NUM; i++) {
if (wizard[i] != nullptr) {
HitEnemy(wizard[i]);//プレイヤーとの当たり判定
for (int j = 0; j < MAX_WIZARD_NUM; j++) {
if (wizard[j] != nullptr && i != j) {
if (wizard[i]->CheckCollision(static_cast<SphereCollider>(*wizard[j]), player) == HIT) {
wizard[i]->SetHitFlg(HIT);
wizard[j]->SetHitFlg(HIT);
wizard[i]->HitVectorCale(static_cast<SphereCollider>(*wizard[j]), player);
wizard[j]->HitVectorCale(static_cast<SphereCollider>(*wizard[i]), player);
}
}
}
}
}