97 lines
2.8 KiB
GDScript
97 lines
2.8 KiB
GDScript
# BUG: elements not adjusting properly when resizing window
|
|
extends Control
|
|
|
|
|
|
# var deltaCount := 0
|
|
# var enemyMoveSpeed := 5.0
|
|
# var questComplete := false
|
|
var canContinue := false
|
|
var totalAreas := 0
|
|
|
|
var worldArea: WorldArea
|
|
var currentAreaQuest: Quest
|
|
var current_area_duration: float
|
|
|
|
|
|
func _ready() -> void:
|
|
if OS.is_debug_build():
|
|
%DebugMenu.show()
|
|
|
|
SignalBus.quest_generated.connect(_on_quest_generated)
|
|
SignalBus.quest_completed.connect(_on_quest_completed)
|
|
|
|
_create_area()
|
|
current_area_duration = 0
|
|
%UITop/AutoProgressToggle.button_pressed = true
|
|
|
|
|
|
# func _process(_delta: float) -> void:
|
|
# deltaCount += 1
|
|
# if canContinue:
|
|
# _continue_button_show()
|
|
|
|
|
|
func _create_area() -> void:
|
|
worldArea = load("res://scenes/world_area.tscn").instantiate()
|
|
add_child(worldArea)
|
|
move_child(worldArea, 0)
|
|
|
|
func _on_button_test_pressed() -> void:
|
|
# slowly increasing chance to get 1
|
|
# bad luck protection for rare spawns, drops, etc.
|
|
var testVal := 0.0
|
|
for i in range(1000):
|
|
testVal += 0.001
|
|
print(testVal, bool(RandomNumberGenerator.new().rand_weighted([1, testVal])))
|
|
|
|
|
|
func _on_button_exit_pressed() -> void:
|
|
# get_tree().quit()
|
|
get_tree().change_scene_to_file("res://scenes/main_menu.tscn")
|
|
|
|
|
|
func _go_next_area() -> void:
|
|
var prevAreaQuest = currentAreaQuest
|
|
SignalBus.area_continue_pressed.emit()
|
|
# Globals.debug_print("gna signal emitted")
|
|
%QuestsContainer.remove_child(prevAreaQuest)
|
|
# Globals.debug_print("gna quest removed")
|
|
# FIXME: rethink logic flow, memory/nodes leaking like a seive
|
|
prevAreaQuest.queue_free()
|
|
totalAreas += 1
|
|
%AreaCountVal.text = str(totalAreas)
|
|
# Globals.debug_print("gna quest queued to free")
|
|
_create_area()
|
|
# Globals.debug_print("gna new area created")
|
|
# _continue_button_hide()
|
|
# Globals.fade_node(%UITop/ContinueButton, "out", 0.1)
|
|
%UITop/ContinueButton.hide()
|
|
current_area_duration = 0
|
|
canContinue = false
|
|
|
|
|
|
func _on_quest_generated(quest) -> void:
|
|
currentAreaQuest = quest
|
|
%QuestsContainer.add_child(currentAreaQuest)
|
|
|
|
|
|
func _on_quest_completed() -> void:
|
|
if %UITop/AutoProgressToggle.button_pressed:
|
|
_go_next_area()
|
|
else:
|
|
# Globals.fade_node(%UITop/ContinueButton, "in", 0.25)
|
|
%UITop/ContinueButton.show()
|
|
|
|
|
|
func _on_continue_button_pressed() -> void:
|
|
_go_next_area()
|
|
|
|
|
|
func _on_clock_timer_timeout() -> void:
|
|
var current_time = Time.get_unix_time_from_system()
|
|
%SystemClock.text = Time.get_time_string_from_unix_time(current_time)
|
|
PlayerState.zone_duration += 1
|
|
%ZTVal.text = Globals.elapsed_time_format(Globals.elapsed_time(PlayerState.zone_duration))
|
|
current_area_duration += 1
|
|
%ATVal.text = Globals.elapsed_time_format(Globals.elapsed_time(current_area_duration))
|