aboutsummaryrefslogtreecommitdiff
path: root/game/scheduler/ObjectsScheduler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'game/scheduler/ObjectsScheduler.cpp')
-rw-r--r--game/scheduler/ObjectsScheduler.cpp57
1 files changed, 40 insertions, 17 deletions
diff --git a/game/scheduler/ObjectsScheduler.cpp b/game/scheduler/ObjectsScheduler.cpp
index c33c707..7f58c79 100644
--- a/game/scheduler/ObjectsScheduler.cpp
+++ b/game/scheduler/ObjectsScheduler.cpp
@@ -12,35 +12,50 @@
#include "prefab/ZapperPoolSubScene.h"
using namespace crepe;
+
void ObjectsScheduler::preset_0() {
- trigger_event<MissileSpawnEvent>(MissileSpawnEvent {});
- trigger_event<MissileSpawnEvent>(MissileSpawnEvent {});
- this->trigger_event<BattleStartEvent>(BattleStartEvent {
- .num_enemies = Random::i(2, 0),
- .battle = false,
- });
+ for (int i = 0; i < this->amount_of_boss_fights; i++) {
+ this->trigger_event<MissileSpawnEvent>(MissileSpawnEvent {});
+ }
+ if (this->amount_of_boss_fights >= 1) {
+ this->trigger_event<BattleStartEvent>(BattleStartEvent {
+ .num_enemies = Random::i(this->amount_of_boss_fights, 0),
+ .battle = false,
+ });
+ }
}
+
void ObjectsScheduler::preset_1() {
trigger_event<MissileSpawnEvent>(MissileSpawnEvent {});
- this->trigger_event<BattleStartEvent>(BattleStartEvent {
- .num_enemies = Random::i(2, 1),
- .battle = false,
- });
+ if (this->amount_of_boss_fights >= 3) {
+ this->trigger_event<BattleStartEvent>(BattleStartEvent {
+ .num_enemies = Random::i(1, 0),
+ .battle = false,
+ });
+ }
}
+
void ObjectsScheduler::preset_2() {
trigger_event<CreateZapperEvent>(CreateZapperEvent {});
- this->trigger_event<BattleStartEvent>(BattleStartEvent {
- .num_enemies = Random::i(2, 1),
- .battle = false,
- });
+ if (this->amount_of_boss_fights >= 2) {
+ this->trigger_event<BattleStartEvent>(BattleStartEvent {
+ .num_enemies = Random::i(2, 1),
+ .battle = false,
+ });
+ }
}
+
void ObjectsScheduler::preset_3() { trigger_event<CreateZapperEvent>(CreateZapperEvent {}); }
+
void ObjectsScheduler::preset_4() {}
+
void ObjectsScheduler::boss_fight_1() {
this->get_components_by_name<Rigidbody>("camera").front().get().data.linear_velocity.x = 0;
this->get_components_by_name<Rigidbody>("player").front().get().data.linear_velocity.x = 0;
+
+ this->amount_of_boss_fights++;
this->trigger_event<BattleStartEvent>(BattleStartEvent {
- .num_enemies = 5,
+ .num_enemies = amount_of_boss_fights,
.battle = true,
});
@@ -57,10 +72,18 @@ bool ObjectsScheduler::boss_fight_1_event() {
this->get_components_by_name<Rigidbody>("player").front().get().data.linear_velocity.x
= PLAYER_SPEED * 0.02;
+ bool first = true;
RefVector<Rigidbody> rb_back_forest
= this->get_components_by_tag<Rigidbody>("forest_background");
- rb_back_forest.front().get().data.linear_velocity.x = 30;
- rb_back_forest.back().get().data.linear_velocity.x = 40;
+ for (Rigidbody & rb : rb_back_forest) {
+ if (first == true) {
+ rb.data.linear_velocity.x = 30;
+ first = false;
+ } else {
+ rb.data.linear_velocity.x = 40;
+ first = true;
+ }
+ }
return false;
}