mirror of
				https://github.com/DerTyp7/grow-ai-unity.git
				synced 2025-10-31 05:17:08 +01:00 
			
		
		
		
	a
This commit is contained in:
		
							
								
								
									
										36
									
								
								Assets/Scripts/Managers/PersonManager.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								Assets/Scripts/Managers/PersonManager.cs
									
									
									
									
									
										Normal 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); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 j.mei7
					j.mei7