Files
CityBuilder/Assets/Scripts/Objectives.cs
SHOUTING_PIRATE 1c91215efd initial commit
2025-07-07 20:59:04 +01:00

59 lines
1.9 KiB
C#

using UnityEngine;
using TMPro;
public class Objectives : MonoBehaviour
{
public static Objectives Instance { get; private set; }
void Awake()
{
Instance = this;
}
public TextMeshProUGUI objectiveText;
public TextMeshProUGUI objectiveDescriptionText;
public TextMeshProUGUI objectiveProgressText;
public string currentObjective;
public string currentObjectiveDescription;
public string[] objectives;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
objectiveText.text = "Objective: " + currentObjective;
//objectiveDescriptionText.text = currentObjectiveDescription;
//objectiveProgressText.text = "Progress: 0%";
// Initialize with the first objective if available
if (objectives.Length > 0)
{
currentObjective = objectives[0];
//currentObjectiveDescription = "Complete the first objective.";
UpdateObjective(currentObjective, currentObjectiveDescription, 0);
}
else
{
Debug.LogWarning("No objectives defined.");
}
}
// Update is called once per frame
void Update()
{
UpdateObjective(currentObjective, currentObjectiveDescription, 0);
}
public void UpdateObjective(string objective, string description, int progress)
{
currentObjective = objective;
//currentObjectiveDescription = description;
objectiveText.text = "Objective: " + currentObjective;
//objectiveDescriptionText.text = currentObjectiveDescription;
//objectiveProgressText.text = "Progress: " + progress + "%";
}
public void ProgressObjective(int progress)
{
// Assuming progress is a percentage value between 0 and 100
objectiveProgressText.text = "Progress: " + progress + "%";
}
}