-
Notifications
You must be signed in to change notification settings - Fork 2
/
BossEnemyActor.cpp
199 lines (164 loc) · 4.46 KB
/
BossEnemyActor.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
//=====================================
//
//ボスエネミーアクター処理[BossEnemyActor.cpp]
//Author:GP12A332 21 立花雄太
//
//=====================================
#include "BossEnemyActor.h"
#include "Framework\AnimationManager.h"
#include "Framework\Easing.h"
#include "Framework\Vector3.h"
/**************************************
マクロ定義
***************************************/
/**************************************
コンストラクタ
***************************************/
BossEnemyActor::BossEnemyActor() :
writeableZ(true),
active(true)
{
animManager = new AnimationManager();
//モデルファイル読み込み
const char* ModelFileName = "data/MODEL/Boss.x";
animManager->LoadXFile(ModelFileName, "Boss");
//アニメーション読み込み
const char* AnimationSetName[] = {
"Flying", "Attack01", "Attack02", "Damage", "Death", "Idle", "LargeDamage"
};
for (UINT i = 0; i < AnimID::Max; i++)
{
animManager->LoadAnimation(AnimationSetName[i], i, 0.3f);
}
//アニメーションスピード設定
const float AnimationPlaySpeed[] = {
1.0f, 0.6f, 0.6f, 1.5f, 0.4f, 1.0f, 1.5f
};
for (UINT i = 0; i < AnimID::Max; i++)
{
animManager->SetPlaySpeed(i, AnimationPlaySpeed[i]);
}
//遷移関係設定
animManager->SetFinishTransition(AnimID::Attack01, AnimID::Idle);
animManager->SetFinishTransition(AnimID::Attack02, AnimID::Idle);
animManager->SetFinishTransition(AnimID::Damage, AnimID::Idle);
animManager->SetFinishTransition(AnimID::LargeDamage, AnimID::Idle);
//フラグ初期化
inMoving = false;
inRotaiton = false;
transform.scale = 50.0f * D3DXVECTOR3(1.0f, 1.0f, 1.0f);
}
/**************************************
デストラクタ
***************************************/
BossEnemyActor::~BossEnemyActor()
{
SAFE_DELETE(animManager);
}
/**************************************
更新処理
***************************************/
void BossEnemyActor::Update()
{
if (!active)
return;
_Move();
_Rotate();
animManager->Update();
}
/**************************************
描画処理
***************************************/
void BossEnemyActor::Draw()
{
if (!active)
return;
LPDIRECT3DDEVICE9 pDevice = GetDevice();
pDevice->SetRenderState(D3DRS_ZWRITEENABLE, writeableZ);
transform.SetWorld();
D3DXMATRIX world = transform.GetMatrix();
animManager->Draw(&world);
pDevice->SetRenderState(D3DRS_ZWRITEENABLE, true);
}
/**************************************
移動処理
***************************************/
void BossEnemyActor::Move(const D3DXVECTOR3& target, int duration)
{
if (inMoving)
return;
targetPos = target;
prevPos = transform.pos;
cntMove = 0;
durationMove = duration;
inMoving = true;
}
/**************************************
回転処理
***************************************/
void BossEnemyActor::Rotate(const D3DXVECTOR3& target, float magnitude)
{
if (inRotaiton)
return;
targetForward = target;
magnitudeRotate = magnitude;
inRotaiton = true;
}
/**************************************
アニメーション変更処理
***************************************/
void BossEnemyActor::ChangeAnimation(AnimID next)
{
animManager->ChangeAnim(next, true);
}
/**************************************
Zバッファ書き込み設定処理
***************************************/
void BossEnemyActor::SetWriteableZ(bool state)
{
writeableZ = state;
}
/**************************************
アクティブ設定処理
***************************************/
void BossEnemyActor::SetActive(bool state)
{
active = state;
}
/**************************************
座標取得処理
***************************************/
D3DXVECTOR3 BossEnemyActor::GetActorPosition()
{
D3DXVECTOR3 position;
D3DXMATRIX mtxBone;
animManager->GetBoneMatrix("Armature_mixamorig_Spine2", mtxBone);
D3DXVec3TransformCoord(&position, &transform.pos, &mtxBone);
return D3DXVECTOR3(mtxBone._41, mtxBone._42, mtxBone._43);
}
/**************************************
移動処理(内部)
***************************************/
void BossEnemyActor::_Move()
{
if (!inMoving)
return;
cntMove++;
float t = (float)cntMove / durationMove;
transform.pos = Easing::EaseValue(t, prevPos, targetPos, EaseType::OutBack);
if (cntMove == durationMove)
inMoving = false;
}
/**************************************
回転処理(内部)
***************************************/
void BossEnemyActor::_Rotate()
{
if (!inRotaiton)
return;
float angle = Vector3::Angle(transform.Forward(), targetForward);
D3DXVECTOR3 axis = Vector3::Axis(transform.Forward(), targetForward);
transform.RotateByAxis(angle * magnitudeRotate, axis);
if (angle < 0.01f)
inRotaiton = false;
}