2024-10-22 12:11:56 -06:00
|
|
|
# BUG: elements not adjusting properly when resizing window
|
2024-10-08 20:51:11 -06:00
|
|
|
extends Control
|
|
|
|
|
|
|
|
|
2024-10-21 16:31:33 -06:00
|
|
|
# var deltaCount := 0
|
|
|
|
# var enemyMoveSpeed := 5.0
|
2024-10-18 14:30:41 -06:00
|
|
|
# var questComplete := false
|
|
|
|
var canContinue := false
|
2024-10-22 12:11:56 -06:00
|
|
|
var totalAreas := 0
|
2024-10-08 20:51:11 -06:00
|
|
|
|
2024-10-21 11:22:38 -06:00
|
|
|
var worldArea: WorldArea
|
|
|
|
var currentAreaQuest: Quest
|
2024-10-24 16:15:49 -06:00
|
|
|
var start_zone_time: float
|
|
|
|
var start_area_time: float
|
|
|
|
var current_zone_duration: float
|
|
|
|
var current_area_duration: float
|
2024-10-09 20:55:46 -06:00
|
|
|
|
2024-10-08 20:51:11 -06:00
|
|
|
|
|
|
|
func _ready() -> void:
|
2024-10-21 09:51:28 -06:00
|
|
|
if OS.is_debug_build():
|
2024-10-18 16:17:39 -06:00
|
|
|
%DebugMenu.show()
|
2024-10-20 16:44:08 -06:00
|
|
|
Engine.time_scale = 10.0
|
2024-10-17 16:50:40 -06:00
|
|
|
|
2024-10-21 09:51:28 -06:00
|
|
|
SignalBus.quest_generated.connect(_on_quest_generated)
|
2024-10-17 16:50:40 -06:00
|
|
|
SignalBus.quest_completed.connect(_on_quest_completed)
|
2024-10-18 14:05:31 -06:00
|
|
|
|
2024-10-21 09:51:28 -06:00
|
|
|
_create_area()
|
2024-10-24 16:15:49 -06:00
|
|
|
start_zone_time = Time.get_unix_time_from_system()
|
|
|
|
start_area_time = Time.get_unix_time_from_system()
|
2024-10-15 15:04:40 -06:00
|
|
|
|
|
|
|
|
2024-10-22 12:11:56 -06:00
|
|
|
# func _process(_delta: float) -> void:
|
2024-10-21 16:31:33 -06:00
|
|
|
# deltaCount += 1
|
2024-10-22 12:11:56 -06:00
|
|
|
# if canContinue:
|
|
|
|
# _continue_button_show()
|
2024-10-09 20:55:46 -06:00
|
|
|
|
2024-10-08 20:51:11 -06:00
|
|
|
|
2024-10-21 09:51:28 -06:00
|
|
|
func _create_area() -> void:
|
2024-10-21 11:22:38 -06:00
|
|
|
worldArea = load("res://scenes/world_area.tscn").instantiate()
|
2024-10-21 09:51:28 -06:00
|
|
|
add_child(worldArea)
|
|
|
|
move_child(worldArea, 0)
|
2024-10-08 20:51:11 -06:00
|
|
|
|
|
|
|
func _on_button_test_pressed() -> void:
|
2024-10-21 16:31:33 -06:00
|
|
|
# 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])))
|
2024-10-08 20:51:11 -06:00
|
|
|
|
|
|
|
|
|
|
|
func _on_button_exit_pressed() -> void:
|
|
|
|
get_tree().quit()
|
|
|
|
|
2024-10-22 12:11:56 -06:00
|
|
|
|
2024-10-21 11:22:38 -06:00
|
|
|
func _go_next_area() -> void:
|
|
|
|
var prevAreaQuest = currentAreaQuest
|
|
|
|
SignalBus.area_continue_pressed.emit()
|
2024-10-21 13:09:51 -06:00
|
|
|
# Globals.debug_print("gna signal emitted")
|
2024-10-21 11:22:38 -06:00
|
|
|
%QuestsContainer.remove_child(prevAreaQuest)
|
2024-10-21 13:09:51 -06:00
|
|
|
# Globals.debug_print("gna quest removed")
|
2024-10-25 22:22:13 -06:00
|
|
|
# FIXME: rethink logic flow, memory/nodes leaking like a seive
|
2024-10-24 14:20:00 -06:00
|
|
|
# prevAreaQuest.queue_free()
|
2024-10-22 12:11:56 -06:00
|
|
|
totalAreas += 1
|
|
|
|
%AreaCountVal.text = str(totalAreas)
|
2024-10-21 13:09:51 -06:00
|
|
|
# Globals.debug_print("gna quest queued to free")
|
2024-10-21 11:22:38 -06:00
|
|
|
_create_area()
|
2024-10-21 13:09:51 -06:00
|
|
|
# Globals.debug_print("gna new area created")
|
2024-10-22 14:11:05 -06:00
|
|
|
# _continue_button_hide()
|
2024-10-22 18:55:47 -06:00
|
|
|
Globals.fade_node(%UITop/ContinueButton, "out", 0.1)
|
2024-10-24 16:15:49 -06:00
|
|
|
start_area_time = Time.get_unix_time_from_system()
|
2024-10-22 12:11:56 -06:00
|
|
|
canContinue = false
|
2024-10-21 13:09:51 -06:00
|
|
|
|
2024-10-21 11:22:38 -06:00
|
|
|
|
2024-10-21 09:51:28 -06:00
|
|
|
func _on_quest_generated(quest) -> void:
|
2024-10-21 11:22:38 -06:00
|
|
|
currentAreaQuest = quest
|
|
|
|
%QuestsContainer.add_child(currentAreaQuest)
|
2024-10-17 16:50:40 -06:00
|
|
|
|
|
|
|
|
|
|
|
func _on_quest_completed() -> void:
|
2024-10-21 09:51:28 -06:00
|
|
|
if %UITop/AutoCheck.button_pressed:
|
2024-10-21 11:22:38 -06:00
|
|
|
_go_next_area()
|
2024-10-21 09:51:28 -06:00
|
|
|
else:
|
2024-10-22 18:55:47 -06:00
|
|
|
Globals.fade_node(%UITop/ContinueButton, "in", 0.25)
|
2024-10-21 11:22:38 -06:00
|
|
|
|
|
|
|
|
|
|
|
func _on_continue_button_pressed() -> void:
|
|
|
|
_go_next_area()
|
2024-10-21 17:14:04 -06:00
|
|
|
|
|
|
|
|
|
|
|
func _on_clock_timer_timeout() -> void:
|
2024-10-24 16:15:49 -06:00
|
|
|
var current_time = Time.get_unix_time_from_system()
|
|
|
|
%SystemClock.text = Time.get_time_string_from_unix_time(current_time)
|
|
|
|
current_zone_duration = current_time - start_zone_time
|
2024-10-25 14:46:19 -06:00
|
|
|
%ZTVal.text = Globals.elapsed_time_format(Globals.elapsed_time(current_zone_duration))
|
2024-10-24 16:15:49 -06:00
|
|
|
current_area_duration = current_time - start_area_time
|
2024-10-25 14:46:19 -06:00
|
|
|
%ATVal.text = Globals.elapsed_time_format(Globals.elapsed_time(current_area_duration))
|