From 17a587ee6ded6d51c678fcd89bf0d28dc60db43d Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Wed, 8 Jan 2025 15:13:08 +0100 Subject: added boss fight, did not work --- game/scheduler/ObjectsScheduler.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'game/scheduler/ObjectsScheduler.cpp') diff --git a/game/scheduler/ObjectsScheduler.cpp b/game/scheduler/ObjectsScheduler.cpp index 21465e3..416a8da 100644 --- a/game/scheduler/ObjectsScheduler.cpp +++ b/game/scheduler/ObjectsScheduler.cpp @@ -5,6 +5,7 @@ #include "../Random.h" #include "../missile/SpawnEvent.h" #include "api/Transform.h" +#include "enemy/BattleScript.h" #include "prefab/ZapperPoolSubScene.h" #include @@ -14,7 +15,12 @@ void ObjectsScheduler::preset_1() { trigger_event(MissileSpaw void ObjectsScheduler::preset_2() { trigger_event(CreateZapperEvent {}); } void ObjectsScheduler::preset_3() {} void ObjectsScheduler::preset_4() {} -void ObjectsScheduler::boss_fight_1() { std::cout << "Boss fight" << std::endl; } +void ObjectsScheduler::boss_fight_1() { trigger_event(BattleStartEvent {}); } + +bool ObjectsScheduler::boss_fight_1_event() { + std::cout << "BATTLE WON" << std::endl; + return false; +} void ObjectsScheduler::init() { this->obstacles.push_back([this]() { preset_0(); }); @@ -24,6 +30,9 @@ void ObjectsScheduler::init() { this->obstacles.push_back([this]() { boss_fight_1(); }); // subscribe to battlewonevent + this->subscribe([this](const BattleWonEvent & ev) -> bool { + return this->boss_fight_1_event(); + }); } void ObjectsScheduler::fixed_update(duration_t dt) { @@ -32,7 +41,7 @@ void ObjectsScheduler::fixed_update(duration_t dt) { int boss_check = (pos_x - this->start_offset) / this->boss_fight_interval; if (boss_check > this->last_boss_check) { - this->obstacles[2](); + this->obstacles.back()(); this->last_boss_check = boss_check; } int obstacle_check = (pos_x - this->start_offset) / this->obstacle_interval; -- cgit v1.2.3