monsterfangen/game.gd

50 lines
1.3 KiB
GDScript

extends Node3D
# Game.gd - Main Entrypoint for the game
@export var skip_menu: bool = true
@export var starting_world: PackedScene
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
# Skip the menu for development
if skip_menu == true:
UI.show_ingame_controls(!skip_menu)
UI.show_main_menu(!skip_menu)
if SaveManager.save_exists():
continue_game()
else:
start_new_game()
return
# On start of the game, the main menu is shown
UI.connect("on_new_game_started", start_new_game)
UI.connect("on_game_continued", continue_game)
UI.show_main_menu()
# this event comes from the MainMenu Node in the UI
func start_new_game() -> void:
UI.show_ingame_controls()
# Add the starting world
SceneManager.set_world(starting_world.resource_path)
# Add the starting player to the starting world
var player = preload("res://entities/player/player.tscn").instantiate()
SceneManager.current_world.add_child(player)
# Give the player a monster
var monster = MonsterData.new()
monster.set_data("debuggy")
SaveManager.current_save.party.push_back(monster)
# Update the UI once
UI.update()
# event comes from the MainMenu Node in the UI
func continue_game() -> void:
SaveManager.load_game()
UI.show_ingame_controls()
UI.update()