update to unity 6.2, add save system and quest system

This commit is contained in:
2025-12-02 16:52:02 -06:00
parent aea12ab091
commit c7dca2f8e5
23 changed files with 767 additions and 48 deletions
+70 -3
View File
@@ -3,18 +3,85 @@
public class Talkable : Interactable
{
// this is a character or object that will talk upon interaction
public Dialogue dialogue;
public Dialogue defaultDialogue;
public GameObject talkIndicator;
public Quest[] quests;
Dialogue currentDialogue;
public void Start()
{
talkIndicator.SetActive(false);
}
void DetermineDialogue()
{
// based on if we have any open quests and where we're at in the quest,
// determine what dialogue to show
Quest currentQuest = null;
// Grab the first ACTIVE quest
// If none active, grab the first AVAILABLE quest
// If none available, revert to default dialogue
if (quests.Length > 0)
{
// check for ACTIVE quests
foreach (Quest q in quests)
{
if (q.hasStarted && !q.hasCompleted)
{
currentQuest = q;
}
}
// check for AVAILABLE quests
if (currentQuest == null)
{
foreach (Quest q in quests)
{
if (!q.hasStarted && !q.hasCompleted)
{
currentQuest = q;
}
}
}
}
// revert to default if no suitable quest found
if (currentQuest == null)
{
currentDialogue = defaultDialogue;
}
else
{
currentQuest.CheckComplete();
currentDialogue = new Dialogue();
currentDialogue.charName = defaultDialogue.charName;
// set up dialogue based on quest
if (currentQuest.hasStarted && !currentQuest.hasCompleted)
{
currentDialogue.sentences = currentQuest.duringText;
}
else if (!currentQuest.hasStarted && !currentQuest.hasCompleted)
{
currentDialogue.sentences = currentQuest.askText;
currentQuest.StartQuest();
}
else
{
currentDialogue.sentences = currentQuest.completionText;
}
}
}
public override void Interact()
{
if (!dialogue.isActive)
GameManager.Instance.DialogueManager.StartDialogue(dialogue);
if (currentDialogue == null || !currentDialogue.isActive)
{
DetermineDialogue();
GameManager.Instance.DialogueManager.StartDialogue(currentDialogue);
}
else
GameManager.Instance.DialogueManager.DisplayNextSentence();