-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathC_MovementAnimation.cpp
44 lines (38 loc) · 1.15 KB
/
C_MovementAnimation.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
#include "C_MovementAnimation.hpp"
#include "Object.hpp"
C_MovementAnimation::C_MovementAnimation(Object* owner) : Component(owner) { }
void C_MovementAnimation::Awake()
{
velocity = owner->GetComponent<C_Velocity>();
animation = owner->GetComponent<C_Animation>();
}
void C_MovementAnimation::Update(float deltaTime)
{
if (!owner->IsDead()) // dead - no need to update anything!
{
if (animation->GetAnimationState() != AnimationState::Projectile && animation->GetAnimationState() != AnimationState::Slash ) // && animation->GetAnimationState() != AnimationState::Thrust)
{
const sf::Vector2f& currentVel = velocity->Get();
if (currentVel.x != 0.f || currentVel.y != 0.f)
{
if (animation->GetAnimationState() == AnimationState::Thrust && animation->IsFinished())
{
animation->SetAnimationState(AnimationState::Walk);
}
else
animation->SetAnimationState(AnimationState::Walk);
}
else
{
if (animation->GetAnimationState() == AnimationState::Thrust && !animation->IsFinished())
{
//do nothing still in animation
}
else
{
animation->SetAnimationState(AnimationState::Idle);
}
}
}
}
}