-
Notifications
You must be signed in to change notification settings - Fork 2
/
BossColliderController.cpp
164 lines (138 loc) · 3.97 KB
/
BossColliderController.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
//=====================================
//
//ボスコライダーコントローラ処理[BossColliderController.cpp]
//Author:GP12A332 21 立花雄太
//
//=====================================
#include "BossColliderController.h"
#include "Framework\ResourceManager.h"
#include "BossColliderGuide.h"
#include "BossEnemyModel.h"
#include "GameParticleManager.h"
using namespace std;
/**************************************
マクロ定義
***************************************/
/**************************************
コンストラクタ
***************************************/
BossColliderController::BossColliderController(BossEnemyModel& model) : posZ(500.0f), model(model)
{
//ポリゴン準備
ResourceManager::Instance()->MakePolygon("BossColliderEdge", "data/TEXTURE/Enemy/BossColliderEdge.png", D3DXVECTOR2(40.0f, 40.0f));
ResourceManager::Instance()->MakePolygon("BossColliderLine", "data/TEXTURE/Enemy/BossCollider.png", D3DXVECTOR2(0.5f, 20.0f));
}
/**************************************
デストラクタ
***************************************/
BossColliderController::~BossColliderController()
{
for (auto&& guide : guideMap)
{
SAFE_DELETE(guide.second);
}
guideMap.clear();
for (auto&& collider : colliderList)
{
SAFE_DELETE(collider);
}
colliderList.clear();
}
/**************************************
更新処理
***************************************/
void BossColliderController::Update()
{
for (auto&& guide : guideMap)
{
guide.second->Update();
}
}
/**************************************
描画処理
***************************************/
void BossColliderController::Draw()
{
LPDIRECT3DDEVICE9 pDevice = GetDevice();
pDevice->SetRenderState(D3DRS_ZWRITEENABLE, false);
pDevice->SetRenderState(D3DRS_ZENABLE, false);
pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
pDevice->SetRenderState(D3DRS_LIGHTING, false);
pDevice->SetRenderState(D3DRS_CULLMODE, false);
for (auto&& guide : guideMap)
{
guide.second->Draw();
}
pDevice->SetRenderState(D3DRS_ZWRITEENABLE, true);
pDevice->SetRenderState(D3DRS_ZENABLE, true);
pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
pDevice->SetRenderState(D3DRS_LIGHTING, true);
pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
}
/**************************************
セット処理
***************************************/
void BossColliderController::SetCollider(const std::vector<int>& edgeList)
{
DeleteAll();
const UINT EdgeMax = edgeList.size() - 1;
for (UINT i = 0; i < EdgeMax; i++)
{
int left = Min(edgeList[i], edgeList[i + 1]);
int right = Max(edgeList[i], edgeList[i + 1]);
LineTrailModel model = LineTrailModel(left, right);
TrailCollider *collider = new TrailCollider(TrailColliderTag::Enemy);
collider->SetTrailIndex(model);
collider->SetAddressZ(&posZ);
collider->AddObserver(this);
guideMap[collider] = new BossColliderGuide(model);
modelMap[collider] = model;
colliderList.push_back(collider);
}
cntHit = 0;
}
/**************************************
全消去処理
***************************************/
void BossColliderController::DeleteAll()
{
for (auto&& pair : guideMap)
{
SAFE_DELETE(pair.second);
}
guideMap.clear();
for (auto&& collider : colliderList)
{
SAFE_DELETE(collider);
}
colliderList.clear();
}
/**************************************
当たり判定通知処理
***************************************/
void BossColliderController::OnNotified(ObserveSubject* notifier)
{
model.OnDamage();
LineTrailModel model = modelMap[notifier];
D3DXVECTOR3 right, left;
model.GetEdgePos(&right, &left);
right.z = left.z = posZ;
D3DXVECTOR3 offset = right - left;
offset /= 10.0f;
for (int i = 0; i < 10; i++)
{
GameParticleManager::Instance()->SetBossHit(&(left + offset));
left += offset;
}
modelMap.erase(notifier);
SAFE_DELETE(guideMap[notifier]);
guideMap.erase(notifier);
auto itr = std::find(colliderList.begin(), colliderList.end(), notifier);
(*itr)->active = false;
//
cntHit++;
if (cntHit == colliderList.size())
{
this->model.ChangeState(BossEnemyModel::State::LargeDamage);
}
}