add quest completion text animation

This commit is contained in:
tonydero 2024-10-18 09:11:15 -06:00
parent d5db6e873b
commit 4d67f43f3b
6 changed files with 55 additions and 24 deletions

View File

@ -1,24 +1,42 @@
[gd_scene load_steps=2 format=3 uid="uid://klcyjys703l5"]
[gd_scene load_steps=3 format=3 uid="uid://klcyjys703l5"]
[ext_resource type="Script" path="res://scripts/Quest.gd" id="1_o0k38"]
[node name="Quest" type="HBoxContainer"]
offset_right = 40.0
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_dv3o6"]
[node name="PanelContainer" type="PanelContainer"]
offset_left = 175.0
offset_right = 175.0
offset_bottom = 40.0
theme_override_styles/panel = SubResource("StyleBoxEmpty_dv3o6")
script = ExtResource("1_o0k38")
[node name="GoalLabel" type="Label" parent="."]
[node name="QuestProgress" type="HBoxContainer" parent="."]
layout_mode = 2
text = "Quest Objective: "
[node name="CompletedValLabel" type="Label" parent="."]
[node name="GoalTextVal" type="Label" parent="QuestProgress"]
layout_mode = 2
text = "Quest Objective"
[node name="Colon" type="Label" parent="QuestProgress"]
layout_mode = 2
text = ":"
[node name="CompletedVal" type="Label" parent="QuestProgress"]
layout_mode = 2
text = "0"
[node name="Separator" type="Label" parent="."]
[node name="Separator" type="Label" parent="QuestProgress"]
layout_mode = 2
text = "/"
[node name="GoalValLabel" type="Label" parent="."]
[node name="GoalVal" type="Label" parent="QuestProgress"]
layout_mode = 2
text = "1"
[node name="QuestComplete" type="Label" parent="."]
visible = false
modulate = Color(1, 1, 1, 0)
layout_mode = 2
size_flags_horizontal = 4
text = "Quest Complete!"

View File

@ -22,7 +22,7 @@ grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_gc1kb")
debug = true
spawnTimerValue = 0.5
spawnTimerValue = 0.75
[node name="SpawnTimer" type="Timer" parent="."]
@ -182,6 +182,7 @@ layout_mode = 2
text = "Crafting"
[node name="DebugMenu" type="HBoxContainer" parent="MarginContainer/UIBottom/UIBottomCenter/MenuButtons"]
visible = false
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 8

View File

@ -1,4 +1,4 @@
# placerholder test ability
# base player ability class
class_name AbilityPlayer
extends AbilityBase
@ -8,11 +8,11 @@ var playerPos
func _ready() -> void:
middleX = get_viewport_rect().size.x/2
middleX = get_viewport_rect().size.x / 2
func _process(_delta: float) -> void:
playerPos = Vector2(middleX, get_viewport_rect().size.y*(0.75))
playerPos = Vector2(middleX, get_viewport_rect().size.y * (0.75))
$IdleCooldown.wait_time = attack_speed

View File

@ -6,7 +6,7 @@ extends NPC
@export var killType: WorldArea.KillTypes = WorldArea.KillTypes.NATURAL
var target
var speed := 300
var speed := 200
var prevCollisions := 0

View File

@ -1,5 +1,5 @@
class_name Quest
extends HBoxContainer
extends PanelContainer
@export var goalType := WorldArea.GoalTypes.KILLMANY
@ -8,6 +8,8 @@ extends HBoxContainer
@export var goalTotal := 1
@export var goalCurrent := 0
var questComplete := false
func _ready() -> void:
SignalBus.enemy_died.connect(_on_enemy_died)
_generate_random_quest()
@ -16,25 +18,37 @@ func _ready() -> void:
func _process(_delta: float) -> void:
pass
if questComplete:
_quest_progress_hide()
_quest_complete_show()
func _set_goal_text() -> void:
match self.goalType:
WorldArea.GoalTypes.KILLMANY:
$GoalLabel.text = "Kill Many"
$QuestProgress/GoalTextVal.text = "Kill Many"
func _set_goal_val() -> void:
$GoalValLabel.text = str(self.goalTotal)
$QuestProgress/GoalVal.text = str(self.goalTotal)
func _quest_goal_check(enemyKillType: WorldArea.KillTypes) -> void:
if enemyKillType == self.killType:
self.goalCurrent += 1
$CompletedValLabel.text = str(self.goalCurrent)
$QuestProgress/CompletedVal.text = str(self.goalCurrent)
if self.goalCurrent == self.goalTotal:
SignalBus.quest_completed.emit()
questComplete = true
func _quest_progress_hide() -> void:
$QuestProgress.modulate.a -= 0.05
func _quest_complete_show() -> void:
$QuestComplete.show()
$QuestComplete.modulate.a += 0.05
func _generate_random_quest() -> void:

View File

@ -13,8 +13,9 @@ var playerPos
func _ready() -> void:
if not debug:
$MarginContainer/Menus/MenuButtons/DebugMenu.hide()
if debug:
$MarginContainer/UIBottom/UIBottomCenter/MenuButtons/DebugMenu.show()
Engine.time_scale = 3.0
SignalBus.quest_completed.connect(_on_quest_completed)
@ -27,6 +28,7 @@ func _ready() -> void:
func _process(_delta: float) -> void:
deltaCount += 1
playerPos = Vector2(middleX, get_viewport_rect().size.y * (0.75))
if _get_enemies().is_empty() and questComplete:
print("Area Complete!")
@ -78,7 +80,3 @@ func _on_spawn_timer_timeout() -> void:
func _on_quest_completed() -> void:
$SpawnTimer.stop()
questComplete = true
$MarginContainer/UITop/QuestsContainer/PHQuest.hide()
var quest_complete_indicator = Label.new()
quest_complete_indicator.text = "Quest Complete!"
$"%QuestsContainer".add_child(quest_complete_indicator)