semi-idle-arpg/scripts/combat_ui_scene.gd

101 lines
2.6 KiB
GDScript3
Raw Normal View History

# BUG: elements not adjusting properly when resizing window
2024-10-08 20:51:11 -06:00
extends Control
# var deltaCount := 0
# var enemyMoveSpeed := 5.0
2024-10-18 14:30:41 -06:00
# var questComplete := false
var canContinue := false
var totalAreas := 0
2024-10-08 20:51:11 -06:00
var worldArea: WorldArea
var currentAreaQuest: Quest
2024-10-08 20:51:11 -06:00
func _ready() -> void:
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
SignalBus.quest_generated.connect(_on_quest_generated)
SignalBus.quest_completed.connect(_on_quest_completed)
2024-10-18 14:05:31 -06:00
_create_area()
# func _process(_delta: float) -> void:
# deltaCount += 1
# if canContinue:
# _continue_button_show()
2024-10-08 20:51:11 -06:00
func _create_area() -> void:
worldArea = load("res://scenes/world_area.tscn").instantiate()
add_child(worldArea)
move_child(worldArea, 0)
2024-10-08 20:51:11 -06:00
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])))
2024-10-08 20:51:11 -06:00
func _on_button_exit_pressed() -> void:
get_tree().quit()
2024-10-21 16:59:53 -06:00
func _continue_button_show() -> void:
# %UITop/ContinueButton.modulate.a += 0.05
%UITop/ContinueButton.show()
while %UITop/ContinueButton.modulate.a < 1:
await get_tree().create_timer(0.01).timeout
%UITop/ContinueButton.modulate.a += 0.02
func _continue_button_hide() -> void:
while %UITop/ContinueButton.modulate.a > 0:
await get_tree().create_timer(0.01).timeout
%UITop/ContinueButton.modulate.a -= 0.05
%UITop/ContinueButton.hide()
2024-10-18 16:17:39 -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")
%QuestsContainer.remove_child(prevAreaQuest)
2024-10-21 13:09:51 -06:00
# Globals.debug_print("gna quest removed")
prevAreaQuest.queue_free()
totalAreas += 1
%AreaCountVal.text = str(totalAreas)
2024-10-21 13:09:51 -06:00
# Globals.debug_print("gna quest queued to free")
_create_area()
2024-10-21 13:09:51 -06:00
# Globals.debug_print("gna new area created")
_continue_button_hide()
canContinue = false
2024-10-21 13:09:51 -06:00
func _on_quest_generated(quest) -> void:
currentAreaQuest = quest
%QuestsContainer.add_child(currentAreaQuest)
func _on_quest_completed() -> void:
if %UITop/AutoCheck.button_pressed:
_go_next_area()
else:
_continue_button_show()
# canContinue = true
func _on_continue_button_pressed() -> void:
_go_next_area()
func _on_clock_timer_timeout() -> void:
%SystemClock.text = Time.get_time_string_from_system()