-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameManager.cpp
69 lines (58 loc) · 1.09 KB
/
GameManager.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
#include "GameManager.h"
GameManager::GameManager(ActorManager *a, TerrainManager *t)
{
aM = a;
tM = t;
activeTeam = 0;
maxPlayers = 2;
teamToggleFlag = false;
toggleActiveTeam(true); //Start first turn
}
void GameManager::update()
{
toggleActiveTeam(keys['T']);
aM->updateActorLOS(activeTeam);
}
void GameManager::toggleActiveTeam(bool teamToggle)
{
if(teamToggle && !teamToggleFlag)
{
teamToggleFlag = true;
activeTeam++;
if(activeTeam > maxPlayers)
activeTeam = 1;
clearCurrentSelection();
startTurn();
}
if(!teamToggle)
teamToggleFlag = false;
}
int GameManager::getActiveTeam()
{
return activeTeam;
}
void GameManager::startTurn()
{
//Reload all the tanks for the team that is now active
ActorManager::ActorList * target = aM->root;
while(target != NULL)
{
Actor *a = target->actor;
if(a->getTeam() == activeTeam)
{
a->reloadClip();
a->resetMovePoints();
}
target = target->next;
}
}
bool GameManager::isSelectable(Actor *a)
{
if(a->isVisible() && a->getTeam() == activeTeam)
return true;
else
return false;
}
GameManager::~GameManager(void)
{
}