diff --git a/.erp b/.erp index 448003f..85f3ef0 100644 --- a/.erp +++ b/.erp @@ -5,7 +5,7 @@ false false true - 1677533527 - 522683637854076046 + 1677589653 + 8006271043655199372 false \ No newline at end of file diff --git a/Assets/Scenes/GaneScene.unity b/Assets/Scenes/GaneScene.unity index b754af7..fc2b7b9 100644 --- a/Assets/Scenes/GaneScene.unity +++ b/Assets/Scenes/GaneScene.unity @@ -192,6 +192,11 @@ PrefabInstance: propertyPath: m_Name value: ClearCounter (1) objectReference: {fileID: 0} + - target: {fileID: 7837983985068458341, guid: f62bfcbfbc8097441a9fae9a02652a07, + type: 3} + propertyPath: testing + value: 0 + objectReference: {fileID: 0} - target: {fileID: 7837983985068458341, guid: f62bfcbfbc8097441a9fae9a02652a07, type: 3} propertyPath: tomatoPrefab @@ -204,6 +209,11 @@ PrefabInstance: value: objectReference: {fileID: 11400000, guid: 9a7cd1ad975e4124e9873832ba4af356, type: 2} + - target: {fileID: 7837983985068458341, guid: f62bfcbfbc8097441a9fae9a02652a07, + type: 3} + propertyPath: secondClearCounter + value: + objectReference: {fileID: 1926678759} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] @@ -380,6 +390,49 @@ MonoBehaviour: m_CameraActivatedEvent: m_PersistentCalls: m_Calls: [] +--- !u!114 &391596026 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 7837983985068458341, guid: f62bfcbfbc8097441a9fae9a02652a07, + type: 3} + m_PrefabInstance: {fileID: 295568153} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bb159edc225081c408fe7a01d52732e4, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1 &408182761 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 408182762} + m_Layer: 0 + m_Name: KitchenObjectHoldPoint + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &408182762 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 408182761} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1.3, z: 1} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 974939166} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &410087039 GameObject: m_ObjectHideFlags: 0 @@ -734,6 +787,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1139635725} + - {fileID: 408182762} m_Father: {fileID: 0} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -754,6 +808,7 @@ MonoBehaviour: countersLayerMask: serializedVersion: 2 m_Bits: 64 + kitchenObjectHoldPoint: {fileID: 408182762} --- !u!1001 &1075657335 PrefabInstance: m_ObjectHideFlags: 0 @@ -997,6 +1052,18 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1926678759 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 7837983985068458341, guid: f62bfcbfbc8097441a9fae9a02652a07, + type: 3} + m_PrefabInstance: {fileID: 8218183545890461205} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bb159edc225081c408fe7a01d52732e4, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &2099865127 GameObject: m_ObjectHideFlags: 0 @@ -1137,12 +1204,22 @@ PrefabInstance: propertyPath: m_Name value: ClearCounter objectReference: {fileID: 0} + - target: {fileID: 7837983985068458341, guid: f62bfcbfbc8097441a9fae9a02652a07, + type: 3} + propertyPath: testing + value: 1 + objectReference: {fileID: 0} - target: {fileID: 7837983985068458341, guid: f62bfcbfbc8097441a9fae9a02652a07, type: 3} propertyPath: kitchenObjectSO value: objectReference: {fileID: 11400000, guid: 38de64e72d766a34c82d1ef83d41c98d, type: 2} + - target: {fileID: 7837983985068458341, guid: f62bfcbfbc8097441a9fae9a02652a07, + type: 3} + propertyPath: secondClearCounter + value: + objectReference: {fileID: 391596026} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] diff --git a/Assets/Scripts/ClearCounter.cs b/Assets/Scripts/ClearCounter.cs index f2e5bb1..3a9aceb 100644 --- a/Assets/Scripts/ClearCounter.cs +++ b/Assets/Scripts/ClearCounter.cs @@ -1,20 +1,53 @@ +using System.Collections; +using System.Collections.Generic; using UnityEngine; -public class ClearCounter : MonoBehaviour +public class ClearCounter : MonoBehaviour, IKitchenObjectParent { + [SerializeField] private KitchenObjectSO kitchenObjectSO; [SerializeField] private Transform counterTopPoint; - public void Interact() + private KitchenObject kitchenObject; + + public void Interact(Player player) { - Debug.Log("Interacted!"); + if (kitchenObject == null) + { + Transform kitchenObjectTransform = Instantiate(kitchenObjectSO.prefab, counterTopPoint); + kitchenObjectTransform.GetComponent().SetKitchenObjectParent(this); + } else + { + // Give object to player + kitchenObject.SetKitchenObjectParent(player); + } + + } - Transform kitchenObjectTransform = Instantiate(kitchenObjectSO.prefab, counterTopPoint); + public Transform GetKitchenObjectFollowTransform() + { + return counterTopPoint; + } - kitchenObjectTransform.localPosition = Vector3.zero; + public void SetKitchenObject(KitchenObject kitchenObject) + { + this.kitchenObject = kitchenObject; + } - Debug.Log(kitchenObjectTransform.GetComponent().GetKitchenObjectSO().objectName); + public KitchenObject GetKitchenObject() + { + return kitchenObject; + } + + public void ClearKitchenObject() + { + kitchenObject = null; + } + + public bool HasKitchenObject() + { + return kitchenObject != null; } } diff --git a/Assets/Scripts/GameInput.cs b/Assets/Scripts/GameInput.cs index f2a2701..a7f8b79 100644 --- a/Assets/Scripts/GameInput.cs +++ b/Assets/Scripts/GameInput.cs @@ -1,3 +1,5 @@ +using System.Collections; +using System.Collections.Generic; using System; using UnityEngine; diff --git a/Assets/Scripts/IKitchenObjectParent.cs b/Assets/Scripts/IKitchenObjectParent.cs new file mode 100644 index 0000000..8cc9feb --- /dev/null +++ b/Assets/Scripts/IKitchenObjectParent.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public interface IKitchenObjectParent +{ + public Transform GetKitchenObjectFollowTransform(); + + public void SetKitchenObject(KitchenObject kitchenObject); + + public KitchenObject GetKitchenObject(); + + public void ClearKitchenObject(); + + public bool HasKitchenObject(); +} diff --git a/Assets/Scripts/IKitchenObjectParent.cs.meta b/Assets/Scripts/IKitchenObjectParent.cs.meta new file mode 100644 index 0000000..7bbe2c2 --- /dev/null +++ b/Assets/Scripts/IKitchenObjectParent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9e041dba01fc1ec41940caf2038dcec5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/KitchenObject.cs b/Assets/Scripts/KitchenObject.cs index 273707f..a53b1db 100644 --- a/Assets/Scripts/KitchenObject.cs +++ b/Assets/Scripts/KitchenObject.cs @@ -7,6 +7,37 @@ public class KitchenObject : MonoBehaviour [SerializeField] private KitchenObjectSO kitchenObjectSO; - public KitchenObjectSO GetKitchenObjectSO() { return kitchenObjectSO; } + private IKitchenObjectParent kitchenObjectParent; + + public KitchenObjectSO GetKitchenObjectSO() + { + return kitchenObjectSO; + } + + public void SetKitchenObjectParent(IKitchenObjectParent kitchenObjectParent) + { + if (this.kitchenObjectParent != null) + { + this.kitchenObjectParent.ClearKitchenObject(); + } + + this.kitchenObjectParent = kitchenObjectParent; + + if (kitchenObjectParent.HasKitchenObject()) + { + Debug.LogError("IKitchenObjectParent already has KitchenObject!"); + } + + kitchenObjectParent.SetKitchenObject(this); + + transform.parent = kitchenObjectParent.GetKitchenObjectFollowTransform(); + transform.localPosition = Vector3.zero; + } + + public IKitchenObjectParent GetKitchenObjectParent() + { + return kitchenObjectParent; + } + } diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index e06fcf2..dc9b637 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -1,8 +1,10 @@ +using System.Collections; +using System.Collections.Generic; using System; using UnityEditorInternal; using UnityEngine; -public class Player : MonoBehaviour +public class Player : MonoBehaviour, IKitchenObjectParent { public static Player Instance { get; private set; } @@ -16,10 +18,12 @@ public class Player : MonoBehaviour [SerializeField] private float moveSpeed = 7f; [SerializeField] private GameInput gameInput; [SerializeField] private LayerMask countersLayerMask; + [SerializeField] private Transform kitchenObjectHoldPoint; private bool isWalking; private Vector3 lastInteractDir; private ClearCounter selectedCounter; + private KitchenObject kitchenObject; private void Start() { @@ -30,7 +34,7 @@ public class Player : MonoBehaviour { if (selectedCounter != null) { - selectedCounter.Interact(); + selectedCounter.Interact(this); } } @@ -155,4 +159,28 @@ public class Player : MonoBehaviour }); } + public Transform GetKitchenObjectFollowTransform() + { + return kitchenObjectHoldPoint; + } + + public void SetKitchenObject(KitchenObject kitchenObject) + { + this.kitchenObject = kitchenObject; + } + + public KitchenObject GetKitchenObject() + { + return kitchenObject; + } + + public void ClearKitchenObject() + { + kitchenObject = null; + } + + public bool HasKitchenObject() + { + return kitchenObject != null; + } } diff --git a/Assets/Scripts/PlayerAnimator.cs b/Assets/Scripts/PlayerAnimator.cs index 0f7da44..88777d5 100644 --- a/Assets/Scripts/PlayerAnimator.cs +++ b/Assets/Scripts/PlayerAnimator.cs @@ -1,3 +1,5 @@ +using System.Collections; +using System.Collections.Generic; using UnityEngine; public class PlayerAnimator : MonoBehaviour diff --git a/Assets/Scripts/SelectedCounterVisual.cs b/Assets/Scripts/SelectedCounterVisual.cs index 5f6df76..ad08edb 100644 --- a/Assets/Scripts/SelectedCounterVisual.cs +++ b/Assets/Scripts/SelectedCounterVisual.cs @@ -1,3 +1,5 @@ +using System.Collections; +using System.Collections.Generic; using UnityEngine; public class SelectedCounterVisual : MonoBehaviour