2026-06-12 11:36:57 +01:00
|
|
|
using UnityEngine;
|
|
|
|
|
using TMPro;
|
|
|
|
|
|
|
|
|
|
public class UIController : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public static UIController Instance;
|
|
|
|
|
|
|
|
|
|
[SerializeField] TextMeshProUGUI wood, stone, population;
|
|
|
|
|
|
|
|
|
|
void Awake()
|
|
|
|
|
{
|
|
|
|
|
Instance = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
UpdateStats();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateStats()
|
|
|
|
|
{
|
|
|
|
|
wood.text = GameManager.Instance.GetResource(Resource.ResourceType.Wood).ToString();
|
|
|
|
|
stone.text = GameManager.Instance.GetResource(Resource.ResourceType.Stone).ToString();
|
2026-06-12 12:00:15 +01:00
|
|
|
population.text = GameManager.Instance.GetResource(Resource.ResourceType.Population).ToString();
|
2026-06-12 11:36:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Called by left-clicking a JobButton
|
|
|
|
|
public void AddJob(NPC.Job jobToAssign)
|
|
|
|
|
{
|
|
|
|
|
NPC[] npcs = FindObjectsByType<NPC>(FindObjectsSortMode.None);
|
|
|
|
|
foreach(NPC npc in npcs)
|
|
|
|
|
{
|
|
|
|
|
// Find a Citizen and give them the new job
|
|
|
|
|
if(npc.job == NPC.Job.Citizen)
|
|
|
|
|
{
|
|
|
|
|
npc.SetJob(jobToAssign);
|
|
|
|
|
Debug.Log($"Assigned a Citizen to {jobToAssign}");
|
|
|
|
|
break; // Stop after assigning one
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Called by right-clicking a JobButton
|
|
|
|
|
public void RemoveJob(NPC.Job jobToRemove)
|
|
|
|
|
{
|
|
|
|
|
NPC[] npcs = FindObjectsByType<NPC>(FindObjectsSortMode.None);
|
|
|
|
|
foreach(NPC npc in npcs)
|
|
|
|
|
{
|
|
|
|
|
// Find an NPC currently doing this job and revert them to a Citizen
|
|
|
|
|
if(npc.job == jobToRemove)
|
|
|
|
|
{
|
|
|
|
|
npc.SetJob(NPC.Job.Citizen);
|
|
|
|
|
Debug.Log($"Removed a {jobToRemove} and made them a Citizen");
|
|
|
|
|
break; // Stop after removing one
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|