struct and stepping? (quest line)
Hi, I would like to create a Quest Line scriptable object.
point: To have a quickly made questline, as my quests are scriptableObjects as wel..
I would Like to make a structure, which has several elements, and if a quest is complete, it goes to the next line in the structure, picking up the next quest available.
Could you please help me out or point me in the right direction?
Have you looked into a List or Array which points to separate Quests, along with an integer index that points to the current one, to be increased when completed?
really good Idea, but this would mean I need to have an ID for each quest isn't it?
You could use your ScriptableObject file path & name itself as Id. It is guaranteed to be unique, after all.
Answer by lagzilajcsi · Feb 16, 2020 at 03:45 PM
So my concept was:
Quest Handler - a monobehaviour class which handles the quests, which quest is selected at the moment in the questline, can be placed on the player.
Questline - a scripltable object so i can create several questlines
Quest - a scriptable object which is basically the quest itself.
So I am halfway there but I will publish the solution regarding my question:
Quest Handler
public class QuestHandler : MonoBehaviour { public Quest quest; public Questline questline;
public int QuestlineIndex;
public void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
NextQuest();
}
public void NextQuest()
{
if (QuestlineIndex < questline.QuestLines.Length)
{
DisplayNextQuest();
Debug.Log(quest);
QuestlineIndex += 1;
} else {
QuestlineIndex = 0;
}
}
public void DisplayNextQuest()
{
QuestLine line = questline.QuestLines[QuestlineIndex];
quest = line.quest;
}
**Questline**
[CreateAssetMenu(fileName = "New Questline", menuName= "Inventory System/Quest/new Questline")] [System.Serializable] public class Questline : ScriptableObject {
public QuestLine[] QuestLines; }
[System.Serializable] public struct QuestLine {
public Quest quest; }
**Quest**
public enum QuestType
{
Cook
}
[System.Serializable]
public class Quest : ScriptableObject
{
public int ID;
public QuestType type;
public ItemObject toCook;
public int howMuchToGather;
}
I will update if I have the full system :)