diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..ddb6ff8 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "visualstudiotoolsforunity.vstuc" + ] +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..da60e25 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,10 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Attach to Unity", + "type": "vstuc", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4f0fdb8 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,60 @@ +{ + "files.exclude": { + "**/.DS_Store": true, + "**/.git": true, + "**/.vs": true, + "**/.gitmodules": true, + "**/.vsconfig": true, + "**/*.booproj": true, + "**/*.pidb": true, + "**/*.suo": true, + "**/*.user": true, + "**/*.userprefs": true, + "**/*.unityproj": true, + "**/*.dll": true, + "**/*.exe": true, + "**/*.pdf": true, + "**/*.mid": true, + "**/*.midi": true, + "**/*.wav": true, + "**/*.gif": true, + "**/*.ico": true, + "**/*.jpg": true, + "**/*.jpeg": true, + "**/*.png": true, + "**/*.psd": true, + "**/*.tga": true, + "**/*.tif": true, + "**/*.tiff": true, + "**/*.3ds": true, + "**/*.3DS": true, + "**/*.fbx": true, + "**/*.FBX": true, + "**/*.lxo": true, + "**/*.LXO": true, + "**/*.ma": true, + "**/*.MA": true, + "**/*.obj": true, + "**/*.OBJ": true, + "**/*.asset": true, + "**/*.cubemap": true, + "**/*.flare": true, + "**/*.mat": true, + "**/*.meta": true, + "**/*.prefab": true, + "**/*.unity": true, + "build/": true, + "Build/": true, + "Library/": true, + "library/": true, + "obj/": true, + "Obj/": true, + "Logs/": true, + "logs/": true, + "ProjectSettings/": true, + "UserSettings/": true, + "temp/": true, + "Temp/": true + }, + "dotnet.defaultSolution": "Let-Him-Cook.sln" +} \ No newline at end of file diff --git a/Assets/Scenes/Noahs kælder.unity b/Assets/Scenes/Noahs kælder.unity index 5adac32..1bfdbf0 100644 --- a/Assets/Scenes/Noahs kælder.unity +++ b/Assets/Scenes/Noahs kælder.unity @@ -177,7 +177,7 @@ GameObject: - component: {fileID: 143107364} m_Layer: 0 m_Name: Rice - m_TagString: Untagged + m_TagString: Ingredient m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -325,7 +325,7 @@ GameObject: - component: {fileID: 389679692} m_Layer: 0 m_Name: Onion - m_TagString: Untagged + m_TagString: Ingredient m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -555,13 +555,13 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 460072661} serializedVersion: 2 - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 4, y: 0, z: 0} + m_LocalRotation: {x: -0, y: -0, z: 0.011939, w: -0.9999287} + m_LocalPosition: {x: 4.06, y: 0.01, z: 0} m_LocalScale: {x: 2, y: 2, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1325490341} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: -1.368} --- !u!1 &537514707 GameObject: m_ObjectHideFlags: 0 @@ -576,7 +576,7 @@ GameObject: - component: {fileID: 537514711} m_Layer: 0 m_Name: Chimken - m_TagString: Untagged + m_TagString: Ingredient m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -642,7 +642,7 @@ Transform: m_GameObject: {fileID: 537514707} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 2.04, y: -2.51, z: 0} + m_LocalPosition: {x: 1.97, y: -0.06, z: 0} m_LocalScale: {x: 2, y: 2, z: 2} m_ConstrainProportionsScale: 0 m_Children: [] @@ -1033,7 +1033,7 @@ Transform: m_GameObject: {fileID: 867381650} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: 0.34, y: 0, z: 0} m_LocalScale: {x: 2, y: 2, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -1120,7 +1120,7 @@ GameObject: - component: {fileID: 885031694} m_Layer: 0 m_Name: Egg - m_TagString: Untagged + m_TagString: Ingredient m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -1134,7 +1134,7 @@ Transform: m_GameObject: {fileID: 885031692} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 3.06, y: -2.09, z: 0} + m_LocalPosition: {x: -0.01, y: -0.03, z: 0} m_LocalScale: {x: 2, y: 2, z: 2} m_ConstrainProportionsScale: 0 m_Children: [] @@ -1267,7 +1267,7 @@ GameObject: - component: {fileID: 1001436610} m_Layer: 0 m_Name: Tomato - m_TagString: Untagged + m_TagString: Ingredient m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -1281,7 +1281,7 @@ Transform: m_GameObject: {fileID: 1001436608} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 4, y: 0, z: 0} + m_LocalPosition: {x: 3.84, y: -0.11, z: 0} m_LocalScale: {x: 2, y: 2, z: 2} m_ConstrainProportionsScale: 0 m_Children: [] @@ -1499,7 +1499,7 @@ GameObject: - component: {fileID: 1274549343} m_Layer: 0 m_Name: Beef - m_TagString: Untagged + m_TagString: Ingredient m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -1790,7 +1790,7 @@ GameObject: - component: {fileID: 1420342331} m_Layer: 0 m_Name: Milk - m_TagString: Untagged + m_TagString: Ingredient m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -2052,7 +2052,8 @@ Transform: m_LocalPosition: {x: -0.19, y: 3.03, z: 1} m_LocalScale: {x: 4.0825, y: 3.375, z: 1} m_ConstrainProportionsScale: 0 - m_Children: [] + m_Children: + - {fileID: 1639705739} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1517788316 @@ -2067,6 +2068,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 84e0c3f7dac20fb428c544f192588d80, type: 3} m_Name: m_EditorClassIdentifier: + FinishedDishPosition: {x: -4.66, y: 2.89, z: 0} --- !u!50 &1517788317 Rigidbody2D: serializedVersion: 4 @@ -2210,7 +2212,7 @@ GameObject: - component: {fileID: 1575942283} m_Layer: 0 m_Name: Flour - m_TagString: Untagged + m_TagString: Ingredient m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -2343,6 +2345,178 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!1 &1639705738 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1639705739} + - component: {fileID: 1639705740} + - component: {fileID: 1639705741} + - component: {fileID: 1639705742} + - component: {fileID: 1639705743} + m_Layer: 0 + m_Name: CookButton + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1639705739 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1639705738} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.033, y: -0.604, z: -1} + m_LocalScale: {x: 0.4, y: 0.4, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1517788315} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &1639705740 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1639705738} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: 5c352ce85017d554694d2fe2623b1f8a, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!114 &1639705741 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1639705738} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 30e28733a4100f84e806c42e84c6d4ba, type: 3} + m_Name: + m_EditorClassIdentifier: + Button: {fileID: 1639705738} +--- !u!61 &1639705742 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1639705738} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_IsTrigger: 1 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0.5, y: 0.5} + oldSize: {x: 0.64, y: 0.64} + newSize: {x: 1, y: 1} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 0.64, y: 0.64} + m_EdgeRadius: 0 +--- !u!50 &1639705743 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1639705738} + m_BodyType: 0 + m_Simulated: 1 + m_UseFullKinematicContacts: 0 + m_UseAutoMass: 0 + m_Mass: 1 + m_LinearDrag: 0 + m_AngularDrag: 0.05 + m_GravityScale: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 7 --- !u!1 &1659394507 GameObject: m_ObjectHideFlags: 0 @@ -2357,7 +2531,7 @@ GameObject: - component: {fileID: 1659394509} m_Layer: 0 m_Name: Toast - m_TagString: Untagged + m_TagString: Ingredient m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -2625,7 +2799,7 @@ MonoBehaviour: RequiredIngredients: - {fileID: 143107362} - {fileID: 537514707} - NutritionalValue: 0 + NutritionalValue: 25 --- !u!212 &1714471224 SpriteRenderer: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/CookButton.cs b/Assets/Scripts/CookButton.cs new file mode 100644 index 0000000..2eb9dca --- /dev/null +++ b/Assets/Scripts/CookButton.cs @@ -0,0 +1,14 @@ +using System.Collections; +using System.Collections.Generic; +using Unity.VisualScripting; +using UnityEngine; + +public class CookButton : MonoBehaviour +{ + public GameObject Button; + + void OnMouseUp() { + Debug.Log("L"); + Button.GetComponentInParent().CreateDish(); + } +} diff --git a/Assets/Scripts/CookButton.cs.meta b/Assets/Scripts/CookButton.cs.meta new file mode 100644 index 0000000..e0fed74 --- /dev/null +++ b/Assets/Scripts/CookButton.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 30e28733a4100f84e806c42e84c6d4ba +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Cooking.cs b/Assets/Scripts/Cooking.cs index 90abb21..74471b2 100644 --- a/Assets/Scripts/Cooking.cs +++ b/Assets/Scripts/Cooking.cs @@ -14,14 +14,23 @@ public class Cooking : MonoBehaviour // } - void CreateDish() { + public Vector3 FinishedDishPosition; + + public void CreateDish() { List Ingredients = GetIngredients(); List AllDishes = new List (); // Find all dishes ingredients can make + if (Ingredients.Count < 1) { + return; + } + foreach (GameObject Ingredient in Ingredients) { + + Debug.Log(Ingredient.name); + List Dishes = Ingredient.GetComponent().IngredientIn; foreach (GameObject Dish in Dishes) { @@ -29,8 +38,9 @@ public class Cooking : MonoBehaviour } } - List PossibleDishes = new List (); + + List PossibleDishes = new List (); // Find the dishes, where all ingredients exist foreach (GameObject Dish in AllDishes) { @@ -51,26 +61,71 @@ public class Cooking : MonoBehaviour } } - foreach (GameObject Dish in PossibleDishes) { - Debug.Log(Dish); + // No dishes possible + + if (PossibleDishes.Count < 1) { + return; } - + GameObject BestDish = null; + foreach (GameObject Dish in PossibleDishes) { + + if (BestDish == null) { + BestDish = Dish; + continue; + } + + int CurrentNutritionalValue = Dish.GetComponent().NutritionalValue; + int BestNutrionnalValue = BestDish.GetComponent().NutritionalValue; + + if (CurrentNutritionalValue > BestNutrionnalValue) { + BestDish = Dish; + } + } + + // Find used ingredients + List IngredientsInDish = BestDish.GetComponent().RequiredIngredients; + List UsedIngredients = new(); + List UnusedIngredients = new(); + + foreach (GameObject Ingredient in Ingredients) { + if (IngredientsInDish.Contains(Ingredient)) { + UsedIngredients.Add(Ingredient); + } + else { + UnusedIngredients.Add(Ingredient); + } + } + + // Remove ingredients and add the dish + foreach (GameObject Ingredient in UsedIngredients) { + Transform transform = Ingredient.GetComponent().transform; + transform.position = Vector3.up * 50; + } + + BestDish.transform.position = FinishedDishPosition; + } // Keep track of ingredients going on and off the cooker. - List currentCollisions = new List (); + List currentCollisions = new List (); private void OnTriggerEnter2D(Collider2D other) { currentCollisions.Add (other.gameObject); - CreateDish(); } private void OnTriggerExit2D(Collider2D other) { currentCollisions.Remove (other.gameObject); } List GetIngredients() { - return currentCollisions; + List Ingredients = new List (); + + foreach (GameObject collision in currentCollisions) { + if (collision.tag == "Ingredient") { + Ingredients.Add(collision); + } + } + return Ingredients; } diff --git a/Packages/manifest.json b/Packages/manifest.json index 5077cac..40c3510 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -3,7 +3,7 @@ "com.unity.collab-proxy": "2.2.0", "com.unity.feature.2d": "2.0.0", "com.unity.ide.rider": "3.0.24", - "com.unity.ide.visualstudio": "2.0.18", + "com.unity.ide.visualstudio": "2.0.22", "com.unity.test-framework": "1.1.33", "com.unity.textmeshpro": "3.0.6", "com.unity.timeline": "1.7.5", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 202403f..45116dd 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -152,7 +152,7 @@ "url": "https://packages.unity.com" }, "com.unity.ide.visualstudio": { - "version": "2.0.18", + "version": "2.0.22", "depth": 0, "source": "registry", "dependencies": { diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 1c92a78..ec9d4b3 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -3,7 +3,8 @@ --- !u!78 &1 TagManager: serializedVersion: 2 - tags: [] + tags: + - Ingredient layers: - Default - TransparentFX