feat: implemented enemies spawning based on current region difficulty
This commit is contained in:
parent
96b5be405c
commit
9b07c70b11
8 changed files with 341 additions and 131 deletions
|
|
@ -1,10 +1,12 @@
|
|||
#include "map_region.h"
|
||||
#include "enemy_body.h"
|
||||
|
||||
String const MapRegion::sig_phase_changed{ "phase_changed" };
|
||||
String const MapRegion::sig_difficulty_increased{ "difficulty_increased" };
|
||||
String const MapRegion::sig_phase_changed{ "hunt_phase" };
|
||||
|
||||
void MapRegion::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo(sig_phase_changed, PropertyInfo(Variant::BOOL, "hunt_phase")));
|
||||
ADD_SIGNAL(MethodInfo(sig_difficulty_increased));
|
||||
ADD_SIGNAL(MethodInfo(sig_phase_changed, PropertyInfo(Variant::BOOL, "hunt")));
|
||||
}
|
||||
|
||||
void MapRegion::on_node_entered(Node *node) {
|
||||
|
|
@ -43,3 +45,22 @@ void MapRegion::remove_unit(NpcUnit *unit) {
|
|||
this->units.erase(unit);
|
||||
}
|
||||
}
|
||||
|
||||
void MapRegion::raise_difficulty(double amount) {
|
||||
if (this->hunt_phase) {
|
||||
return;
|
||||
}
|
||||
double const new_difficulty{ this->difficulty + amount };
|
||||
int const new_trunc{ (int)Math::floor(new_difficulty) };
|
||||
int const old_trunc{ (int)Math::floor(this->difficulty) };
|
||||
if (new_trunc != old_trunc) {
|
||||
emit_signal(sig_difficulty_increased);
|
||||
emit_signal(sig_phase_changed, true);
|
||||
this->hunt_phase = true;
|
||||
}
|
||||
}
|
||||
|
||||
int MapRegion::get_current_difficulty() const {
|
||||
int difficulty{ (int)Math::floor(this->difficulty) };
|
||||
return difficulty;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue