-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStageManager.cpp
57 lines (52 loc) · 984 Bytes
/
StageManager.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
#include "StageManager.h"
// 更新処理
void StageManager::Update(float elapsedTime)
{
for (Stage* stage : stages)
{
stage->Update(elapsedTime);
}
}
// 描画処理
void StageManager::Render(ID3D11DeviceContext* context, Shader* shader)
{
for (Stage* stage : stages)
{
stage->Render(context, shader);
}
}
// ステージを登録
void StageManager::Register(Stage* stage)
{
stages.emplace_back(stage);
}
// ステージを全削除
void StageManager::Clear()
{
for (Stage* stage : stages)
{
delete stage;
}
stages.clear();
}
// レイキャスト
bool StageManager::RayCast(const DirectX::XMFLOAT3& start, const DirectX::XMFLOAT3& end, HitResult& hit)
{
bool result = false;
hit.distance = FLT_MAX;
for (Stage* stage : stages)
{
HitResult temp;
if (stage->RayCast(start, end, temp))
{
// レイキャストが当たっているとき
if (hit.distance > temp.distance)
{
// temp.distanceの方が距離が短いとき
hit = temp;
result = true;
}
}
}
return result;
}