feat: better level loading
This commit is contained in:
parent
94be550654
commit
317aed8f1b
|
@ -11,7 +11,7 @@ void EndScreen::_bind_methods() {
|
|||
GDPROPERTY_HINTED(game_scene, Variant::OBJECT, PROPERTY_HINT_RESOURCE_TYPE, "PackedScene");
|
||||
}
|
||||
|
||||
void EndScreen::_enter_tree() { GDGAMEONLY();
|
||||
void EndScreen::_ready() { GDGAMEONLY();
|
||||
Button *restart_button = this->get_node<Button>("RestartButton");
|
||||
restart_button->connect("button_down", callable_mp(this, &EndScreen::restart));
|
||||
restart_button->grab_focus();
|
||||
|
@ -20,8 +20,7 @@ void EndScreen::_enter_tree() { GDGAMEONLY();
|
|||
}
|
||||
|
||||
void EndScreen::return_to_main() {
|
||||
this->get_owner()->queue_free();
|
||||
GameRoot3D::get_singleton()->load_level(this->main_menu_scene);
|
||||
GameRoot3D::get_singleton()->replace_levels(this->main_menu_scene);
|
||||
}
|
||||
|
||||
void EndScreen::restart() {
|
||||
|
|
|
@ -8,7 +8,7 @@ class EndScreen : public CanvasLayer {
|
|||
GDCLASS(EndScreen, CanvasLayer);
|
||||
static void _bind_methods();
|
||||
public:
|
||||
virtual void _enter_tree() override;
|
||||
virtual void _ready() override;
|
||||
|
||||
void return_to_main();
|
||||
void restart();
|
||||
|
|
|
@ -12,7 +12,7 @@ void MenuUI::_bind_methods() {
|
|||
GDPROPERTY_HINTED(game_scene, Variant::OBJECT, PROPERTY_HINT_RESOURCE_TYPE, "PackedScene");
|
||||
}
|
||||
|
||||
void MenuUI::_enter_tree() { GDGAMEONLY();
|
||||
void MenuUI::_ready() { GDGAMEONLY();
|
||||
Button *start_button = this->get_node<Button>("StartButton");
|
||||
start_button->connect("button_down", callable_mp(this, &MenuUI::start_game));
|
||||
start_button->grab_focus();
|
||||
|
@ -23,8 +23,7 @@ void MenuUI::_enter_tree() { GDGAMEONLY();
|
|||
}
|
||||
|
||||
void MenuUI::start_game() {
|
||||
this->get_parent()->queue_free();
|
||||
GameRoot3D::get_singleton()->load_level(this->game_scene);
|
||||
GameRoot3D::get_singleton()->replace_levels(this->game_scene);
|
||||
}
|
||||
|
||||
void MenuUI::toggle_controls() {
|
||||
|
|
|
@ -11,7 +11,7 @@ class MenuUI : public CanvasLayer {
|
|||
GDCLASS(MenuUI, CanvasLayer);
|
||||
static void _bind_methods();
|
||||
public:
|
||||
virtual void _enter_tree() override;
|
||||
virtual void _ready() override;
|
||||
|
||||
void start_game();
|
||||
void toggle_controls();
|
||||
|
|
|
@ -23,16 +23,10 @@ void RallyRushGameMode::notify_key_found() {
|
|||
}
|
||||
|
||||
void RallyRushGameMode::notify_player_death() {
|
||||
GameRoot3D *root = GameRoot3D::get_singleton();
|
||||
HashMap<StringName, Level3D*> levels = root->get_levels();
|
||||
for(KeyValue<StringName, Level3D*> &kvp : levels)
|
||||
if(kvp.value->is_inside_tree())
|
||||
kvp.value->queue_free();
|
||||
root->get_levels().clear();
|
||||
root->load_level(ResourceLoader::get_singleton()->load("res://game_end_screen.tscn"));
|
||||
root->reset_game_mode();
|
||||
GameRoot3D::get_singleton()->replace_levels(ResourceLoader::get_singleton()->load("res://game_end_screen.tscn"));
|
||||
}
|
||||
|
||||
void RallyRushGameMode::notify_player_escaped() {
|
||||
GameRoot3D::get_singleton()->replace_levels(ResourceLoader::get_singleton()->load("res://game_end_screen.tscn"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue