From ef0155632ae7653bd37618f9e71e061eed1f7fa2 Mon Sep 17 00:00:00 2001 From: BuyMyMojo Date: Thu, 2 Mar 2023 03:34:38 +1100 Subject: [PATCH] Add basic broken frying logic --- .erp | 2 +- Assets/Prefabs/Counter/StoveCounter.prefab | 51 +++++++++- Assets/Scenes/GaneScene.unity | 93 +++++++++++++++++-- .../MeatPattyCooked-MeatPattyBurnt.asset | 2 +- .../MeatPattyUncooked-MeatPattyCooked.asset | 2 +- Assets/Scripts/Counters/BaseCounter.cs | 3 +- Assets/Scripts/Counters/StoveCounter.cs | 93 +++++++++++++++++++ 7 files changed, 230 insertions(+), 16 deletions(-) diff --git a/.erp b/.erp index 717b384..2de6fa9 100644 --- a/.erp +++ b/.erp @@ -5,7 +5,7 @@ false false true - 1677687834 + 1677690484 23669525547325516 false \ No newline at end of file diff --git a/Assets/Prefabs/Counter/StoveCounter.prefab b/Assets/Prefabs/Counter/StoveCounter.prefab index 005df83..f2591ee 100644 --- a/Assets/Prefabs/Counter/StoveCounter.prefab +++ b/Assets/Prefabs/Counter/StoveCounter.prefab @@ -94,14 +94,46 @@ PrefabInstance: type: 3} insertIndex: -1 addedObject: {fileID: 9076728630823268195} - m_AddedComponents: [] + m_AddedComponents: + - targetCorrespondingSourceObject: {fileID: 6869097019740516189, guid: 509501a557d1d0a45817fb7332917dd5, + type: 3} + insertIndex: -1 + addedObject: {fileID: 5065327384487018965} m_SourcePrefab: {fileID: 100100000, guid: 509501a557d1d0a45817fb7332917dd5, type: 3} +--- !u!4 &976370877519106100 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 1024188629140685204, guid: 509501a557d1d0a45817fb7332917dd5, + type: 3} + m_PrefabInstance: {fileID: 268634890214101408} + m_PrefabAsset: {fileID: 0} --- !u!4 &6616006834372177299 stripped Transform: m_CorrespondingSourceObject: {fileID: 6371086230447438899, guid: 509501a557d1d0a45817fb7332917dd5, type: 3} m_PrefabInstance: {fileID: 268634890214101408} m_PrefabAsset: {fileID: 0} +--- !u!1 &6695037738886840061 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 6869097019740516189, guid: 509501a557d1d0a45817fb7332917dd5, + type: 3} + m_PrefabInstance: {fileID: 268634890214101408} + m_PrefabAsset: {fileID: 0} +--- !u!114 &5065327384487018965 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6695037738886840061} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 97b430ad528743b4c820a9ec73b4ae32, type: 3} + m_Name: + m_EditorClassIdentifier: + counterTopPoint: {fileID: 976370877519106100} + fryingRecipeSOArray: + - {fileID: 11400000, guid: 3d422b39fbddcbd47bae458238f9c627, type: 2} + - {fileID: 11400000, guid: ab68452688ff0fc4eb1439a3f3f5eca4, type: 2} --- !u!1001 &4775776715932421064 PrefabInstance: m_ObjectHideFlags: 0 @@ -199,6 +231,11 @@ PrefabInstance: propertyPath: m_Materials.Array.data[0] value: objectReference: {fileID: 2100000, guid: 1a0afd856a35421469b28b916116fd9c, type: 2} + - target: {fileID: 4386361873462607087, guid: 93af8b85a17635f40a5b76ed82a86c18, + type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} - target: {fileID: 4589716710238282922, guid: 93af8b85a17635f40a5b76ed82a86c18, type: 3} propertyPath: m_Name @@ -279,6 +316,16 @@ PrefabInstance: propertyPath: m_ConstrainProportionsScale value: 1 objectReference: {fileID: 0} + - target: {fileID: 4998458208842551057, guid: 93af8b85a17635f40a5b76ed82a86c18, + type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6918696954688420558, guid: 93af8b85a17635f40a5b76ed82a86c18, + type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} - target: {fileID: 8864449973679823643, guid: 93af8b85a17635f40a5b76ed82a86c18, type: 3} propertyPath: m_Materials.Array.data[0] @@ -335,7 +382,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6b8e4c74ab1ad4b4a8c3676f33904e52, type: 3} m_Name: m_EditorClassIdentifier: - baseCounter: {fileID: 0} + baseCounter: {fileID: 5065327384487018965} visualGameObjectArray: - {fileID: 703760627113338248} - {fileID: 8089917589884704374} diff --git a/Assets/Scenes/GaneScene.unity b/Assets/Scenes/GaneScene.unity index 525457d..94df2c1 100644 --- a/Assets/Scenes/GaneScene.unity +++ b/Assets/Scenes/GaneScene.unity @@ -667,8 +667,81 @@ Transform: - {fileID: 78671169} - {fileID: 1617745536} m_Father: {fileID: 0} - m_RootOrder: 10 + m_RootOrder: 11 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &370799796 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 6616006834372177299, guid: ae14b9e7a32963047a859cc7ab07f505, + type: 3} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6616006834372177299, guid: ae14b9e7a32963047a859cc7ab07f505, + type: 3} + propertyPath: m_LocalPosition.x + value: 6 + objectReference: {fileID: 0} + - target: {fileID: 6616006834372177299, guid: ae14b9e7a32963047a859cc7ab07f505, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6616006834372177299, guid: ae14b9e7a32963047a859cc7ab07f505, + type: 3} + propertyPath: m_LocalPosition.z + value: 3.5 + objectReference: {fileID: 0} + - target: {fileID: 6616006834372177299, guid: ae14b9e7a32963047a859cc7ab07f505, + type: 3} + propertyPath: m_LocalRotation.w + value: -0.0028347075 + objectReference: {fileID: 0} + - target: {fileID: 6616006834372177299, guid: ae14b9e7a32963047a859cc7ab07f505, + type: 3} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 6616006834372177299, guid: ae14b9e7a32963047a859cc7ab07f505, + type: 3} + propertyPath: m_LocalRotation.y + value: -0.999996 + objectReference: {fileID: 0} + - target: {fileID: 6616006834372177299, guid: ae14b9e7a32963047a859cc7ab07f505, + type: 3} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 6616006834372177299, guid: ae14b9e7a32963047a859cc7ab07f505, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6616006834372177299, guid: ae14b9e7a32963047a859cc7ab07f505, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: -180.325 + objectReference: {fileID: 0} + - target: {fileID: 6616006834372177299, guid: ae14b9e7a32963047a859cc7ab07f505, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6695037738886840061, guid: ae14b9e7a32963047a859cc7ab07f505, + type: 3} + propertyPath: m_Name + value: StoveCounter + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: ae14b9e7a32963047a859cc7ab07f505, type: 3} --- !u!1 &392963849 GameObject: m_ObjectHideFlags: 0 @@ -735,7 +808,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 9 + m_RootOrder: 10 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &408182761 GameObject: @@ -861,7 +934,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!114 &410087042 MonoBehaviour: @@ -1132,7 +1205,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 7 + m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &763156967 PrefabInstance: @@ -1327,7 +1400,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &974939165 GameObject: @@ -1361,7 +1434,7 @@ Transform: - {fileID: 1139635725} - {fileID: 408182762} m_Father: {fileID: 0} - m_RootOrder: 6 + m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &974939167 MonoBehaviour: @@ -1786,7 +1859,7 @@ Transform: m_ConstrainProportionsScale: 1 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1329055550 PrefabInstance: @@ -2271,7 +2344,7 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 8 + m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -2379,7 +2452,7 @@ PrefabInstance: - target: {fileID: 6853301306222527979, guid: dcc374f2f4a690540874e0afc4c73531, type: 3} propertyPath: m_RootOrder - value: 1 + value: 2 objectReference: {fileID: 0} - target: {fileID: 6853301306222527979, guid: dcc374f2f4a690540874e0afc4c73531, type: 3} @@ -2658,5 +2731,5 @@ Transform: m_Children: - {fileID: 691696597} m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 46, y: 0, z: 0} diff --git a/Assets/ScriptableObjects/FryingRecipeSO/MeatPattyCooked-MeatPattyBurnt.asset b/Assets/ScriptableObjects/FryingRecipeSO/MeatPattyCooked-MeatPattyBurnt.asset index e8bc260..9a112b6 100644 --- a/Assets/ScriptableObjects/FryingRecipeSO/MeatPattyCooked-MeatPattyBurnt.asset +++ b/Assets/ScriptableObjects/FryingRecipeSO/MeatPattyCooked-MeatPattyBurnt.asset @@ -14,4 +14,4 @@ MonoBehaviour: m_EditorClassIdentifier: input: {fileID: 11400000, guid: cf77ec56d13b4c7478384a548ab18277, type: 2} output: {fileID: 11400000, guid: 42754f770e37e78488140348e6a9f9c3, type: 2} - fryingTimerMax: 0 + fryingTimerMax: 3 diff --git a/Assets/ScriptableObjects/FryingRecipeSO/MeatPattyUncooked-MeatPattyCooked.asset b/Assets/ScriptableObjects/FryingRecipeSO/MeatPattyUncooked-MeatPattyCooked.asset index ee0e033..8fae0ef 100644 --- a/Assets/ScriptableObjects/FryingRecipeSO/MeatPattyUncooked-MeatPattyCooked.asset +++ b/Assets/ScriptableObjects/FryingRecipeSO/MeatPattyUncooked-MeatPattyCooked.asset @@ -14,4 +14,4 @@ MonoBehaviour: m_EditorClassIdentifier: input: {fileID: 11400000, guid: d672e8baad811004281dd021411b0a80, type: 2} output: {fileID: 11400000, guid: cf77ec56d13b4c7478384a548ab18277, type: 2} - fryingTimerMax: 0 + fryingTimerMax: 3 diff --git a/Assets/Scripts/Counters/BaseCounter.cs b/Assets/Scripts/Counters/BaseCounter.cs index 8446818..6e15c8e 100644 --- a/Assets/Scripts/Counters/BaseCounter.cs +++ b/Assets/Scripts/Counters/BaseCounter.cs @@ -16,7 +16,8 @@ public class BaseCounter : MonoBehaviour, IKitchenObjectParent public virtual void InteractAlternate(Player player) { - Debug.LogError("BaseCounter.InteractAlterante();"); + // Debug.LogError("BaseCounter.InteractAlterante();"); + // Don't do anything, not all Counters need alt interact actions. } public Transform GetKitchenObjectFollowTransform() diff --git a/Assets/Scripts/Counters/StoveCounter.cs b/Assets/Scripts/Counters/StoveCounter.cs index 8f16ad4..a724c3f 100644 --- a/Assets/Scripts/Counters/StoveCounter.cs +++ b/Assets/Scripts/Counters/StoveCounter.cs @@ -1,8 +1,101 @@ using System.Collections; using System.Collections.Generic; +using Unity.VisualScripting; using UnityEngine; +using static CuttingCounter; public class StoveCounter : BaseCounter { + [SerializeField] private FryingRecipeSO[] fryingRecipeSOArray; + + private float fryingTimer; + + private void Update() + { + if (HasKitchenObject()) + { + fryingTimer += Time.deltaTime; + FryingRecipeSO fryingRecipeSO = GetFryingRecipeSOWithInput(GetKitchenObject().GetKitchenObjectSO()); + if (fryingTimer > fryingRecipeSO.fryingTimerMax) + { + // Fried + fryingTimer = 0f; + Debug.Log("Fried!"); + GetKitchenObject().DestroySelf(); + + KitchenObject.SpawnKitchenObject(fryingRecipeSO.output, this); + + } + Debug.Log(fryingTimer); + } + } + + public override void Interact(Player player) + { + if (!HasKitchenObject()) + { + // no KitchenObject here + if (player.HasKitchenObject()) + { + // player has object + if (HasRecipeWithInput(player.GetKitchenObject().GetKitchenObjectSO())) + { + // player is carrying an object that can be Fried + player.GetKitchenObject().SetKitchenObjectParent(this); + } + } + else + { + // player has nothing, do nothing + } + } + else + { + // KitchenObject is here + if (player.HasKitchenObject()) + { + // player has object, do nothing + } + else + { + // player has nothing + GetKitchenObject().SetKitchenObjectParent(player); + } + } + + } + + private bool HasRecipeWithInput(KitchenObjectSO inputKitchenObjectSO) + { + FryingRecipeSO fryingRecipeSO = GetFryingRecipeSOWithInput(inputKitchenObjectSO); + return fryingRecipeSO != null; + } + + private KitchenObjectSO GetOutputForInput(KitchenObjectSO inputKitchenObjectSO) + { + FryingRecipeSO fryingRecipeSO = GetFryingRecipeSOWithInput(inputKitchenObjectSO); + if (fryingRecipeSO != null) + { + return fryingRecipeSO.output; + } + else + { + return null; + } + } + + private FryingRecipeSO GetFryingRecipeSOWithInput(KitchenObjectSO inputKitchenObjectSO) + { + foreach (FryingRecipeSO fryingRecipeSO in fryingRecipeSOArray) + { + if (fryingRecipeSO.input == inputKitchenObjectSO) + { + return fryingRecipeSO; + } + } + return null; + + } + }