This commit is contained in:
j.mei7
2022-03-16 18:16:19 +01:00
parent eb71cdbc9d
commit 2e92ba6ea4
41 changed files with 596 additions and 449 deletions

View File

@@ -0,0 +1,36 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PersonManager : MonoBehaviour
{
City city;
[SerializeField] GameObject personPrefab;
void Start()
{
city = GetComponent<City>();
TimeManager.OnDayUpdate += OnDayUpdate;
}
void OnDayUpdate()
{
int avaiableSpace = city.GetAvaiableHousingSpace();
if (avaiableSpace > 5)
{
SpawnPerson(5);
}
else
{
SpawnPerson(avaiableSpace);
}
}
public void SpawnPerson(int count = 1)
{
for(int i = 0; i < count; i++)
{
Instantiate(personPrefab);
}
}
}