2024-10-17 14:11:10 -06:00
|
|
|
class_name Quest
|
|
|
|
extends HBoxContainer
|
|
|
|
|
|
|
|
|
2024-10-17 16:50:40 -06:00
|
|
|
@export var goalType := WorldArea.GoalTypes.KILLMANY
|
|
|
|
@export var killType := WorldArea.KillTypes.NATURAL
|
|
|
|
|
|
|
|
@export var goalTotal := 1
|
|
|
|
@export var goalCurrent := 0
|
2024-10-17 14:11:10 -06:00
|
|
|
|
|
|
|
func _ready() -> void:
|
2024-10-17 16:50:40 -06:00
|
|
|
SignalBus.enemy_died.connect(_on_enemy_died)
|
|
|
|
_generate_random_quest()
|
|
|
|
_set_goal_text()
|
|
|
|
_set_goal_val()
|
2024-10-17 14:11:10 -06:00
|
|
|
|
|
|
|
|
|
|
|
func _process(_delta: float) -> void:
|
|
|
|
pass
|
2024-10-17 16:50:40 -06:00
|
|
|
|
|
|
|
|
|
|
|
func _set_goal_text() -> void:
|
|
|
|
match self.goalType:
|
|
|
|
WorldArea.GoalTypes.KILLMANY:
|
|
|
|
$GoalLabel.text = "Kill Many"
|
|
|
|
|
|
|
|
|
|
|
|
func _set_goal_val() -> void:
|
|
|
|
$GoalValLabel.text = str(self.goalTotal)
|
|
|
|
|
|
|
|
|
|
|
|
func _quest_goal_check(enemyKillType: WorldArea.KillTypes) -> void:
|
|
|
|
if enemyKillType == self.killType:
|
|
|
|
self.goalCurrent += 1
|
|
|
|
$CompletedValLabel.text = str(self.goalCurrent)
|
|
|
|
if self.goalCurrent == self.goalTotal:
|
|
|
|
SignalBus.quest_completed.emit()
|
|
|
|
|
|
|
|
|
|
|
|
func _generate_random_quest() -> void:
|
|
|
|
pass
|
|
|
|
# TODO: generate random quest
|
|
|
|
# self.goalType = GoalTypes.
|
|
|
|
# match self.goalType:
|
|
|
|
# GoalTypes.KILLMANY:
|
|
|
|
# self.killType = KillTypes.NATURAL
|
|
|
|
|
|
|
|
|
|
|
|
func _on_enemy_died(_enemyDifficulty: NPC.NPCDifficulties, enemyKillType: WorldArea.KillTypes):
|
|
|
|
_quest_goal_check(enemyKillType)
|