mirror of
				https://github.com/DerTyp7/grow-ai-unity.git
				synced 2025-10-30 21:07:09 +01:00 
			
		
		
		
	init
This commit is contained in:
		
							
								
								
									
										66
									
								
								Assets/Scripts/Person.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								Assets/Scripts/Person.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,66 @@ | ||||
| using System.Collections; | ||||
| using System.Collections.Generic; | ||||
| using UnityEngine; | ||||
|  | ||||
| public class Person : MonoBehaviour | ||||
| { | ||||
|     [Header("Person")] | ||||
|     [SerializeField] | ||||
|     string firstName = ""; | ||||
|  | ||||
|     [SerializeField] | ||||
|     string lastName = ""; | ||||
|  | ||||
|     [SerializeField] | ||||
|     City city; | ||||
|  | ||||
|     [SerializeField] | ||||
|     House house; | ||||
|  | ||||
|     [SerializeField] | ||||
|     Workplace workplace; | ||||
|  | ||||
|     TimeManager timeManager; | ||||
|     PersonMovement movement; | ||||
|  | ||||
|     public string GetFirstName() => firstName; | ||||
|     public string GetLastName() => lastName; | ||||
|     public string GetFullName() => firstName + " " + lastName; | ||||
|  | ||||
|     void Awake() | ||||
|     { | ||||
|         city.AddCitizen(this); | ||||
|         house.AddPerson(this); | ||||
|         workplace.AddWorker(this); | ||||
|     } | ||||
|  | ||||
|     void Start() | ||||
|     { | ||||
|         timeManager = GameObject.Find("GameManager").GetComponent<TimeManager>(); | ||||
|         movement = GetComponent<PersonMovement>(); | ||||
|  | ||||
|         TimeManager.OnTimeInterval += OnTimeInterval; | ||||
|     } | ||||
|  | ||||
|     void OnTimeInterval() | ||||
|     { | ||||
|         switch (timeManager.partOfDay) | ||||
|         { | ||||
|             case TimeManager.PartOfDay.NIGHT: | ||||
|                 movement.SetTarget(house.transform); | ||||
|                 break; | ||||
|             case TimeManager.PartOfDay.MORNING: | ||||
|                 movement.SetTarget(workplace.transform); | ||||
|                 break; | ||||
|             case TimeManager.PartOfDay.AFTERNOON: | ||||
|                 movement.SetTarget(workplace.transform); | ||||
|                 break; | ||||
|             case TimeManager.PartOfDay.EVENING: | ||||
|                 movement.SetTarget(city.transform); | ||||
|                 break; | ||||
|             default: | ||||
|                 movement.SetTarget(city.transform); | ||||
|                 break; | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 j.mei7
					j.mei7