From 79b699887e9f414cb8537e812a4396ee7e6b3dad Mon Sep 17 00:00:00 2001 From: tonydero Date: Tue, 22 Oct 2024 18:55:47 -0600 Subject: [PATCH] convert to general Globals.fade_node use --- scenes/quest.tscn | 2 ++ scripts/Globals.gd | 9 +++++---- scripts/NPCEnemy.gd | 6 ++++++ scripts/Quest.gd | 12 ++---------- scripts/combat_ui_scene.gd | 23 ++-------------------- scripts/map_tile.gd | 12 ------------ scripts/test_instance_scene.gd | 36 ---------------------------------- scripts/test_scene.gd | 22 --------------------- 8 files changed, 17 insertions(+), 105 deletions(-) delete mode 100644 scripts/map_tile.gd delete mode 100644 scripts/test_instance_scene.gd delete mode 100644 scripts/test_scene.gd diff --git a/scenes/quest.tscn b/scenes/quest.tscn index 4276e25..8201fe8 100644 --- a/scenes/quest.tscn +++ b/scenes/quest.tscn @@ -13,6 +13,7 @@ script = ExtResource("1_o0k38") goalTotal = 20 [node name="QuestProgress" type="HBoxContainer" parent="."] +unique_name_in_owner = true layout_mode = 2 [node name="GoalTypeVal" type="Label" parent="QuestProgress"] @@ -36,6 +37,7 @@ layout_mode = 2 text = "1" [node name="QuestComplete" type="Label" parent="."] +unique_name_in_owner = true modulate = Color(1, 1, 1, 0) layout_mode = 2 size_flags_horizontal = 4 diff --git a/scripts/Globals.gd b/scripts/Globals.gd index 2a6dcef..a59d59d 100644 --- a/scripts/Globals.gd +++ b/scripts/Globals.gd @@ -74,7 +74,8 @@ func fade_node(node: Node, direction: String, duration: float) -> void: func _input(event: InputEvent) -> void: - if event.is_action_pressed("game_speed_fast"): - Engine.time_scale = 10.0 - if event.is_action_pressed("game_speed_normal"): - Engine.time_scale = 1.0 + if OS.is_debug_build(): + if event.is_action_pressed("game_speed_fast"): + Engine.time_scale = 10.0 + if event.is_action_pressed("game_speed_normal"): + Engine.time_scale = 1.0 diff --git a/scripts/NPCEnemy.gd b/scripts/NPCEnemy.gd index 28c39b4..a8646c7 100644 --- a/scripts/NPCEnemy.gd +++ b/scripts/NPCEnemy.gd @@ -20,6 +20,10 @@ func _ready() -> void: # set faction self.faction = Globals.World.Faction.CREATURE + + # randomness + # TODO: needs to be random from distribution + # var rand_difficulty = NPC.NPCDifficulty.values().pick_random() # set health _random_mod_health() @@ -37,6 +41,8 @@ func _process(_delta: float) -> void: var enemyFaction = self.faction var enemyTier = self.npcTier # delete node + # TODO: add fade out for enemy death, Global func doens't work due to + # the node getting freed, await didn't help. reimpliment here in enemy. self.remove_from_group("enemies") self.queue_free() # send signal that I died to be counted, etc. diff --git a/scripts/Quest.gd b/scripts/Quest.gd index ed862be..464701e 100644 --- a/scripts/Quest.gd +++ b/scripts/Quest.gd @@ -21,8 +21,8 @@ func _ready() -> void: func _process(_delta: float) -> void: if questComplete: - _quest_progress_hide() - _quest_complete_show() + Globals.fade_node(%QuestProgress, "out", 0.1) + Globals.fade_node(%QuestComplete, "in", 0.1) func _set_goal_text() -> void: @@ -45,14 +45,6 @@ func _quest_goal_check(enemyKillType: Globals.World.Faction) -> void: questComplete = true -func _quest_progress_hide() -> void: - $QuestProgress.modulate.a -= 0.05 - - -func _quest_complete_show() -> void: - $QuestComplete.modulate.a += 0.05 - - func _generate_random_quest() -> void: # TODO: generate acutally random quest self.goalType = WorldArea.GoalType.KILL diff --git a/scripts/combat_ui_scene.gd b/scripts/combat_ui_scene.gd index 2ab8112..4128a29 100644 --- a/scripts/combat_ui_scene.gd +++ b/scripts/combat_ui_scene.gd @@ -46,25 +46,7 @@ func _on_button_test_pressed() -> void: func _on_button_exit_pressed() -> void: get_tree().quit() - -func _continue_button_show() -> void: - # %UITop/ContinueButton.modulate.a += 0.05 - %UITop/ContinueButton.show() - while %UITop/ContinueButton.modulate.a < 1: - # 50 steps 1/100th of a second apart for a total 1/2 second animation - 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: - # 20 steps 1/100th of a second apart for a total 1/5 second animation - await get_tree().create_timer(0.01).timeout - %UITop/ContinueButton.modulate.a -= 0.05 - %UITop/ContinueButton.hide() - - - func _go_next_area() -> void: var prevAreaQuest = currentAreaQuest SignalBus.area_continue_pressed.emit() @@ -78,7 +60,7 @@ func _go_next_area() -> void: _create_area() # Globals.debug_print("gna new area created") # _continue_button_hide() - Globals.fade_node(%UITop/ContinueButton, "out", 0.5) + Globals.fade_node(%UITop/ContinueButton, "out", 0.1) canContinue = false @@ -91,8 +73,7 @@ func _on_quest_completed() -> void: if %UITop/AutoCheck.button_pressed: _go_next_area() else: - _continue_button_show() - # canContinue = true + Globals.fade_node(%UITop/ContinueButton, "in", 0.25) func _on_continue_button_pressed() -> void: diff --git a/scripts/map_tile.gd b/scripts/map_tile.gd deleted file mode 100644 index 63be33d..0000000 --- a/scripts/map_tile.gd +++ /dev/null @@ -1,12 +0,0 @@ -extends Node2D - - -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - pass - - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass diff --git a/scripts/test_instance_scene.gd b/scripts/test_instance_scene.gd deleted file mode 100644 index 54d028f..0000000 --- a/scripts/test_instance_scene.gd +++ /dev/null @@ -1,36 +0,0 @@ -extends Control - - -var enemies = Array() -@export var debug = false - - -func _on_button_instantiate_pressed() -> void: - var middleX := get_viewport_rect().size.x / 2 - var upperY := get_viewport_rect().size.y / 4 - var middleY := get_viewport_rect().size.y / 2 - for enemy in enemies: - remove_child(enemy) - - enemies = [] - var numEnemies = randi_range(1, 5) - for i in range(numEnemies): - enemies.append(load("res://scenes/npc.tscn").instantiate()) - add_child(enemies[i]) - var posX := int(round((i + 1) * get_viewport_rect().size.x / (numEnemies + 1))) - enemies[i].position = Vector2(posX, middleY) - enemies[0].get_node("%NPCNameLabel").text = "Test" - var bossEnemy = load("res://scenes/npc.tscn").instantiate() - bossEnemy.npcDifficulty = NPC.NPCDifficulty.BOSS - add_child(bossEnemy) - bossEnemy.position = Vector2(middleX, upperY) - #print(bossEnemy.npcDifficulty) - bossEnemy.scale = Vector2.ONE * 1.6 - - -func _on_button_exit_pressed() -> void: - get_tree().quit() - -func _ready() -> void: - if not debug: - $MarginContainer/Menus/DebugMenu.hide() diff --git a/scripts/test_scene.gd b/scripts/test_scene.gd deleted file mode 100644 index b4547a3..0000000 --- a/scripts/test_scene.gd +++ /dev/null @@ -1,22 +0,0 @@ -extends Control - - -@onready var styling: Control = $Styling - - -func _on_exit_button_pressed() -> void: - get_tree().quit() - - -func _on_test_button_pressed() -> void: - var rand_difficulty = NPC.NPCDifficulty.values().pick_random() - var rand_tier = NPC.NPCTier.values().pick_random() - var anNPC = NPC.new() - %TestNMEMaxHealthVal.text = str(anNPC.maxHealth) - #TestEMaxHealthVal.label_settings = LabelSettings.new() - %TestNMEName.text = str(NPC.NPCDifficulty.find_key(anNPC.npcDifficulty)) - %TestNMETierVal.text = str(NPC.NPCTier.find_key(anNPC.npcTier)) - # style the name label based on the difficulty - styling.format_label_difficulty(%TestNMEName, anNPC.npcDifficulty) - #anNPC.position = Vector2(64, 64) - #add_child(anNPC)