forked from YutaTachibana0310/SankouGoudou2019Summer
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnemyBulletTrailController.cpp
76 lines (67 loc) · 2.31 KB
/
EnemyBulletTrailController.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
//=====================================
//
//エネミーバレットトレイルコントローラ処理[EnemyBulletTrailController.cpp]
//Author:GP12A332 21 立花雄太
//
//=====================================
#include "EnemyBulletTrailController.h"
#include "EnemyBulletTrail.h"
/**************************************
マクロ定義
***************************************/
#define ENEMYBULLETTRAIL_TEX_NAME "data/TEXTURE/Effect/EnemyBulletTrail.png"
#define ENEMYBULLETTRAIL_NUM_MAX (1024)
#define ENEMYBULLETTRAIL_EMITTER_MAX (32)
#define ENEMYBULLETTRAIL_EMIT_NUM (5)
typedef BaseParticleController Base;
/**************************************
初期化処理
***************************************/
void EnemyBulletTrailController::Init()
{
D3DXVECTOR2 ENEMYBULLETTRAIL_SIZE = D3DXVECTOR2(10.0f, 10.0f);
D3DXVECTOR2 ENEMYBULLETTRAIL_TEX_DIV = D3DXVECTOR2(8.0f, 8.0f);
//頂点バッファ設定、テクスチャ読み込み
Base::MakeUnitBuffer(&ENEMYBULLETTRAIL_SIZE, &ENEMYBULLETTRAIL_TEX_DIV);
Base::LoadTexture(ENEMYBULLETTRAIL_TEX_NAME);
//パーティクルコンテナ作成
particleContainer.resize(ENEMYBULLETTRAIL_NUM_MAX);
for (auto& particle : particleContainer)
{
particle = new EnemyBulletTrail();
static_cast<AnimationParticle*>(particle)->SetAnimParameter(&ENEMYBULLETTRAIL_TEX_DIV);
}
//エミッターコンテナ作成
emitterContainer.resize(ENEMYBULLETTRAIL_EMITTER_MAX);
for(auto& emitter : emitterContainer)
{
emitter = new EnemyBulletTrailEmitter();
}
}
/**************************************
放出処理
***************************************/
void EnemyBulletTrailController::Emit()
{
//放出
Base::ForEachEmitter(ENEMYBULLETTRAIL_EMIT_NUM, [](BaseEmitter *emitter, BaseParticle *particle)
{
//座標設定
particle->transform.pos = emitter->transform.pos;
//移動方向設定
EnemyBulletTrail *entityParticle = static_cast<EnemyBulletTrail*>(particle);
EnemyBulletTrailEmitter *entityEmitter = static_cast<EnemyBulletTrailEmitter*>(emitter);
entityParticle->moveDir = entityEmitter->prevPos - entityEmitter->transform.pos;
D3DXVec3Normalize(&entityParticle->moveDir, &entityParticle->moveDir);
//初期化
particle->Init();
});
//現在位置を保存
for (auto& emitter : emitterContainer)
{
if (!emitter->active)
continue;
EnemyBulletTrailEmitter *entity = static_cast<EnemyBulletTrailEmitter*>(emitter);
entity->prevPos = entity->transform.pos;
}
}