3#include "../gameplay/event.h"
4#include "../gameplay/player.h"
5#include "../gameplay/stateMachine.h"
7#include "../rendering/hud.h"
9#include "../utils/log.h"
10#include "../utils/ai.h"
43 BoidEvent(
const std::string& eventType,
int numBoids) :
Event(eventType), numBoids(numBoids) {}
53 if (eventInstance.
type ==
"dispatchBoids") {
54 auto const& boidEvent =
static_cast<BoidEvent const&
>(eventInstance);
55 if (boidManager) boidManager->
addBoids(boidEvent.numBoids);
83 if (eventInstance.
type ==
"playerDied" && isAlive) {
90 AIRE_ERROR(
"Player died.");
92 GameOverEvent::deathText->
active =
true;
95 GameOverEvent::deathSound->
play();
98 rb->position = glm::vec3(0.f);
101 }
else if (eventInstance.
type ==
"gameOver") {
103 AIRE_WARN(
"Game over.");
106 GameOverEvent::winText->
active =
true;
109 GameOverEvent::winSound->
play();
112 }
else if (eventInstance.
type ==
"collision") {
114 auto const& collision =
static_cast<CollisionEvent const&
>(eventInstance);
115 health -= collision.collisionDamage;
120 float health = 100.0f;
132 if (eventInstance.
type ==
"startChasing") {
136 }
else if (eventInstance.
type ==
"stopChasing") {
150 if (!boidMan)
return;
151 if (name ==
"chasing") {
154 else if (name ==
"peaceful") {
AudioSource class to play sound effects.
Definition audioSource.h:17
void play()
Plays the audio.
Definition audioSource.cpp:43
Manager for the boids.
Definition ai.h:159
void setTrackPlayer(bool trackPlayer)
Make the boids track the player.
Definition ai.h:211
void addBoids(int numBoids)
Add a nmber of new boids.
Definition ai.cpp:174
Rigidbody * rb
Rigid body handles physics.
Definition player.h:26
Config config
Config attached to the player.
Definition player.h:24
virtual void onEvent(const Aire::Event &eventInstance) override
Definition myEvent.h:52
virtual void onEvent(const Aire::Event &eventInstance) override
Definition myEvent.h:82
std::string type
Type of the event. Serves as event identifier. Case sensitive.
Definition event.h:14
static void registerForEvent(GameObject *obj, std::string eventType)
Definition event.h:53
static void dispatchEvent(const Event &eventInstance)
Definition event.h:139
Class to display text on the screen.
Definition hud.h:47
bool active
Flag to indicate if currently active.
Definition hud.h:50
Definition stateMachine.h:9
A state machine that controls transition between states.
Definition stateMachine.h:37
State * currentState
The current state that the state machine is in.
Definition stateMachine.h:38
void transitionTo(std::string dstState)
Definition stateMachine.h:46
virtual void onActive() override
Definition myEvent.h:149
virtual void onEvent(const Aire::Event &eventInstance) override
Definition myEvent.h:131
float collisionDamage
The amount of damage the collision will do.
Definition myEvent.h:24