mirror of
				https://github.com/DerTyp7/grow-ai-unity.git
				synced 2025-10-31 05:17:08 +01:00 
			
		
		
		
	init
This commit is contained in:
		
							
								
								
									
										39
									
								
								Assets/Scripts/House.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								Assets/Scripts/House.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| using System.Collections; | ||||
| using System.Collections.Generic; | ||||
| using UnityEngine; | ||||
|  | ||||
| public class House : MonoBehaviour | ||||
| { | ||||
|     [Header("House")] | ||||
|     [SerializeField] | ||||
|     int space = 1; | ||||
|  | ||||
|     [SerializeField] | ||||
|     List<Person> persons = new List<Person>(); | ||||
|  | ||||
|     [SerializeField] | ||||
|     City city; | ||||
|  | ||||
|     void Awake() | ||||
|     { | ||||
|         city.AddHouse(this); | ||||
|     } | ||||
|  | ||||
|     public void AddPerson(Person person) | ||||
|     { | ||||
|         if (!persons.Contains(person) && persons.Count < space) | ||||
|         { | ||||
|             persons.Add(person); | ||||
|             Debug.Log(person.GetFullName() + " now lives in house"); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void RemovePerson(Person person) | ||||
|     { | ||||
|         if (persons.Contains(person)) | ||||
|         { | ||||
|             persons.Remove(person); | ||||
|             Debug.Log(person.GetFullName() + " does not live in house anymore"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 j.mei7
					j.mei7