diff --git a/.erp b/.erp
index 38423f9..efda13f 100644
--- a/.erp
+++ b/.erp
@@ -5,7 +5,7 @@
false
false
true
- 1677612387
+ 1677615563
8006271043655199372
false
\ No newline at end of file
diff --git a/Assets/Prefabs/Counter/CuttingCounter.prefab b/Assets/Prefabs/Counter/CuttingCounter.prefab
index a970acf..aa4abd2 100644
--- a/Assets/Prefabs/Counter/CuttingCounter.prefab
+++ b/Assets/Prefabs/Counter/CuttingCounter.prefab
@@ -364,7 +364,10 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
counterTopPoint: {fileID: 9008358141095219129}
- cutKitchenObjectSO: {fileID: 11400000, guid: f00d7c6ba063ee6448dd26fac2bf4ce4, type: 2}
+ cuttingRecipeSOArray:
+ - {fileID: 11400000, guid: 4b789feab80f3af4d9f54c0b12fc6f89, type: 2}
+ - {fileID: 11400000, guid: 26b6267afdd6fcf42b5c4f100065f7cd, type: 2}
+ - {fileID: 11400000, guid: 13cce409a5589f447b8b5b33c98ec9d6, type: 2}
--- !u!4 &9008358141095219129 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 1024188629140685204, guid: 509501a557d1d0a45817fb7332917dd5,
diff --git a/Assets/Prefabs/KitchenObjects/CheeseSlices.prefab b/Assets/Prefabs/KitchenObjects/CheeseSlices.prefab
index f6db146..1c82850 100644
--- a/Assets/Prefabs/KitchenObjects/CheeseSlices.prefab
+++ b/Assets/Prefabs/KitchenObjects/CheeseSlices.prefab
@@ -29,7 +29,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- - {fileID: 4217830993578611624}
+ - {fileID: 1277091092657317217}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -46,7 +46,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
kitchenObjectSO: {fileID: 11400000, guid: adbde85b933684c4992834e8bb9d893b, type: 2}
---- !u!1001 &1036586551768401192
+--- !u!1001 &2689542459995665377
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
@@ -119,9 +119,9 @@ PrefabInstance:
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 17cb28a1a37fd7f44ae6e1ad2aa9da78, type: 3}
---- !u!4 &4217830993578611624 stripped
+--- !u!4 &1277091092657317217 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3812876574508226176, guid: 17cb28a1a37fd7f44ae6e1ad2aa9da78,
type: 3}
- m_PrefabInstance: {fileID: 1036586551768401192}
+ m_PrefabInstance: {fileID: 2689542459995665377}
m_PrefabAsset: {fileID: 0}
diff --git a/Assets/Prefabs/KitchenObjects/Tomato.prefab b/Assets/Prefabs/KitchenObjects/Tomato.prefab
index 2e65e3a..9df1ae9 100644
--- a/Assets/Prefabs/KitchenObjects/Tomato.prefab
+++ b/Assets/Prefabs/KitchenObjects/Tomato.prefab
@@ -31,7 +31,7 @@ Transform:
m_Children:
- {fileID: 7776824414934913256}
m_Father: {fileID: 0}
- m_RootOrder: 9
+ m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &5792615824413011753
MonoBehaviour:
@@ -45,7 +45,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9f604455b7aeb5f4790263b920c04313, type: 3}
m_Name:
m_EditorClassIdentifier:
- kitchenObjectSO: {fileID: 11400000, guid: 9a7cd1ad975e4124e9873832ba4af356, type: 2}
+ kitchenObjectSO: {fileID: 11400000, guid: 38de64e72d766a34c82d1ef83d41c98d, type: 2}
--- !u!1001 &6847401699804399208
PrefabInstance:
m_ObjectHideFlags: 0
diff --git a/Assets/Scripts/CuttingCounter.cs b/Assets/Scripts/CuttingCounter.cs
index a37fe24..6bbff0b 100644
--- a/Assets/Scripts/CuttingCounter.cs
+++ b/Assets/Scripts/CuttingCounter.cs
@@ -5,7 +5,7 @@ using UnityEngine;
public class CuttingCounter : BaseCounter
{
- [SerializeField] private KitchenObjectSO cutKitchenObjectSO;
+ [SerializeField] private CuttingRecipeSO[] cuttingRecipeSOArray;
public override void Interact(Player player)
{
@@ -15,7 +15,11 @@ public class CuttingCounter : BaseCounter
if (player.HasKitchenObject())
{
// player has object
- player.GetKitchenObject().SetKitchenObjectParent(this);
+ if (HasRecipeWithInput(player.GetKitchenObject().GetKitchenObjectSO()))
+ {
+ // player is carrying an object that can be chopped
+ player.GetKitchenObject().SetKitchenObjectParent(this);
+ }
}
else
{
@@ -39,12 +43,39 @@ public class CuttingCounter : BaseCounter
public override void InteractAlternate(Player player)
{
- if (HasKitchenObject())
+ if (HasKitchenObject() && HasRecipeWithInput(GetKitchenObject().GetKitchenObjectSO()))
{
- // there is a KitchenObject here
+ // there is a KitchenObject AND it is able to be cut
+
+ KitchenObjectSO outputKitchenSO = GetOutputForInput(GetKitchenObject().GetKitchenObjectSO());
+
GetKitchenObject().DestroySelf();
- KitchenObject.SpawnKitchenObject(cutKitchenObjectSO, this);
+ KitchenObject.SpawnKitchenObject(outputKitchenSO, this);
}
}
+
+ private bool HasRecipeWithInput(KitchenObjectSO inputKitchenObjectSO)
+ {
+ foreach (CuttingRecipeSO cuttingRecipeSO in cuttingRecipeSOArray)
+ {
+ if (cuttingRecipeSO.input == inputKitchenObjectSO)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private KitchenObjectSO GetOutputForInput(KitchenObjectSO inputKitchenObjectSO)
+ {
+ foreach (CuttingRecipeSO cuttingRecipeSO in cuttingRecipeSOArray)
+ {
+ if (cuttingRecipeSO.input == inputKitchenObjectSO)
+ {
+ return cuttingRecipeSO.output;
+ }
+ }
+ return null;
+ }
}