-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystem_points.cpp
32 lines (27 loc) · 1.02 KB
/
system_points.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
#include "system_points.h"
#include "component_point.h"
#include "component_sprite.h"
#include "engine.h"
#include "entity.h"
#include "tags.h"
void SystemPoints::Update()
{
// TODO: Set the correct sprites of all entities with point component
EntityStream* es = engine->GetEntityStream();
Context* cont = engine->GetContext();
ComponentPoint* cpoint;
ComponentSprite* cspr;
set<Entity*> entities_point = es->WithTag(Component::POINT);
set<Entity*>::iterator itr;
for(itr = entities_point.begin(); itr != entities_point.end(); itr++){
cspr = dynamic_cast<ComponentSprite*>((*itr)->GetComponent(Component::SPRITE));
cpoint = dynamic_cast<ComponentPoint*>((*itr)->GetComponent(Component::POINT));
if(cpoint->point_id <= cont->GetPoints(1) && cpoint->player_id == 1){
cspr->sprite = Graphics::SPRITE_POINT_P1;
}else if(cpoint->point_id <= cont->GetPoints(2) && cpoint->player_id == 2){
cspr->sprite = Graphics::SPRITE_POINT_P2;
}else{
cspr->sprite = Graphics::SPRITE_POINT;
}
}
}