knowledge-representation #3

Merged
s452618 merged 4 commits from knowledge-representation into master 2021-04-07 20:32:24 +02:00
83 changed files with 336 additions and 261 deletions
Showing only changes of commit 27face68bc - Show all commits

View File

@ -54,24 +54,26 @@
<ItemGroup>
<Compile Include="Assets\Logic\UI\UIInventoryManager.cs" />
<Compile Include="Assets\Logic\Agent\Agent.cs" />
<Compile Include="Assets\Logic\Inventory\ItemIngredient.cs" />
<Compile Include="Assets\Logic\Data\RecipeIngredient.cs" />
<Compile Include="Assets\Logic\Utils\FloatComparer.cs" />
<Compile Include="Assets\Logic\UI\UITableComponent.cs" />
<Compile Include="Assets\Logic\SceneContext.cs" />
<Compile Include="Assets\Logic\UIManager.cs" />
<Compile Include="Assets\Logic\UI\UITableManager.cs" />
<Compile Include="Assets\Logic\UI\UIInventorySlot.cs" />
<Compile Include="Assets\Logic\Inventory\FoodObject.cs" />
<Compile Include="Assets\Logic\Data\RecipeObject.cs" />
<Compile Include="Assets\Logic\KitchenTableManager.cs" />
<Compile Include="Assets\Logic\UI\UIQueueManager.cs" />
<Compile Include="Assets\Logic\UI\UIQueue.cs" />
<Compile Include="Assets\Logic\Inventory\ItemObject.cs" />
<Compile Include="Assets\Logic\Data\Recipe.cs" />
<Compile Include="Assets\Logic\Graph\Table.cs" />
<Compile Include="Assets\Logic\Graph\Node.cs" />
<Compile Include="Assets\Logic\Graph\CustomerTable.cs" />
<Compile Include="Assets\Logic\CustomerTableManager.cs" />
<Compile Include="Assets\Logic\Inventory\WaitressInventory.cs" />
<Compile Include="Assets\Logic\Graph\KitchenTable.cs" />
<Compile Include="Assets\Logic\Data\Customer.cs" />
<Compile Include="Assets\Logic\Utils\Randomizer.cs" />
<None Include="Assets\Graphics\Shaders\Food.shader" />
<Reference Include="UnityEngine">
<HintPath>C:/Program Files/Unity/Hub/Editor/2020.2.7f1/Editor/Data/Managed/UnityEngine/UnityEngine.dll</HintPath>

View File

@ -1,8 +1,8 @@
fileFormatVersion: 2
guid: 7074f5128807cdd438aa4b38bb27f420
NativeFormatImporter:
guid: 6d42fd2e8cfe1e34a81ae5bdb4388fc5
folderAsset: yes
DefaultImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,78 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: goldCoin_Diffuse
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _NORMALMAP
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

View File

@ -1,8 +1,8 @@
fileFormatVersion: 2
guid: ed8072f279e1e80499c93d10689b7d23
guid: 8b457c38c89c4f54c8cf493a842b82b7
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,22 +1,22 @@
using Assets.Logic.Utils;
using System.Collections;
using System.Linq;
using Logic.Graph;
using Logic.Utils;
using UnityEngine;
namespace Assets.Logic.Agent
namespace Logic.Agent
{
public class Agent : MonoBehaviour
{
public Node ActualNode;
private Node previousNode;
private bool canMove = true; //temporary
public Node actualNode;
private Node _previousNode;
private bool _canMove = true; //temporary
void Update()
{
//temporary
if (!canMove) return;
if (ActualNode is Table table)
if (!_canMove) return;
if (actualNode is Table table)
{
if (table is KitchenTable kitchenTable)
{
@ -29,13 +29,13 @@ namespace Assets.Logic.Agent
{
if (Input.GetKeyDown(KeyCode.Space))
{
customerTable.HandleSpace();
customerTable.HandleSpaceClick();
}
}
if (Input.GetKeyDown(KeyCode.Escape) && previousNode != null)
if (Input.GetKeyDown(KeyCode.Escape) && _previousNode != null)
{
StartCoroutine(RunToAnotherNode(previousNode));
StartCoroutine(RunToAnotherNode(_previousNode));
}
}
else
@ -44,32 +44,32 @@ namespace Assets.Logic.Agent
{
if (transform.rotation.eulerAngles.y.IsEq(0,2))
{
var node = ActualNode.neighbors.FirstOrDefault(x =>
x.transform.position.x.IsEq(ActualNode.transform.position.x) &&
x.transform.position.z > ActualNode.transform.position.z);
var node = actualNode.neighbors.FirstOrDefault(x =>
x.transform.position.x.IsEq(actualNode.transform.position.x) &&
x.transform.position.z > actualNode.transform.position.z);
if (node != null) StartCoroutine(RunToAnotherNode(node));
}
if (transform.rotation.eulerAngles.y.IsEq(180, 2))
{
var node = ActualNode.neighbors.FirstOrDefault(x =>
x.transform.position.x.IsEq(ActualNode.transform.position.x) &&
x.transform.position.z < ActualNode.transform.position.z);
var node = actualNode.neighbors.FirstOrDefault(x =>
x.transform.position.x.IsEq(actualNode.transform.position.x) &&
x.transform.position.z < actualNode.transform.position.z);
if (node != null) StartCoroutine(RunToAnotherNode(node));
}
if (transform.rotation.eulerAngles.y.IsEq(90, 2))
{
var node = ActualNode.neighbors.FirstOrDefault(x =>
x.transform.position.z.IsEq(ActualNode.transform.position.z) &&
x.transform.position.x > ActualNode.transform.position.x);
var node = actualNode.neighbors.FirstOrDefault(x =>
x.transform.position.z.IsEq(actualNode.transform.position.z) &&
x.transform.position.x > actualNode.transform.position.x);
if (node != null) StartCoroutine(RunToAnotherNode(node));
}
if (transform.rotation.eulerAngles.y.IsEq(270, 2))
{
var node = ActualNode.neighbors.FirstOrDefault(x =>
x.transform.position.z.IsEq(ActualNode.transform.position.z) &&
x.transform.position.x < ActualNode.transform.position.x);
var node = actualNode.neighbors.FirstOrDefault(x =>
x.transform.position.z.IsEq(actualNode.transform.position.z) &&
x.transform.position.x < actualNode.transform.position.x);
if (node != null) StartCoroutine(RunToAnotherNode(node));
}
}
@ -77,32 +77,32 @@ namespace Assets.Logic.Agent
{
if (transform.rotation.eulerAngles.y.IsEq(0, 1))
{
var node = ActualNode.neighbors.FirstOrDefault(x =>
x.transform.position.x.IsEq(ActualNode.transform.position.x) &&
x.transform.position.z < ActualNode.transform.position.z);
var node = actualNode.neighbors.FirstOrDefault(x =>
x.transform.position.x.IsEq(actualNode.transform.position.x) &&
x.transform.position.z < actualNode.transform.position.z);
if (node != null) StartCoroutine(RunToAnotherNode(node));
}
if (transform.rotation.eulerAngles.y.IsEq(180, 1))
{
var node = ActualNode.neighbors.FirstOrDefault(x =>
x.transform.position.x.IsEq(ActualNode.transform.position.x) &&
x.transform.position.z > ActualNode.transform.position.z);
var node = actualNode.neighbors.FirstOrDefault(x =>
x.transform.position.x.IsEq(actualNode.transform.position.x) &&
x.transform.position.z > actualNode.transform.position.z);
if (node != null) StartCoroutine(RunToAnotherNode(node));
}
if (transform.rotation.eulerAngles.y.IsEq(90, 1))
{
var node = ActualNode.neighbors.FirstOrDefault(x =>
x.transform.position.z.IsEq(ActualNode.transform.position.z) &&
x.transform.position.x < ActualNode.transform.position.x);
var node = actualNode.neighbors.FirstOrDefault(x =>
x.transform.position.z.IsEq(actualNode.transform.position.z) &&
x.transform.position.x < actualNode.transform.position.x);
if (node != null) StartCoroutine(RunToAnotherNode(node));
}
if (transform.rotation.eulerAngles.y.IsEq(270, 1))
{
var node = ActualNode.neighbors.FirstOrDefault(x =>
x.transform.position.z.IsEq(ActualNode.transform.position.z) &&
x.transform.position.x > ActualNode.transform.position.x);
var node = actualNode.neighbors.FirstOrDefault(x =>
x.transform.position.z.IsEq(actualNode.transform.position.z) &&
x.transform.position.x > actualNode.transform.position.x);
if (node != null) StartCoroutine(RunToAnotherNode(node));
}
}
@ -110,32 +110,32 @@ namespace Assets.Logic.Agent
{
if (transform.rotation.eulerAngles.y.IsEq(0, 1))
{
var node = ActualNode.neighbors.FirstOrDefault(x =>
x.transform.position.z.IsEq(ActualNode.transform.position.z) &&
x.transform.position.x > ActualNode.transform.position.x);
var node = actualNode.neighbors.FirstOrDefault(x =>
x.transform.position.z.IsEq(actualNode.transform.position.z) &&
x.transform.position.x > actualNode.transform.position.x);
if (node != null) StartCoroutine(RunToAnotherNode(node));
}
if (transform.rotation.eulerAngles.y.IsEq(180, 1))
{
var node = ActualNode.neighbors.FirstOrDefault(x =>
x.transform.position.z.IsEq(ActualNode.transform.position.z) &&
x.transform.position.x < ActualNode.transform.position.x);
var node = actualNode.neighbors.FirstOrDefault(x =>
x.transform.position.z.IsEq(actualNode.transform.position.z) &&
x.transform.position.x < actualNode.transform.position.x);
if (node != null) StartCoroutine(RunToAnotherNode(node));
}
if (transform.rotation.eulerAngles.y.IsEq(90, 1))
{
var node = ActualNode.neighbors.FirstOrDefault(x =>
x.transform.position.x.IsEq(ActualNode.transform.position.x) &&
x.transform.position.z < ActualNode.transform.position.z);
var node = actualNode.neighbors.FirstOrDefault(x =>
x.transform.position.x.IsEq(actualNode.transform.position.x) &&
x.transform.position.z < actualNode.transform.position.z);
if (node != null) StartCoroutine(RunToAnotherNode(node));
}
if (transform.rotation.eulerAngles.y.IsEq(270, 1))
{
var node = ActualNode.neighbors.FirstOrDefault(x =>
x.transform.position.x.IsEq(ActualNode.transform.position.x) &&
x.transform.position.z > ActualNode.transform.position.z);
var node = actualNode.neighbors.FirstOrDefault(x =>
x.transform.position.x.IsEq(actualNode.transform.position.x) &&
x.transform.position.z > actualNode.transform.position.z);
if (node != null) StartCoroutine(RunToAnotherNode(node));
}
}
@ -143,32 +143,32 @@ namespace Assets.Logic.Agent
{
if (transform.rotation.eulerAngles.y.IsEq(0, 1))
{
var node = ActualNode.neighbors.FirstOrDefault(x =>
x.transform.position.z.IsEq(ActualNode.transform.position.z) &&
x.transform.position.x < ActualNode.transform.position.x);
var node = actualNode.neighbors.FirstOrDefault(x =>
x.transform.position.z.IsEq(actualNode.transform.position.z) &&
x.transform.position.x < actualNode.transform.position.x);
if (node != null) StartCoroutine(RunToAnotherNode(node));
}
if (transform.rotation.eulerAngles.y.IsEq(180, 1))
{
var node = ActualNode.neighbors.FirstOrDefault(x =>
x.transform.position.z.IsEq(ActualNode.transform.position.z) &&
x.transform.position.x > ActualNode.transform.position.x);
var node = actualNode.neighbors.FirstOrDefault(x =>
x.transform.position.z.IsEq(actualNode.transform.position.z) &&
x.transform.position.x > actualNode.transform.position.x);
if (node != null) StartCoroutine(RunToAnotherNode(node));
}
if (transform.rotation.eulerAngles.y.IsEq(90, 1))
{
var node = ActualNode.neighbors.FirstOrDefault(x =>
x.transform.position.x.IsEq(ActualNode.transform.position.x) &&
x.transform.position.z > ActualNode.transform.position.z);
var node = actualNode.neighbors.FirstOrDefault(x =>
x.transform.position.x.IsEq(actualNode.transform.position.x) &&
x.transform.position.z > actualNode.transform.position.z);
if (node != null) StartCoroutine(RunToAnotherNode(node));
}
if (transform.rotation.eulerAngles.y.IsEq(270, 1))
{
var node = ActualNode.neighbors.FirstOrDefault(x =>
x.transform.position.x.IsEq(ActualNode.transform.position.x) &&
x.transform.position.z < ActualNode.transform.position.z);
var node = actualNode.neighbors.FirstOrDefault(x =>
x.transform.position.x.IsEq(actualNode.transform.position.x) &&
x.transform.position.z < actualNode.transform.position.z);
if (node != null) StartCoroutine(RunToAnotherNode(node));
}
}
@ -177,7 +177,7 @@ namespace Assets.Logic.Agent
private IEnumerator RunToAnotherNode(Node destination)
{
canMove = false;
_canMove = false;
var location = destination.GetComponent<Transform>().position;
var targetPoint = new Vector3(location.x, transform.position.y, location.z) - transform.position;
@ -206,9 +206,9 @@ namespace Assets.Logic.Agent
transform.position = new Vector3(location.x, transform.position.y, location.z);
}
previousNode = ActualNode;
ActualNode = destination;
canMove = true;
_previousNode = actualNode;
actualNode = destination;
_canMove = true;
}
}
}

View File

@ -1,22 +1,26 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Logic.Data;
using Logic.Graph;
using Logic.Inventory.Scripts;
using Logic.Utils;
using UnityEngine;
using Random = UnityEngine.Random;
namespace Logic
{
public class CustomerTableManager: MonoBehaviour
{
#region Singleton
public static CustomerTableManager Instance;
public int customerSpawnTime = 10;
[SerializeField] private List<CustomerTable> customerTables;
[SerializeField] private List<Recipe> availableRecipes;
private void Awake()
{
Instance = this;
availableRecipes = Resources.LoadAll<ItemObject>("Items").ToList();
availableRecipes = Resources.LoadAll<Recipe>("Items").ToList();
customerTables = GetComponentsInChildren<CustomerTable>().ToList();
int i = 0;
foreach (CustomerTable table in customerTables)
@ -26,12 +30,6 @@ namespace Logic
}
}
#endregion
public int customerSpawnTime = 10;
[SerializeField] private List<CustomerTable> customerTables;
[SerializeField] private List<ItemObject> availableRecipes;
private void Start()
{
StartCoroutine(HandleCustomerSpawn(customerSpawnTime));
@ -44,6 +42,10 @@ namespace Logic
int randomTableNumber = Random.Range(0, customerTables.Count);
if (customerTables[randomTableNumber].state == TableState.Empty)
{
AllergenType allergenType = Randomizer.GetRandomEnumElement<AllergenType>();
int maxCalories = Randomizer.GetRandomIntInRange(400, 700);
customerTables[randomTableNumber].Customer = new Customer(allergenType, maxCalories);
customerTables[randomTableNumber].state = TableState.WaitingForMenu;
UIManager.Instance.uiTableManager.ChangeStatus(randomTableNumber, TableState.WaitingForMenu);
}
@ -51,7 +53,7 @@ namespace Logic
}
}
public ItemObject GetRandomRecipe()
public Recipe GetRandomRecipe()
{
return availableRecipes[Random.Range(0, availableRecipes.Count)];
}

3
Assets/Logic/Data.meta Normal file
View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a759d3ff90f0402b8c991e705f06c815
timeCreated: 1617124677

View File

@ -0,0 +1,18 @@
using System;
namespace Logic.Data
{
[Serializable]
public class Customer
{
public AllergenType allergenType;
public int maxCalories;
public Customer(AllergenType allergenType, int maxCalories)
{
this.allergenType = allergenType;
this.maxCalories = maxCalories;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 77bfec7377fd428fa9bcc05ce572dbc5
timeCreated: 1617124273

View File

@ -1,26 +1,33 @@
using System;
using System.Collections.Generic;
using UnityEngine;
public enum ItemType
namespace Logic.Data
{
Food,
Recipe,
Money
}
namespace Logic.Inventory.Scripts
{
public abstract class ItemObject : ScriptableObject
public enum ItemType
{
Food,
Recipe,
Money
}
public abstract class Recipe : ScriptableObject
{
private void Awake()
{
type = ItemType.Food;
}
public GameObject foodPrefab;
public Sprite foodIcon;
public Sprite recipeIcon;
public Sprite moneyIcon;
public ItemType type;
public int forTable;
public string itemName;
public int cost;
public int kcal;
public List<ItemIngredient> ingredients;
public List<RecipeIngredient> ingredients;
}
}

View File

@ -1,4 +1,4 @@
namespace Logic.Inventory
namespace Logic.Data
{
public enum IngredientType
{
@ -15,7 +15,7 @@ namespace Logic.Inventory
}
[System.Serializable]
public struct ItemIngredient
public struct RecipeIngredient
{
public string ingredientName;
public IngredientType type;

View File

@ -0,0 +1,13 @@
using UnityEngine;
namespace Logic.Data
{
[CreateAssetMenu(fileName = "New Recipe Object", menuName = "Inventory/Recipe")]
public class RecipeObject : Recipe
{
public void Awake()
{
type = ItemType.Food;
}
}
}

View File

@ -1,5 +1,6 @@
using System.Collections;
using Logic.Inventory.Scripts;
using Logic.Data;
using Logic.Inventory;
using UnityEngine;
namespace Logic.Graph
@ -14,15 +15,17 @@ namespace Logic.Graph
Eating = 5,
WaitingForPay = 6
}
public class CustomerTable : Table
{
public TableState state;
public Customer Customer;
public bool recipeReady;
private Coroutine _prepareRecipeCoroutine;
private Coroutine _eatMealCoroutine;
public void HandleSpace()
public void HandleSpaceClick()
{
switch (state)
{
@ -70,10 +73,10 @@ namespace Logic.Graph
{
if (recipeReady)
{
ItemObject item = GETRecipe();
Recipe item = GETRecipe();
item.forTable = tableNumber;
item.type = ItemType.Recipe;
bool isSuccess = WaitressInventory.instance.AddItem(item);
bool isSuccess = WaitressInventory.Instance.AddItem(item);
if (isSuccess)
{
ClearItemObject();
@ -87,12 +90,12 @@ namespace Logic.Graph
private void HandleFoodDelivery()
{
ItemObject meal = WaitressInventory.instance.GETMealForTable(tableNumber);
Recipe meal = WaitressInventory.Instance.GETMealForTable(tableNumber);
if (meal != null)
{
currentItem = meal;
Spawn();
WaitressInventory.instance.RemoveItem(meal);
WaitressInventory.Instance.RemoveItem(meal);
_eatMealCoroutine = StartCoroutine(HandleEatMeal(3));
state = TableState.Eating;
UIManager.Instance.uiTableManager

View File

@ -2,7 +2,8 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Logic.Inventory.Scripts;
using Logic.Data;
using Logic.Inventory;
using Logic.UI;
using UnityEngine;
@ -19,8 +20,8 @@ namespace Logic.Graph
public void HandleSpace()
{
List<ItemObject> foodToPrepare = WaitressInventory.instance.GetRecipes();
foreach (ItemObject foodObject in foodToPrepare)
List<Recipe> foodToPrepare = WaitressInventory.Instance.GetRecipes();
foreach (Recipe foodObject in foodToPrepare)
{
foodObject.type = ItemType.Food;
KitchenTableManager.Instance.AddToQueue(foodObject, QueueType.ProgressQueue);
@ -28,8 +29,8 @@ namespace Logic.Graph
if (isFull)
{
ItemObject item = GETRecipe();
bool isSuccess = WaitressInventory.instance.AddItem(item);
Recipe item = GETRecipe();
bool isSuccess = WaitressInventory.Instance.AddItem(item);
if (isSuccess)
{
ClearItemObject();

View File

@ -1,4 +1,4 @@
using Logic.Inventory.Scripts;
using Logic.Data;
using UnityEngine;
namespace Logic.Graph
@ -8,12 +8,12 @@ namespace Logic.Graph
[SerializeField] private GameObject recipePrefab;
[SerializeField] private GameObject moneyPrefab;
[SerializeField] private GameObject spawnPoint;
public ItemObject currentItem;
public Recipe currentItem;
public int tableNumber;
public bool isFull;
public ItemObject GETRecipe()
public Recipe GETRecipe()
{
return currentItem;
}
@ -27,7 +27,7 @@ namespace Logic.Graph
protected void Spawn()
{
if (isFull && currentItem != null) return;
var itemObject = new GameObject();
GameObject itemObject;
if (currentItem.type == ItemType.Recipe)
{
itemObject = Instantiate(recipePrefab, spawnPoint.transform);

View File

@ -1,14 +0,0 @@
using Logic.Inventory.Scripts;
using UnityEngine;
namespace Logic.Inventory
{
[CreateAssetMenu(fileName = "New Food Object", menuName = "Inventory/Items/Food")]
public class FoodObject : ItemObject
{
public void Awake()
{
type = ItemType.Food;
}
}
}

View File

@ -1,41 +1,38 @@
using System.Collections.Generic;
using System.Linq;
using Logic.Data;
using UnityEngine;
namespace Logic.Inventory.Scripts
namespace Logic.Inventory
{
public class WaitressInventory : MonoBehaviour
{
#region Singleton
public static WaitressInventory instance;
public static WaitressInventory Instance;
private void Awake()
{
instance = this;
Instance = this;
}
#endregion
[SerializeField]
private List<ItemObject> container = new List<ItemObject>();
[SerializeField] private List<Recipe> container = new List<Recipe>();
private int maxSize = 4;
public bool AddItem(ItemObject itemObject)
public bool AddItem(Recipe recipe)
{
if (container.Count < maxSize)
{
container.Add(itemObject);
UIManager.Instance.uiInventoryManager.Add(itemObject);
container.Add(recipe);
UIManager.Instance.uiInventoryManager.Add(recipe);
return true;
}
return false;
}
public List<ItemObject> GetRecipes()
public List<Recipe> GetRecipes()
{
var recipes = new List<ItemObject>();
foreach (ItemObject item in container.ToList())
var recipes = new List<Recipe>();
foreach (Recipe item in container.ToList())
{
if (item.type == ItemType.Recipe)
{
@ -48,17 +45,17 @@ namespace Logic.Inventory.Scripts
return recipes;
}
public ItemObject GETMealForTable(int tableId)
public Recipe GETMealForTable(int tableId)
{
ItemObject item = container
Recipe item = container
.SingleOrDefault(x => x.forTable == tableId && x.type == ItemType.Food);
return item;
}
public void RemoveItem(ItemObject itemObject)
public void RemoveItem(Recipe recipe)
{
UIManager.Instance.uiInventoryManager.Remove(itemObject);
container.Remove(itemObject);
UIManager.Instance.uiInventoryManager.Remove(recipe);
container.Remove(recipe);
}
}
}

View File

@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Logic.Data;
using Logic.Graph;
using Logic.Inventory.Scripts;
using Logic.UI;
using UnityEngine;
@ -9,24 +8,18 @@ namespace Logic
{
public class KitchenTableManager: MonoBehaviour
{
#region Singleton
public static KitchenTableManager Instance;
public Queue<Recipe> inProgressQueue = new Queue<Recipe>();
public Queue<Recipe> readyQueue = new Queue<Recipe>();
[SerializeField] private KitchenTable kitchenTable;
private void Awake()
{
Instance = this;
kitchenTables = GetComponentsInChildren<KitchenTable>().ToList();
kitchenTable = GetComponentInChildren<KitchenTable>();
}
#endregion
[SerializeField] private List<KitchenTable> kitchenTables;
public Queue<ItemObject> inProgressQueue = new Queue<ItemObject>();
public Queue<ItemObject> readyQueue = new Queue<ItemObject>();
public void AddToQueue(ItemObject item, QueueType type)
public void AddToQueue(Recipe item, QueueType type)
{
if (type == QueueType.ProgressQueue)
{
@ -40,7 +33,7 @@ namespace Logic
}
}
public ItemObject RemoveFromQueue(QueueType type)
public Recipe RemoveFromQueue(QueueType type)
{
if (type == QueueType.ProgressQueue)
{

View File

@ -4,45 +4,49 @@ using Logic.Graph;
using UnityEngine;
using UnityEngine.UI;
namespace Assets.Logic
namespace Logic
{
public class SceneContext : MonoBehaviour
{
public List<Node> Map;
public Agent.Agent WaitressAgent;
public List<Node> map;
public Agent.Agent waitressAgent;
public static SceneContext Instance;
public Text text1, text2;
void Start()
{
Instance = this;
Application.targetFrameRate = 144;
Map = GetComponentsInChildren<Node>().ToList();
map = GetComponentsInChildren<Node>().ToList();
}
#region Gizmos
private void DrawGizmosFrom(Node from, List<Node> without)
{
foreach (var x in from.neighbors.Where(x=>!without.Contains(x)))
{
Gizmos.color = Color.blue;
Gizmos.DrawLine(from.transform.position, x.transform.position);
Gizmos.DrawSphere(from.transform.position,0.1f);
var position = @from.transform.position;
Gizmos.DrawLine(position, x.transform.position);
Gizmos.DrawSphere(position,0.1f);
if(!(x is Table)) without.Add(x);
DrawGizmosFrom(x, without);
}
foreach (var x in from.neighbors.Where(x => without.Contains(x)))
{
Gizmos.color = Color.blue;
Gizmos.DrawLine(from.transform.position, x.transform.position);
Gizmos.DrawSphere(from.transform.position,0.1f);
var position = @from.transform.position;
Gizmos.DrawLine(position, x.transform.position);
Gizmos.DrawSphere(position,0.1f);
}
}
private void OnDrawGizmos()
{
// if(Map.Count>0)
// DrawGizmosFrom(Map.First(), new List<Node>());
if(map.Count>0)
DrawGizmosFrom(map.First(), new List<Node>());
}
#endregion
}
}

View File

@ -1,4 +1,4 @@
using Logic.Inventory.Scripts;
using Logic.Data;
using UnityEngine;
namespace Logic.UI
@ -11,23 +11,23 @@ namespace Logic.UI
inventorySlots = GetComponentsInChildren<UIInventorySlot>();
}
public void Add(ItemObject itemObject)
public void Add(Recipe recipe)
{
foreach (UIInventorySlot inventorySlot in inventorySlots)
{
if (!inventorySlot.isFull)
{
inventorySlot.AddItem(itemObject);
inventorySlot.AddItem(recipe);
break;
}
}
}
public void Remove(ItemObject itemObject)
public void Remove(Recipe recipe)
{
foreach (UIInventorySlot inventorySlot in inventorySlots)
{
if (inventorySlot.isFull && inventorySlot.itemObject.Equals(itemObject))
if (inventorySlot.isFull && inventorySlot.recipe.Equals(recipe))
{
inventorySlot.ClearSlot();
break;

View File

@ -1,4 +1,4 @@
using Logic.Inventory.Scripts;
using Logic.Data;
using UnityEngine;
using UnityEngine.UI;
@ -7,25 +7,25 @@ namespace Logic.UI
public class UIInventorySlot : MonoBehaviour
{
[SerializeField] private Image icon;
public ItemObject itemObject;
public Recipe recipe;
public bool isFull;
public void AddItem(ItemObject newItem)
public void AddItem(Recipe newItem)
{
itemObject = newItem;
recipe = newItem;
SetIcon(newItem);
isFull = true;
}
public void ClearSlot()
{
itemObject = null;
recipe = null;
icon.sprite = null;
icon.enabled = false;
isFull = false;
}
private void SetIcon(ItemObject newItem)
private void SetIcon(Recipe newItem)
{
if (newItem.type == ItemType.Food)
{

View File

@ -1,4 +1,4 @@
using Logic.Inventory.Scripts;
using Logic.Data;
using UnityEngine;
namespace Logic.UI
@ -16,10 +16,9 @@ namespace Logic.UI
}
}
public void Add(ItemObject item)
public void Add(Recipe item)
{
UIInventorySlot uiQueueSlot = Instantiate(uiInventorySlot) as UIInventorySlot;
uiQueueSlot.transform.SetParent(queueWrapper.transform, false);
UIInventorySlot uiQueueSlot = Instantiate(uiInventorySlot, queueWrapper.transform, false);
uiQueueSlot.AddItem(item);
Canvas.ForceUpdateCanvases();
}

View File

@ -1,4 +1,4 @@
using Logic.Inventory.Scripts;
using Logic.Data;
using UnityEngine;
namespace Logic.UI
@ -14,7 +14,7 @@ namespace Logic.UI
[SerializeField] private UIQueue readyUIQueue;
[SerializeField] private UIQueue progressUIQueue;
public void Add(ItemObject item, QueueType type)
public void Add(Recipe item, QueueType type)
{
if (type == QueueType.ProgressQueue)
{

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Logic.Data;
using Logic.Graph;
using Logic.Inventory.Scripts;
using UnityEngine;
namespace Logic.UI
@ -30,14 +30,14 @@ namespace Logic.UI
}
}
public void ChangeItem(int tableNumber, ItemObject itemObject)
public void ChangeItem(int tableNumber, Recipe recipe)
{
if (tableNumber >= 0 && tableNumber <= 8)
{
_tableUIComponents[tableNumber].inventorySlot.ClearSlot();
if (itemObject == null)
if (recipe == null)
return;
_tableUIComponents[tableNumber].inventorySlot.AddItem(itemObject);
_tableUIComponents[tableNumber].inventorySlot.AddItem(recipe);
}
}
}

View File

@ -1,6 +1,6 @@
using System;
namespace Assets.Logic.Utils
namespace Logic.Utils
{
public static class FloatComparer
{

View File

@ -0,0 +1,20 @@
using System;
namespace Logic.Utils
{
public static class Randomizer
{
private static readonly Random Random = new Random();
public static T GetRandomEnumElement<T>() where T : struct, IConvertible
{
Array values = Enum.GetValues(typeof(T));
return (T)values.GetValue(Random.Next(values.Length));
}
public static int GetRandomIntInRange(int min, int max)
{
return Random.Next(min, max + 1);
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 05952562e4e64c67ad5046529a09fea7
timeCreated: 1617125590

View File

@ -1,30 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3047cb746451f4343a80357b74e6de5e, type: 3}
m_Name: Avocado
m_EditorClassIdentifier:
foodPrefab: {fileID: 1000010759889362, guid: 3245fc5926a7535429f2989cab01a844, type: 3}
foodIcon: {fileID: 21300042, guid: 37607ec1aab56e349af84a980f685a4b, type: 3}
recipeIcon: {fileID: 21300000, guid: 246f8fe64a276e040bd935eccb8a3a00, type: 3}
moneyIcon: {fileID: 21300000, guid: cef5e24fe61c976479140a07b2cda36c, type: 3}
type: 0
forTable: 0
itemName: Avocado
cost: 0
kcal: 0
ingredients:
- ingredientName:
type: 0
allergen: 0
- ingredientName:
type: 0
allergen: 0

View File

@ -1,24 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3047cb746451f4343a80357b74e6de5e, type: 3}
m_Name: Banana
m_EditorClassIdentifier:
foodPrefab: {fileID: 1000012997751318, guid: 0550765fb22bb954ea0412b7153ff417, type: 3}
foodIcon: {fileID: 21300020, guid: 37607ec1aab56e349af84a980f685a4b, type: 3}
recipeIcon: {fileID: 21300000, guid: 246f8fe64a276e040bd935eccb8a3a00, type: 3}
moneyIcon: {fileID: 21300000, guid: cef5e24fe61c976479140a07b2cda36c, type: 3}
type: 0
forTable: 0
itemName: Banana
cost: 0
kcal: 0
ingredients: []

View File

@ -4169,17 +4169,6 @@ Transform:
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 6a4e254c0b0d9214ea7b53f9c0c43b10, type: 3}
m_PrefabInstance: {fileID: 49519274}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1001334837 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 5273760715808998313, guid: f41a2c255b114084b9b939f2f6548a94, type: 3}
m_PrefabInstance: {fileID: 1986650115}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c774c22d330c32f48bfaca0426c29ad5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &1008716297
PrefabInstance:
m_ObjectHideFlags: 0
@ -6065,7 +6054,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 88c24af30e59b1a4ab8fd947b1361040, type: 3}
m_Name:
m_EditorClassIdentifier:
ActualNode: {fileID: 1001334837}
actualNode: {fileID: 1427572732}
--- !u!136 &1413865864
CapsuleCollider:
m_ObjectHideFlags: 0
@ -6269,6 +6258,17 @@ Transform:
m_CorrespondingSourceObject: {fileID: 5273760715808998314, guid: f41a2c255b114084b9b939f2f6548a94, type: 3}
m_PrefabInstance: {fileID: 198940678}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1427572732 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 5273760715808998313, guid: f41a2c255b114084b9b939f2f6548a94, type: 3}
m_PrefabInstance: {fileID: 1678673438}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c774c22d330c32f48bfaca0426c29ad5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &1433145648
PrefabInstance:
m_ObjectHideFlags: 0
@ -8573,10 +8573,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 88a63bb2b5290fd40b280c91b8f47077, type: 3}
m_Name:
m_EditorClassIdentifier:
Map: []
WaitressAgent: {fileID: 1413865863}
text1: {fileID: 0}
text2: {fileID: 0}
map: []
waitressAgent: {fileID: 0}
--- !u!4 &2007317810
Transform:
m_ObjectHideFlags: 0
@ -8650,8 +8648,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c34fcf5236784d3096ec85dd3649ec66, type: 3}
m_Name:
m_EditorClassIdentifier:
kitchenTables:
- {fileID: 0}
kitchenTable: {fileID: 0}
--- !u!1001 &2008034177
PrefabInstance:
m_ObjectHideFlags: 0