mirror of
https://github.com/DerTyp7/grow-ai-unity.git
synced 2025-10-30 21:07:09 +01:00
added freetime etc
This commit is contained in:
15
Assets/Scripts/FreeTime/FreeTimeObject.cs
Normal file
15
Assets/Scripts/FreeTime/FreeTimeObject.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class FreeTimeObject : MonoBehaviour
|
||||
{
|
||||
[Header("FreeTime Object")]
|
||||
[SerializeField] string FreeTimeObjectName;
|
||||
[SerializeField] City city;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
city.AddFreeTimeObject(this);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/FreeTime/FreeTimeObject.cs.meta
Normal file
11
Assets/Scripts/FreeTime/FreeTimeObject.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: adc5520d40289db41ae3b07650f6da07
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/FreeTime/Park.cs
Normal file
8
Assets/Scripts/FreeTime/Park.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Park : FreeTimeObject
|
||||
{
|
||||
|
||||
}
|
||||
11
Assets/Scripts/FreeTime/Park.cs.meta
Normal file
11
Assets/Scripts/FreeTime/Park.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7bc2527398280d14790a72191ef86c05
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
54
Assets/Scripts/FreeTime/Store.cs
Normal file
54
Assets/Scripts/FreeTime/Store.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Store : MonoBehaviour
|
||||
{
|
||||
[SerializeField] string storeName;
|
||||
[SerializeField] City city;
|
||||
[SerializeField] List<PersonIndicators> personIndicatorsInStore = new List<PersonIndicators>();
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
city.AddStore(this);
|
||||
TimeManager.OnMinuteUpdate += OnMinuteUpdate;
|
||||
}
|
||||
|
||||
void OnMinuteUpdate()
|
||||
{
|
||||
foreach (PersonIndicators personIndicator in personIndicatorsInStore)
|
||||
{
|
||||
personIndicator.IncreaseSupplied(0.05f);
|
||||
}
|
||||
}
|
||||
|
||||
void OnTriggerEnter2D(Collider2D collision)
|
||||
{
|
||||
if (collision != null)
|
||||
{
|
||||
if(collision.GetComponent<Person>() != null)
|
||||
{
|
||||
if(collision.GetComponent<Person>().status == PersonStatus.STORE)
|
||||
{
|
||||
personIndicatorsInStore.Add(collision.GetComponent<PersonIndicators>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit2D(Collider2D collision)
|
||||
{
|
||||
if (collision != null)
|
||||
{
|
||||
if (collision.GetComponent<Person>() != null)
|
||||
{
|
||||
if (personIndicatorsInStore.Contains(collision.GetComponent<PersonIndicators>()))
|
||||
{
|
||||
personIndicatorsInStore.Remove(collision.GetComponent<PersonIndicators>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/FreeTime/Store.cs.meta
Normal file
11
Assets/Scripts/FreeTime/Store.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca70058e52bdff8428269af9aeb78f80
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user