-
Notifications
You must be signed in to change notification settings - Fork 2
/
EnemyBulletController.cpp
140 lines (122 loc) · 3.33 KB
/
EnemyBulletController.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
//=====================================
//
//テンプレート処理[EnemyBulletController.cpp]
//Author:GP12A332 21 立花雄太
//
//=====================================
#include "EnemyBulletController.h"
#include "EnemyBulletModel.h"
#include "EnemyBullet.h"
#include "Framework\ResourceManager.h"
#include <algorithm>
using namespace std;
/**************************************
マクロ定義
***************************************/
#define ENEMYBULLET_NUM_MAX (128)
#define ENEMYBULLET_VTX_SIZE (D3DXVECTOR2(10.0f, 10.0f))
#define ENEMYBULLET_TEX_NAME ("data/TEXTURE/Enemy/EnemyBullet.png")
/**************************************
コンストラクタ
***************************************/
EnemyBulletController::EnemyBulletController()
{
//リソース作成
ResourceManager::Instance()->MakePolygon(RESOURCE_ENEMYBULLET_TAG, ENEMYBULLET_TEX_NAME, ENEMYBULLET_VTX_SIZE);
}
/**************************************
デストラクタ
***************************************/
EnemyBulletController::~EnemyBulletController()
{
for (auto& bullet : modelContainer)
{
SAFE_DELETE(bullet);
}
modelContainer.clear();
}
/**************************************
終了処理
***************************************/
void EnemyBulletController::Uninit()
{
for (auto& model : modelContainer)
{
model->Uninit();
}
}
/**************************************
更新処理
***************************************/
void EnemyBulletController::Update()
{
for (auto& model : modelContainer)
{
model->Update();
}
}
/**************************************
描画処理
***************************************/
void EnemyBulletController::Draw()
{
LPDIRECT3DDEVICE9 pDevice = GetDevice();
pDevice->SetRenderState(D3DRS_LIGHTING, false);
pDevice->SetRenderState(D3DRS_ALPHATESTENABLE, true);
pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
pDevice->SetRenderState(D3DRS_ZWRITEENABLE, false);
for (auto& model : modelContainer)
{
model->Draw();
}
pDevice->SetRenderState(D3DRS_LIGHTING, true);
pDevice->SetRenderState(D3DRS_ALPHATESTENABLE, false);
pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
pDevice->SetRenderState(D3DRS_ZWRITEENABLE, true);
}
/**************************************
セット処理
***************************************/
void EnemyBulletController::Set(vector<D3DXVECTOR3> emitters, LineTrailModel target)
{
auto itr = find_if(modelContainer.begin(), modelContainer.end(),
[](EnemyBulletModel* model)
{
return !model->active;
});
if (itr == modelContainer.end())
{
modelContainer.push_back(new EnemyBulletModel());
itr = modelContainer.end() - 1;
}
(*itr)->Init(emitters, target);
}
/**************************************
非アクティブ処理
***************************************/
void EnemyBulletController::DisableAll()
{
for (auto& model : modelContainer)
{
if (!model->active)
continue;
model->Disable();
}
}
/**************************************
非アクティブ処理
***************************************/
void EnemyBulletController::Set(vector<D3DXVECTOR3> emitters, LineTrailModel target, int duration, const D3DXVECTOR3 scale)
{
auto itr = find_if(modelContainer.begin(), modelContainer.end(),
[](EnemyBulletModel* model)
{
return !model->active;
});
if (itr == modelContainer.end())
{
modelContainer.push_back(new EnemyBulletModel());
itr = modelContainer.end() - 1;
}
(*itr)->Init(emitters, target, duration, scale);
}