mirror of
https://github.com/DerTyp7/grow-ai-unity.git
synced 2025-10-30 12:57:09 +01:00
a
This commit is contained in:
43
Assets/Scripts/PlacedObjects/House.cs
Normal file
43
Assets/Scripts/PlacedObjects/House.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class House : PlacedObject
|
||||
{
|
||||
[Header("House")]
|
||||
[SerializeField]
|
||||
int space = 4;
|
||||
|
||||
[SerializeField]
|
||||
List<Person> persons = new List<Person>();
|
||||
|
||||
City city;
|
||||
|
||||
public int GetAvaiableSpace() => space - persons.Count;
|
||||
|
||||
public override void OnPlace()
|
||||
{
|
||||
city = GameObject.Find("GameManager").GetComponent<City>();
|
||||
city.AddHouse(this);
|
||||
}
|
||||
|
||||
public bool AddPerson(Person person)
|
||||
{
|
||||
if (!persons.Contains(person) && persons.Count < space)
|
||||
{
|
||||
persons.Add(person);
|
||||
Debug.Log(person.GetFullName() + " now lives in house");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void RemovePerson(Person person)
|
||||
{
|
||||
if (persons.Contains(person))
|
||||
{
|
||||
persons.Remove(person);
|
||||
Debug.Log(person.GetFullName() + " does not live in house anymore");
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/PlacedObjects/House.cs.meta
Normal file
11
Assets/Scripts/PlacedObjects/House.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5efcb4abb6526ca4fbbd130512bbc14d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
12
Assets/Scripts/PlacedObjects/Way.cs
Normal file
12
Assets/Scripts/PlacedObjects/Way.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Way : PlacedObject
|
||||
{
|
||||
public override void OnPlace()
|
||||
{
|
||||
Debug.Log("Placed Way");
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/PlacedObjects/Way.cs.meta
Normal file
11
Assets/Scripts/PlacedObjects/Way.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b31ffe74c8ae354abc084445ecb77b6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user