-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNPC.cpp
87 lines (70 loc) · 1.42 KB
/
NPC.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
#include "NPC.h"
NPC::NPC(ModelEnum curr)
{
model = curr;
translate = new glm::vec2(0.f, 0.f);
rotation = glm::mat4(1);
// Change to AABB later
collider_ = new ColliderCircle(glm::vec2(0, 3.f), 8, false);
collider_->collider_is_trigger = true;
}
NPC::~NPC()
{
delete translate;
delete collider_;
}
void NPC::FixedUpdate()
{
//collider_->center = *translate;
}
glm::mat4 NPC::GetParentTransform()
{
const glm::mat4 trans = glm::translate(glm::vec3((*translate)[0], 0, -(*translate)[1])) * rotation;
return trans * rotation;
}
ModelEnum NPC::GetModelEnum()
{
return model;
}
AniMode NPC::GetAniMode()
{
return modelAnim;
}
std::vector<Collider*> NPC::GetColliders()
{
return { collider_ };
}
glm::vec2* NPC::GetWorldPosition()
{
return translate;
}
glm::vec3 NPC::GetPosition() const
{
return glm::vec3((*translate)[0], 0, -(*translate)[1]);
}
void NPC::SetWorldPosition(glm::vec3 position)
{
*translate = glm::vec2(position[0], -position[2]);
//*translate3D = glm::vec3(position[0], position[1], -position[2]);
}
bool NPC::CanInteract(Player* player)
{
//TODO: if bribed return false
return true;
}
void NPC::OnInteract(Player* player)
{
if (player->GetIsHolding()) {
// TODO: instead of calling sell directly, open sell GUI instead
player->OpenSaleUI();
//player->Sell();
}
else {
// Enable Shop UI and disable movement
player->OpenUI();
}
}
glm::mat4 NPC::GetRotation()
{
return glm::mat4();
}