-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRoom.h
68 lines (58 loc) · 1.52 KB
/
Room.h
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
#ifndef ROOM_H
#define ROOM_H
#include <vector>
#include "Entity.h"
#include "ModuleCollision.h"
#include "JsonHandler.h"
#include "Point.h"
#include "Creature.h"
class Room : public Entity
{
public:
Room(SDL_Texture* texture, const char* name, ModuleStages* stage) : Entity(Entity::Type::ROOM, texture, stage)
{
if (App->parser->LoadObject(name))
{
iPoint back_position = { 0,0 };
App->parser->GetRect(entity_rect, "Rectangle");
App->parser->GetPoint(back_position, "Position");
has_transition = App->parser->GetBool("HasTransition");
if (has_transition)
{
Point3d collider_pos;
Point3d collider_dimensions;
App->parser->GetPoint3D(collider_pos, "TransitionColliderPosition");
App->parser->GetPoint3D(collider_dimensions, "TransitionColliderDimensions");
collider = App->collision->AddCollider(collider_pos, collider_dimensions, ColliderType::ACTIVATION, this);
collider->active = false;
}
if (App->parser->UnloadObject())
{
position.x = back_position.x;
position.y = back_position.y;
position.z = -1;
dimensions.x = entity_rect.w;
dimensions.y = entity_rect.h;
}
}
}
~Room() {}
int GetNumberOfEnemies() const
{
int ret = 0;
for (std::list<Entity*>::const_iterator it = contains.begin(); it != contains.end(); ++it)
{
if ((*it)->type == Entity::ENEMY)
++ret;
}
return ret;
}
void HasCollided(Collider* with)
{
if (stage->transition == false)
stage->transition = true;
}
public:
bool has_transition = false;
};
#endif // !ROOM_H