로직 데이터 연동 시작
This commit is contained in:
39
Assets/Scripts/SimulationModels/SimulationModelStore.cs
Normal file
39
Assets/Scripts/SimulationModels/SimulationModelStore.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RTG;
|
||||
public class SimulationModelStore : SimulationModel
|
||||
{
|
||||
public List<Transform> storePositions = new List<Transform>();
|
||||
public int maxCapacity;
|
||||
public List<GameObject> storedProducts = new List<GameObject>();
|
||||
public string storeType = "fifo";
|
||||
public void StoreProduct(GameObject product)
|
||||
{
|
||||
List<Transform> list = storePositions.FindAll(t => t.childCount == 0);
|
||||
product.transform.parent = list[UnityEngine.Random.Range(0, list.Count)];
|
||||
product.transform.localPosition = Vector3.zero;
|
||||
product.transform.localRotation = Quaternion.identity;
|
||||
storedProducts.Add(product);
|
||||
if (storedProducts.Count > maxCapacity)
|
||||
Debug.LogWarning("Max Capacity Reached on : " + nodeID);
|
||||
}
|
||||
public GameObject GetProduct()
|
||||
{
|
||||
if (storedProducts.Count == 0)
|
||||
return null;
|
||||
if (storeType.Contains("fifo"))
|
||||
{
|
||||
GameObject product = storedProducts[0];
|
||||
storedProducts.Remove(product);
|
||||
return product;
|
||||
}
|
||||
else if (storeType.Contains("lifo"))
|
||||
{
|
||||
GameObject product = storedProducts[storedProducts.Count - 1];
|
||||
storedProducts.Remove(product);
|
||||
return product;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user