2026-06-11 17:30:53 +01:00
|
|
|
using UnityEngine;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class GameManager : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public Dictionary<Resource.ResourceType, int> statistics = new Dictionary<Resource.ResourceType, int>();
|
|
|
|
|
public static GameManager Instance;
|
2026-06-12 12:00:15 +01:00
|
|
|
[SerializeField]private float money, population, wood, stone, metal;
|
2026-06-11 17:30:53 +01:00
|
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
|
|
|
void Awake()
|
|
|
|
|
{
|
|
|
|
|
Instance = this;
|
2026-06-12 12:00:15 +01:00
|
|
|
CalculatePopulation();
|
2026-06-11 17:30:53 +01:00
|
|
|
}
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2026-06-12 12:00:15 +01:00
|
|
|
|
2026-06-11 17:30:53 +01:00
|
|
|
}
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public void AddResource(Resource.ResourceType resourceToAdd, int amountToAdd)
|
|
|
|
|
{
|
|
|
|
|
switch (resourceToAdd)
|
|
|
|
|
{
|
|
|
|
|
case Resource.ResourceType.Wood:
|
|
|
|
|
wood += amountToAdd;
|
|
|
|
|
break;
|
|
|
|
|
case Resource.ResourceType.Stone:
|
|
|
|
|
stone += amountToAdd;
|
|
|
|
|
break;
|
|
|
|
|
case Resource.ResourceType.Metal:
|
|
|
|
|
metal += amountToAdd;
|
|
|
|
|
break;
|
|
|
|
|
case Resource.ResourceType.Money:
|
|
|
|
|
money += amountToAdd;
|
|
|
|
|
break;
|
2026-06-12 12:00:15 +01:00
|
|
|
case Resource.ResourceType.Population:
|
|
|
|
|
population += amountToAdd;
|
2026-06-11 17:30:53 +01:00
|
|
|
break;
|
|
|
|
|
}
|
2026-06-12 16:30:41 +01:00
|
|
|
statistics[resourceToAdd] += amountToAdd;
|
|
|
|
|
UIController.Instance.UpdateStats();
|
2026-06-11 17:30:53 +01:00
|
|
|
}
|
2026-06-12 16:30:41 +01:00
|
|
|
|
2026-06-11 17:30:53 +01:00
|
|
|
public float GetResource(Resource.ResourceType resourceToGet)
|
|
|
|
|
{
|
|
|
|
|
switch (resourceToGet)
|
|
|
|
|
{
|
|
|
|
|
case Resource.ResourceType.Wood:
|
|
|
|
|
return wood;
|
|
|
|
|
case Resource.ResourceType.Stone:
|
|
|
|
|
return stone;
|
|
|
|
|
case Resource.ResourceType.Metal:
|
|
|
|
|
return metal;
|
|
|
|
|
case Resource.ResourceType.Money:
|
|
|
|
|
return money;
|
2026-06-12 12:00:15 +01:00
|
|
|
case Resource.ResourceType.Population:
|
|
|
|
|
return population;
|
2026-06-11 17:30:53 +01:00
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2026-06-12 12:00:15 +01:00
|
|
|
public void CalculatePopulation()
|
|
|
|
|
{
|
|
|
|
|
NPC[] npcs = FindObjectsByType<NPC>(FindObjectsSortMode.None);
|
|
|
|
|
AddResource(Resource.ResourceType.Population, npcs.Length);
|
|
|
|
|
}
|
|
|
|
|
public Building[] CountBuildings()
|
|
|
|
|
{
|
|
|
|
|
Building[] buildings = FindObjectsByType<Building>(FindObjectsSortMode.None);
|
|
|
|
|
return buildings;
|
|
|
|
|
}
|
2026-06-11 17:30:53 +01:00
|
|
|
}
|