Hi, I'm trying to make a list based quest manager but I'm struggling to extract certain variables from the list.

I’m trying the make the code switch to the next quest when you reach the required amount of points for each quest. For some reason it’s not working and I really can’y work out why.

Any help would be great thanks!

Bit of script I’m trying to make work:

for (int i = currentPoints; i >= 0; i++)
        {
            if (Quests*.pointsRequired <= currentPoints)*

{
Debug.Log(“ping”);
currentQuestid += 1;
}
}
And the full script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class questManager : MonoBehaviour
{
public int currentQuestid;

[System.Serializable]
public class Quest
{
public int pointsRequired;
public GameObject objects;
public int questID;
public string objective;
public string pointName;
public string info;
public float waitTime;
public bool enabled = false;
public Text objectiveText;
public Text remainingText;
public Text infoText;
}

public Quest[] Quests;
public int currentPoints;
public float currentdelay;
public int required;

void Start()
{
currentQuestid = 0;
currentPoints = 0;

for (int i = 0; i < Quests.Length; i++)
{
Quests_.objectiveText.text = Quests*.objective;
}
}*_

void Update()
{
for (int i = 0; i < Quests.Length; i++)
{
Quests*.objects.SetActive(i == currentQuestid);*
}

for (int i = 0; i < Quests.Length; i++)
{
Quests.remainingText.text = Quests_.pointName + ": " + currentPoints + “/” + Quests*.pointsRequired;
}*_

for (int i = currentPoints; i >= 0; i++)
{
if (Quests*.pointsRequired <= currentPoints)*
{
Debug.Log(“ping”);
currentQuestid += 1;
}
}

}

Something like this should work. I added a ‘usedPoints’ variable so that quest don’t have accumulative points.

    public int currentQuest = 0;
    public int currentPoints = 0;
    public int usedPoints = 0;
    
    public bool IsQuestComplete(int questID)
    {
        bool results = false;

        // Assuming that the Quests don't have higher and higher points required.
        if( (currentPoints - usedPoints) >= quests[currentQuest].pointsRequired)
        {
            Debug.Log("Quest " + questID + " completed.");
            usedPoints += quests[currentQuest].pointsRequired;      // use up the points for this quest.
            results = true;           
        }
        return results;
    }

    // Call this when the current points change.
    public bool AllQuestsCompleted()
    {
        bool results = false;

        if(IsQuestComplete(currentQuest))
        {
            ++currentQuest;         // next quest.
            if(currentQuest >= quests.Length)
            {
                Debug.Log("All quests completed.");
                results = true;
            }
        }
        return results;
    }