mirror of
https://github.com/DerTyp7/grow-ai-unity.git
synced 2025-10-30 12:57:09 +01:00
init
This commit is contained in:
42
Assets/Scripts/Workplace.cs
Normal file
42
Assets/Scripts/Workplace.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Workplace : MonoBehaviour
|
||||
{
|
||||
[Header("Workplace")]
|
||||
[SerializeField]
|
||||
int space = 1;
|
||||
|
||||
[SerializeField]
|
||||
float salary = 4.5f;
|
||||
|
||||
[SerializeField]
|
||||
List<Person> workers = new List<Person>();
|
||||
|
||||
[SerializeField]
|
||||
City city;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
city.AddWorkplace(this);
|
||||
}
|
||||
|
||||
public void AddWorker(Person worker)
|
||||
{
|
||||
if (!workers.Contains(worker) && workers.Count < space)
|
||||
{
|
||||
workers.Add(worker);
|
||||
Debug.Log(worker.GetFullName() + " now works");
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveWorker(Person worker)
|
||||
{
|
||||
if (workers.Contains(worker))
|
||||
{
|
||||
workers.Remove(worker);
|
||||
Debug.Log(worker.GetFullName() + " does not work anymore");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user