2024-10-20 16:44:08 -06:00
|
|
|
# quest class, impleeenting all quest functionality
|
|
|
|
# TODO: implement zone quests
|
2024-10-17 14:11:10 -06:00
|
|
|
class_name Quest
|
2024-10-18 09:11:15 -06:00
|
|
|
extends PanelContainer
|
2024-10-17 14:11:10 -06:00
|
|
|
|
|
|
|
|
2024-10-18 13:24:11 -06:00
|
|
|
@export var goalType := WorldArea.GoalType.KILL
|
2024-10-20 16:44:08 -06:00
|
|
|
@export var faction := Globals.World.Faction.CREATURE
|
2024-10-17 16:50:40 -06:00
|
|
|
|
|
|
|
@export var goalTotal := 1
|
2024-10-21 06:44:52 -06:00
|
|
|
var goalCurrent := 0
|
2024-10-17 14:11:10 -06:00
|
|
|
|
2024-10-18 09:11:15 -06:00
|
|
|
var questComplete := false
|
|
|
|
|
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)
|
2024-10-21 06:44:52 -06:00
|
|
|
#_generate_random_quest()
|
2024-10-17 16:50:40 -06:00
|
|
|
_set_goal_text()
|
|
|
|
_set_goal_val()
|
2024-10-17 14:11:10 -06:00
|
|
|
|
|
|
|
|
|
|
|
func _process(_delta: float) -> void:
|
2024-10-18 09:11:15 -06:00
|
|
|
if questComplete:
|
|
|
|
_quest_progress_hide()
|
|
|
|
_quest_complete_show()
|
2024-10-17 16:50:40 -06:00
|
|
|
|
|
|
|
|
|
|
|
func _set_goal_text() -> void:
|
2024-10-18 14:30:41 -06:00
|
|
|
var goalStr = WorldArea.GoalType.keys()[self.goalType].capitalize()
|
2024-10-20 16:44:08 -06:00
|
|
|
var factionStr = Globals.World.Faction.keys()[self.faction].capitalize()
|
2024-10-21 06:44:52 -06:00
|
|
|
# TODO: use better string formatting methods
|
2024-10-18 14:30:41 -06:00
|
|
|
$QuestProgress/GoalTypeVal.text = goalStr + " " + factionStr + "s"
|
|
|
|
|
2024-10-17 16:50:40 -06:00
|
|
|
|
|
|
|
func _set_goal_val() -> void:
|
2024-10-18 09:11:15 -06:00
|
|
|
$QuestProgress/GoalVal.text = str(self.goalTotal)
|
2024-10-17 16:50:40 -06:00
|
|
|
|
|
|
|
|
2024-10-20 16:44:08 -06:00
|
|
|
func _quest_goal_check(enemyKillType: Globals.World.Faction) -> void:
|
2024-10-18 13:24:11 -06:00
|
|
|
if enemyKillType == self.faction:
|
2024-10-17 16:50:40 -06:00
|
|
|
self.goalCurrent += 1
|
2024-10-18 09:11:15 -06:00
|
|
|
$QuestProgress/CompletedVal.text = str(self.goalCurrent)
|
2024-10-17 16:50:40 -06:00
|
|
|
if self.goalCurrent == self.goalTotal:
|
|
|
|
SignalBus.quest_completed.emit()
|
2024-10-18 09:11:15 -06:00
|
|
|
questComplete = true
|
|
|
|
|
|
|
|
|
|
|
|
func _quest_progress_hide() -> void:
|
|
|
|
$QuestProgress.modulate.a -= 0.05
|
|
|
|
|
|
|
|
|
|
|
|
func _quest_complete_show() -> void:
|
|
|
|
$QuestComplete.modulate.a += 0.05
|
2024-10-17 16:50:40 -06:00
|
|
|
|
|
|
|
|
|
|
|
func _generate_random_quest() -> void:
|
2024-10-20 16:44:08 -06:00
|
|
|
# TODO: generate acutally random quest
|
2024-10-18 14:30:41 -06:00
|
|
|
self.goalType = WorldArea.GoalType.KILL
|
2024-10-20 16:44:08 -06:00
|
|
|
self.faction = Globals.World.Faction.CREATURE
|
2024-10-18 14:30:41 -06:00
|
|
|
self.goalTotal = randi_range(20, 50)
|
2024-10-17 16:50:40 -06:00
|
|
|
# match self.goalType:
|
|
|
|
# GoalTypes.KILLMANY:
|
2024-10-18 13:24:11 -06:00
|
|
|
# self.faction = KillTypes.NATURAL
|
2024-10-17 16:50:40 -06:00
|
|
|
|
|
|
|
|
2024-10-20 16:44:08 -06:00
|
|
|
func _on_enemy_died(
|
|
|
|
_enemyDifficulty: NPC.NPCDifficulty,
|
|
|
|
_enemyTier: NPC.NPCTier,
|
|
|
|
enemyFaction: Globals.World.Faction,
|
|
|
|
):
|
2024-10-18 13:24:11 -06:00
|
|
|
_quest_goal_check(enemyFaction)
|