-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameListener.cpp
More file actions
36 lines (30 loc) · 767 Bytes
/
GameListener.cpp
File metadata and controls
36 lines (30 loc) · 767 Bytes
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
#include "GameListener.h"
#include "Game.h"
int GameListener::msID = 0;
GameListener::GameListener()
{
mID = msID;
msID++;
// Add this listener to each game event in the Event System
gpEventSystem->addListener(INVADER_HIT_WALL, this);
gpEventSystem->addListener(INVADER_HIT_PLAYER, this);
gpEventSystem->addListener(PLAYERS_DEAD, this);
}
GameListener::~GameListener()
{
}
void GameListener::handleEvent(const Event &theEvent)
{
switch (theEvent.getType())
{
case INVADER_HIT_WALL:
Game::getInstance()->getEnemyManager()->setMustSwitchDirections(true);
break;
case INVADER_HIT_PLAYER:
Game::getInstance()->getEnemyManager()->resetPositions();
break;
case PLAYERS_DEAD:
Game::getInstance()->getEnemyManager()->resetPositions();
break;
}
}