-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMinotaur.cpp
461 lines (373 loc) · 10.1 KB
/
Minotaur.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
#include "Minotaur.h"
#include"main.h"
//#define DEBUG
//#define BTN_DEBUG
Minotaur::Minotaur()
{
debugCnt = 0;
//画像読込
minotaurImg[MINOTAUR_IMG_STATE_NOROAR] = LoadGraph("resources/images/enemy_images/minotaur/minotaur_syoumen.png");
minotaurImg[MINOTAUR_IMG_STATE_TACKLE_RIGHT] = LoadGraph("resources/images/enemy_images/minotaur/minotaur_right_move.png");
minotaurImg[MINOTAUR_IMG_STATE_TACKLE_LEFT] = LoadGraph("resources/images/enemy_images/minotaur/minotaur_left_move.png");
minotaurImg[MINOTAUR_IMG_STATE_ROAR] = LoadGraph("resources/images/enemy_images/minotaur/minotaur_houkou.png");
img = minotaurImg[MINOTAUR_IMG_STATE_NOROAR];
hp = MINOTAUR_MAX_HP;
damage = MINOTAUR_ATTAK_DAMAGE;
location.x = _SCREEN_WIDHT_ / 2;
location.y = 60;
tackleTmpL.x = 0;
tackleTmpL.y = 0;
vector.x = 0;
vector.y = 0;
radius = 50;
respawnFlg = true;
tackleFlg = false;
doOneFlg = false;
coolTimeFlg = false;
tackleCoolTimeCnt = 0;
tackleCoolTime = SECOND_FRAME(1.3);
tackleSpeed = TACKLE_SPEED;
nowTackleCnt = 0;
tackleCnt = 0;
roarStartFlg = false;
//-----タックル-----//
//薄い赤色の矩形
boxX_a = 0;
boxY_a = 0;
boxX_d = 0;
boxY_d = 0;
//濃い赤色の矩形
lineSize = 1;
lineSizeChageCnt = 0;
//-----咆哮-----//
roarCnt = 0;
roarFlg = false;
roarRadius = 0;
roarFinFlg = false;
playerRoarHitFlg = false;
//エフェクト
for (int i = 0; i < ROAR_EFFECT_CIRCLE_NUM; i++) {
roarEffectRadius[i] = 0;
roarEffectDrawFlg[i] = false;
}
//-----その他-----//
}
Minotaur::~Minotaur()
{
DeleteGraph(img);
for (int i = 0; i <= 4; i++) {
DeleteGraph(minotaurImg[i]);
}
}
void Minotaur::Update(Player* player)
{
//プレイヤーの移動量をdiffにセット
SetPlayerAmountOfTravel_X(player->Player_MoveX());
SetPlayerAmountOfTravel_Y(player->Player_MoveY());
//プレイヤーの座標をdiffLocationにセット
SetPlayer_Location(player->GetLocation());
img = minotaurImg[MINOTAUR_IMG_STATE_NOROAR];
if (roarStartFlg == false) {
TackleUpdate();//タックル
//咆哮エフェクトの初期化
for (int i = 0; i < ROAR_EFFECT_CIRCLE_NUM; i++) {
roarEffectRadius[i] = 0;
roarEffectDrawFlg[i] = false;
}
roarEffectCircleNum = -1;
nextCircleCoolTimeCounter = 0;
roarEffectCircleCreateFlg = false;
}
else if (roarStartFlg == true) {
RoarUpdate();//咆哮
if (roarEffectFlg == true) {
RoarEffectUpdate();
if (roarEndedFrame > 0) img = minotaurImg[MINOTAUR_IMG_STATE_ROAR];
}
}
else if (roarStartFlg == false) {
img = minotaurImg[MINOTAUR_IMG_STATE_ROAR];
};
//移動処理
if (tackleFlg == false) {
location.x = location.x - diff.x;
location.y = location.y - diff.y;
}
else if (tackleFlg == true) {//タックル中
location.x += vector.x * TACKLE_SPEED - diff.x;
location.y += vector.y * TACKLE_SPEED - diff.y;
// 画像切り替え
if (vector.x < 0.0f) img = minotaurImg[MINOTAUR_IMG_STATE_TACKLE_LEFT];
if (vector.x > 0.0f) img = minotaurImg[MINOTAUR_IMG_STATE_TACKLE_RIGHT];
if (vector.x == 0.0f) img = minotaurImg[MINOTAUR_IMG_STATE_NOROAR];
}
//武器からの攻撃とHPが0以上なら赤く表示する
if (hitWeaponFlg == true && hp > 0) {
redDrawFlg = true;
}
hitWeaponFlg = false;
if (hp <= 0) {
respawnFlg = false;
}
if (redFrameCounter == RED_FRAME) {
redDrawFlg = false;
redFrameCounter = 0;
}
if (redDrawFlg == true) {
redFrameCounter++;
}
#ifdef BTN_DEBUG
if (InputCtrl::GetKeyState(KEY_INPUT_D) == PRESS && hp >= 0) {
hitWeaponFlg = true;
hp -= 9999;
}
else {
hitWeaponFlg = false;
}
#endif // BTN_DEBUG
}
void Minotaur::Draw() const
{
DrawRotaGraph((int)location.x, (int)location.y, 1, 0, img, TRUE);
if (redDrawFlg == true) {
SetDrawBright(255, 0, 0);
DrawRotaGraph((int)location.x, (int)location.y, 1, 0, img, TRUE);
SetDrawBright(255, 255, 255);
}
if (coolTimeFlg == false && tackleFlg == false) {
TackleDraw();
}
if (roarStartFlg == true) {
if (roarEndedFrame <= 0) RoarDraw();
if (roarEndedFrame > 0) {
RoarEffectDraw();
}
}
#ifdef DEBUG
DrawFormatString(300, 560, C_RED, "%d", tackleCnt);
DrawCircle(location.x, location.y, radius, C_RED, FALSE, 1);
DrawFormatString(300, 500, C_GREEN, "HP:%.2f", hp);
DrawLine(location.x, location.y, location.x, location.y - boxY_a, C_GREEN, 5);//縦
DrawLine(location.x, location.y, location.x - boxX_a, location.y, C_BLUE, 5);//横
DrawLine(location.x, location.y, location.x - boxX_a, location.y - boxY_a, C_RED, 10);
#endif // DEBUG
}
void Minotaur::TackleUpdate()
{
pLength = PlayerLoad(location, false);
if (coolTimeFlg == false && tackleFlg == false) {
boxX_a = location.x - dL.x;
boxY_a = location.y - dL.y;
//長さを一定にする
boxX_d = fabsf(BOX_MAX_LENGTH / PlayerLoad(location, false));
boxX_a *= boxX_d;
boxY_d = fabsf(BOX_MAX_LENGTH / PlayerLoad(location, false));
boxY_a *= boxY_d;
}
if (coolTimeFlg == false) {
//濃い赤色の矩形の太さ//
if (lineSize <= BOX_MAX_WIDTH) {//太さが最大の太さじゃないなら
lineSizeChageCnt += 3;
}
else if (lineSize >= BOX_MAX_WIDTH) {//太さが最大の太さなら
lineSize = 0;
tackleFlg = true;
}
if (lineSizeChageCnt >= tackleSpeed) {
lineSize++;
lineSizeChageCnt = 0;
}
}
//タックル開始
if (tackleFlg == true) {
if (doOneFlg == false) {
SoundManager::PlaySoundSE("se_enemy_tackle");
//タックルした時に最終的に移動する場所
tackleTmpL.x = location.x - boxX_a;
tackleTmpL.y = location.y - boxY_a;
//タックル中の移動量をセット
vector.x = Normalization_X(M_PLX(location.x), M_PLY(location.y));
vector.y = Normalization_Y(M_PLX(location.x), M_PLY(location.y));
doOneFlg = true;
}
nowTackleCnt++;
//タックルの最終地点移動
if (nowTackleCnt >= BOX_MAX_LENGTH / TACKLE_SPEED) {
tackleFlg = false;
coolTimeFlg = true;
doOneFlg = false;
nowTackleCnt = 0;
tackleCnt++;
lineSize = 0;
}
}
//咆哮が当たったなら
if (playerRoarHitFlg == true) {
tackleCoolTime = 0;
}
else {
tackleCoolTime = SECOND_FRAME(1.3);
}
//タックルのクールタイム
if (coolTimeFlg == true && tackleFlg == false) {
tackleCoolTimeCnt++;
}
else if (coolTimeFlg == false) {
tackleCoolTimeCnt = 0;
}
if (tackleCoolTimeCnt >= tackleCoolTime) {
coolTimeFlg = false;
}
if (tackleCnt >= 3) {
roarStartFlg = true;
}
}
void Minotaur::TackleDraw() const
{
//薄い赤色の矩形
SetDrawBlendMode(DX_BLENDMODE_ALPHA, 70);
DrawLine(location.x, location.y, location.x - boxX_a, location.y - boxY_a, C_RED, BOX_MAX_WIDTH);
//SetDrawBlendMode(DX_BLENDMODE_ALPHA, 255);
//濃い赤色の矩形
SetDrawBlendMode(DX_BLENDMODE_ALPHA, 150);
DrawLine(location.x, location.y, location.x - boxX_a, location.y - boxY_a, C_RED, lineSize);
SetDrawBlendMode(DX_BLENDMODE_ALPHA, 255);
}
void Minotaur::TackleEffectUpdate()
{
}
void Minotaur::TackleEffectDraw() const
{
}
float Minotaur::M_PLX(float location_X)
{
float r = dL.x - location.x;
return r;
}
float Minotaur::M_PLY(float location_Y)
{
float r = dL.y - location.y;
return r;
}
void Minotaur::RoarUpdate()
{
if (roarEndedFrame <= 0) {
roarFlg = true;
if (roarRadius <= ROAR_RADIUS) {
roarRadius += 2;
}
else if (roarRadius >= ROAR_RADIUS) {
roarEffectFlg = true;
}
if (roarEffectFinFlg == true) {
roarFinFlg = true;
}
};
if (roarFinFlg == true) {
if (roarEndedFrame <= 0) {
SoundManager::PlaySoundSE("se_enemy_shout");
roarRadius = 0;
roarEndedFrame = 60;
}
else {
if (roarEndedFrame == 1) {
roarFlg = false;
roarStartFlg = false;
tackleCnt = 0;
roarFinFlg = false;
roarEffectFinFlg = false;
roarEffectFlg = false;
};
roarEndedFrame--;
};
}
}
void Minotaur::RoarDraw() const
{
SetDrawBlendMode(DX_BLENDMODE_ALPHA, 50);
DrawCircle(location.x, location.y, ROAR_RADIUS, C_RED, TRUE);
SetDrawBlendMode(DX_BLENDMODE_ALPHA, 70);
DrawCircle(location.x, location.y, roarRadius, C_RED, TRUE);
SetDrawBlendMode(DX_BLENDMODE_ALPHA, 255);
}
void Minotaur::RoarHit()
{
}
void Minotaur::RoarEffectUpdate()
{
//プレイヤーとの当たり判定
float a = location.x - dL.x;
float b = location.y - dL.y;
float c = sqrtf(pow(a, 2) + pow(b, 2));
if (c <= ROAR_RADIUS + PLAYER_RADIUS) {//当たった
playerRoarHitFlg = true;
}
else {
playerRoarHitFlg = false;
}
roarEffectFinFlg = true;
//・・・・・エフェクトの処理・・・・・//
//円の生成
if (nextCircleCoolTimeCounter == 0) {
roarEffectCircleCreateFlg = true;
nextCircleCoolTimeCounter++;
roarEffectCircleNum++;
}
else {
roarEffectCircleCreateFlg = false;
nextCircleCoolTimeCounter++;
if (nextCircleCoolTimeCounter >= ROAR_EFFECT_NEXT_CIRCLE_TIEM) {
nextCircleCoolTimeCounter = 0;
}
}
if (roarEffectCircleCreateFlg == true) {//DrawFlgをTrueにする
roarEffectLocation[roarEffectCircleNum].x = location.x - diff.x;
roarEffectLocation[roarEffectCircleNum].y = location.y - diff.y;
roarEffectDrawFlg[roarEffectCircleNum] = true;
}
//円の半径&下に少し移動する処理
for (int i = 0; i < 10; i++) {
if (roarEffectDrawFlg[i] == true) {
roarEffectLocation[i].x = location.x;
roarEffectLocation[i].y = location.y;
roarEffectRadius[i] += ROAR_EFFECT_SPPED;
if (roarEffectRadius[i] >= ROAR_RADIUS) {
roarEffectRadius[i] = ROAR_RADIUS;
}
//ここにy軸を少し下にずらす処理を書く
}
roarEffectLocation[roarEffectCircleNum].x = location.x;
roarEffectLocation[roarEffectCircleNum].y = location.y;
}
}
void Minotaur::RoarEffectDraw() const
{
for (int i = 0; i < ROAR_EFFECT_CIRCLE_NUM; i++) {
if (roarEffectDrawFlg[i] == true) {
DrawCircle(roarEffectLocation[i].x, roarEffectLocation[i].y, roarEffectRadius[i], C_RED, FALSE,2);
}
}
}
bool Minotaur::GetRoarHitFlg()
{
//プレイヤーの瞬間移動で使うFlg制御
if (playerRoarHitFlg == true) {
playerRoarHitCounter++;
if (playerRoarHitCounter >= SECOND_FRAME(6)) {
playerRoarHitFlg = false;
playerRoarHitCounter = 0;
}
}
//プレイヤーにFlgを返す
return playerRoarHitFlg;
}
void Minotaur::DeathEffectUpdate()
{
}
void Minotaur::DeathEffectDraw() const
{
}
float Minotaur::GetHP()
{
return hp;
}