diff --git a/Assets/ObjectScript.cs b/Assets/ObjectScript.cs new file mode 100644 index 0000000..593df59 --- /dev/null +++ b/Assets/ObjectScript.cs @@ -0,0 +1,25 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ObjectScript : MonoBehaviour +{ + void OnCollisionEnter2D(Collision2D other){ + + if(!this.transform.GetChild(1).gameObject.activeInHierarchy && + other.gameObject.name == "SprayBottle") + { + this.transform.GetChild(1).gameObject.SetActive(true); + } + + if(this.transform.GetChild(1).gameObject.activeInHierarchy && + other.gameObject.name == "Rag") + { + this.transform.GetChild(0).gameObject.SetActive(false); + this.transform.GetChild(1).gameObject.SetActive(false); + } + + //Debug.Log("Collision"); + + } +} diff --git a/Assets/ObjectScript.cs.meta b/Assets/ObjectScript.cs.meta new file mode 100644 index 0000000..663269b --- /dev/null +++ b/Assets/ObjectScript.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1ee23683ea369cc46acd31c562ef7a65 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Main Scene.unity b/Assets/Scenes/Main Scene.unity index 0deec50..a56ac1e 100644 --- a/Assets/Scenes/Main Scene.unity +++ b/Assets/Scenes/Main Scene.unity @@ -131,7 +131,6 @@ GameObject: m_Component: - component: {fileID: 19670644} - component: {fileID: 19670645} - - component: {fileID: 19670646} m_Layer: 0 m_Name: Dirt m_TagString: Untagged @@ -203,32 +202,6 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 ---- !u!61 &19670646 -BoxCollider2D: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 19670643} - m_Enabled: 1 - m_Density: 1 - m_Material: {fileID: 0} - m_IsTrigger: 0 - 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: 5.12, y: 5.12} - newSize: {x: 5.12, y: 5.12} - adaptiveTilingThreshold: 0.5 - drawMode: 0 - adaptiveTiling: 0 - m_AutoTiling: 0 - serializedVersion: 2 - m_Size: {x: 5.12, y: 5.12} - m_EdgeRadius: 0 --- !u!1 &317481903 GameObject: m_ObjectHideFlags: 0 @@ -239,6 +212,7 @@ GameObject: m_Component: - component: {fileID: 317481905} - component: {fileID: 317481904} + - component: {fileID: 317481906} m_Layer: 0 m_Name: Object m_TagString: Object @@ -282,8 +256,8 @@ SpriteRenderer: m_AutoUVMaxDistance: 0.5 m_AutoUVMaxAngle: 89 m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 + m_SortingLayerID: -66892319 + m_SortingLayer: 1 m_SortingOrder: 0 m_Sprite: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} @@ -312,6 +286,18 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &317481906 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 317481903} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1ee23683ea369cc46acd31c562ef7a65, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &519420028 GameObject: m_ObjectHideFlags: 0 @@ -405,7 +391,6 @@ GameObject: m_Component: - component: {fileID: 728689084} - component: {fileID: 728689085} - - component: {fileID: 728689086} m_Layer: 0 m_Name: CleanerFluid m_TagString: Untagged @@ -477,140 +462,6 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 ---- !u!61 &728689086 -BoxCollider2D: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 728689083} - m_Enabled: 1 - m_Density: 1 - m_Material: {fileID: 0} - m_IsTrigger: 0 - 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: 5.12, y: 5.12} - newSize: {x: 5.12, y: 5.12} - adaptiveTilingThreshold: 0.5 - drawMode: 0 - adaptiveTiling: 0 - m_AutoTiling: 0 - serializedVersion: 2 - m_Size: {x: 5.12, y: 5.12} - m_EdgeRadius: 0 ---- !u!1 &1038355577 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1038355579} - - component: {fileID: 1038355578} - - component: {fileID: 1038355580} - m_Layer: 0 - m_Name: Gem - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!212 &1038355578 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1038355577} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 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: -66892319 - m_SortingLayer: 1 - m_SortingOrder: 0 - m_Sprite: {fileID: 21300000, guid: f86f46202b4377743b719984d5bb8396, type: 3} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 5.12, y: 5.12} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 - m_MaskInteraction: 0 - m_SpriteSortPoint: 0 ---- !u!4 &1038355579 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1038355577} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -0.18, y: -0.23, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 5 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!61 &1038355580 -BoxCollider2D: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1038355577} - m_Enabled: 1 - m_Density: 1 - m_Material: {fileID: 0} - m_IsTrigger: 0 - 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: 5.12, y: 5.12} - newSize: {x: 5.12, y: 5.12} - adaptiveTilingThreshold: 0.5 - drawMode: 0 - adaptiveTiling: 0 - m_AutoTiling: 0 - serializedVersion: 2 - m_Size: {x: 5.12, y: 5.12} - m_EdgeRadius: 0 --- !u!1 &1425971015 GameObject: m_ObjectHideFlags: 0 @@ -721,6 +572,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 54fe94d557fed4245bd0ad22efbca7b3, type: 3} m_Name: m_EditorClassIdentifier: + Object: {fileID: 317481903} + ObjectSprites: + - {fileID: 21300000, guid: f86f46202b4377743b719984d5bb8396, type: 3} --- !u!4 &1664203757 Transform: m_ObjectHideFlags: 0 @@ -733,7 +587,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 6 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1739945069 GameObject: @@ -745,6 +599,7 @@ GameObject: m_Component: - component: {fileID: 1739945071} - component: {fileID: 1739945070} + - component: {fileID: 1739945073} - component: {fileID: 1739945072} m_Layer: 0 m_Name: SprayBottle @@ -791,7 +646,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: -66892319 m_SortingLayer: 1 - m_SortingOrder: 2 + m_SortingOrder: 3 m_Sprite: {fileID: 21300000, guid: ece481ca0ba584448abe839a124d3429, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -817,8 +672,8 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!61 &1739945072 -BoxCollider2D: +--- !u!60 &1739945072 +PolygonCollider2D: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} @@ -840,9 +695,125 @@ BoxCollider2D: drawMode: 0 adaptiveTiling: 0 m_AutoTiling: 0 - serializedVersion: 2 - m_Size: {x: 5.12, y: 5.12} - m_EdgeRadius: 0 + m_Points: + m_Paths: + - - {x: 1.24, y: -2.06} + - {x: 1.29, y: -1.81} + - {x: 1.3, y: -1.49} + - {x: 1.3299999, y: -1.41} + - {x: 1.36, y: -1.05} + - {x: 1.38, y: -0.56} + - {x: 1.38, y: -0.049999997} + - {x: 1.35, y: 0.04} + - {x: 1.28, y: 0.14} + - {x: 1.14, y: 0.25} + - {x: 0.76, y: 0.35} + - {x: 0.59999996, y: 0.45} + - {x: 0.44, y: 0.59} + - {x: 0.38, y: 0.7} + - {x: 0.35, y: 0.93} + - {x: 0.38, y: 1} + - {x: 0.41, y: 1.15} + - {x: 0.42999998, y: 1.3} + - {x: 0.45, y: 1.65} + - {x: 0.47, y: 1.9699999} + - {x: 0.44, y: 2.01} + - {x: -0.11, y: 2.02} + - {x: -0.22999999, y: 2.04} + - {x: -0.9, y: 2.04} + - {x: -1.01, y: 2.01} + - {x: -1.37, y: 1.9699999} + - {x: -1.4499999, y: 1.89} + - {x: -1.4699999, y: 1.8299999} + - {x: -1.4699999, y: 1.5899999} + - {x: -1.42, y: 1.3199999} + - {x: -1.27, y: 1.2099999} + - {x: -1.16, y: 1.23} + - {x: -1.0699999, y: 1.29} + - {x: -0.81, y: 1.23} + - {x: -0.83, y: 1.09} + - {x: -0.96999997, y: 0.76} + - {x: -0.96, y: 0.68} + - {x: -0.90999997, y: 0.61} + - {x: -0.76, y: 0.62} + - {x: -0.7, y: 0.65} + - {x: -0.42999998, y: 0.93} + - {x: -0.38, y: 0.82} + - {x: -0.39, y: 0.56} + - {x: -0.48, y: 0.37} + - {x: -0.58, y: 0.34} + - {x: -0.71, y: 0.29} + - {x: -1.03, y: 0.25} + - {x: -1.17, y: 0.17} + - {x: -1.4499999, y: -0.12} + - {x: -1.5, y: -0.22} + - {x: -1.56, y: -0.5} + - {x: -1.5899999, y: -1.03} + - {x: -1.5899999, y: -1.86} + - {x: -1.5699999, y: -2.03} + - {x: -1.43, y: -2.3} + - {x: -1.3, y: -2.45} + - {x: -1.23, y: -2.49} + - {x: -0.64, y: -2.5} + - {x: -0.35, y: -2.54} + - {x: -0.19, y: -2.55} + - {x: 0.74, y: -2.55} + - {x: 0.85999995, y: -2.54} + - {x: 1.01, y: -2.49} + - {x: 1.14, y: -2.29} + - - {x: -1.3199999, y: -0.5} + - {x: -1.24, y: -0.22999999} + - {x: -0.9456892, y: -0.4429326} + - {x: -0.96, y: 0.03} + - {x: -0.71, y: 0.049999997} + - {x: -0.761466, y: -0.4145093} + - {x: -0.35, y: 0.17999999} + - {x: -0.13568974, y: 0.7300887} + - {x: -0.2898903, y: -0.4308114} + - {x: 0.29398346, y: -0.33216858} + - {x: 0.14999999, y: 0.84999996} + - {x: 0.16, y: 0.65} + - {x: 0.19, y: 0.53} + - {x: 0.39, y: 0.29999998} + - {x: 0.5006342, y: -0.30840397} + - {x: 0.64, y: 0.14999999} + - {x: 0.81, y: 0.099999994} + - {x: 0.7198019, y: -0.33409262} + - {x: 1.17, y: -0.12} + - {x: 1.18, y: -0.34} + - {x: 0.79999995, y: -0.34} + - {x: 0.68, y: -0.32} + - {x: 0.25, y: -0.32999998} + - {x: 0.13, y: -0.38} + - {x: -0.11, y: -0.42999998} + - {x: -0.41, y: -0.45} + - {x: -0.41, y: -0.44} + - {x: -0.57, y: -0.41} + - {x: -0.82, y: -0.41} + - {x: -0.85999995, y: -0.42} + - {x: -1.0699999, y: -0.47} + - {x: -1.3399999, y: -0.58} +--- !u!50 &1739945073 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1739945069} + m_BodyType: 0 + m_Simulated: 1 + m_UseFullKinematicContacts: 0 + m_UseAutoMass: 0 + m_Mass: 1 + m_LinearDrag: 0 + m_AngularDrag: 0.05 + m_GravityScale: 0 + m_Material: {fileID: 0} + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 --- !u!1 &1885377150 GameObject: m_ObjectHideFlags: 0 @@ -853,6 +824,7 @@ GameObject: m_Component: - component: {fileID: 1885377152} - component: {fileID: 1885377151} + - component: {fileID: 1885377154} - component: {fileID: 1885377153} m_Layer: 0 m_Name: Rag @@ -925,8 +897,8 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!61 &1885377153 -BoxCollider2D: +--- !u!60 &1885377153 +PolygonCollider2D: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} @@ -948,6 +920,114 @@ BoxCollider2D: drawMode: 0 adaptiveTiling: 0 m_AutoTiling: 0 - serializedVersion: 2 - m_Size: {x: 5.12, y: 5.12} - m_EdgeRadius: 0 + m_Points: + m_Paths: + - - {x: -0.53, y: -2.03} + - {x: -0.48999998, y: -1.9399999} + - {x: -0.39999998, y: -1.9399999} + - {x: -0.34, y: -1.93} + - {x: -0.26, y: -1.9499999} + - {x: 0, y: -2.07} + - {x: 0.089999996, y: -2.1299999} + - {x: 0.17999999, y: -2.1499999} + - {x: 0.48, y: -2.1499999} + - {x: 0.62, y: -2.11} + - {x: 0.83, y: -2.03} + - {x: 1.06, y: -1.9399999} + - {x: 1.26, y: -2.03} + - {x: 1.4699999, y: -2.07} + - {x: 1.63, y: -2.09} + - {x: 1.78, y: -2.08} + - {x: 1.8499999, y: -2.04} + - {x: 1.93, y: -1.9699999} + - {x: 2.05, y: -1.9} + - {x: 2.11, y: -1.8299999} + - {x: 2.1399999, y: -1.78} + - {x: 2.19, y: -1.64} + - {x: 2.32, y: -1.37} + - {x: 2.37, y: -1.24} + - {x: 2.4199998, y: -1.01} + - {x: 2.44, y: -0.84} + - {x: 2.44, y: -0.61} + - {x: 2.4199998, y: -0.44} + - {x: 2.37, y: -0.16} + - {x: 2.35, y: -0.08} + - {x: 2.27, y: 0.19} + - {x: 2.24, y: 0.29999998} + - {x: 2.21, y: 0.42} + - {x: 2.1399999, y: 0.61} + - {x: 2.08, y: 0.82} + - {x: 2.04, y: 1.09} + - {x: 2.01, y: 1.28} + - {x: 1.9699999, y: 1.42} + - {x: 1.87, y: 1.5999999} + - {x: 1.7199999, y: 1.81} + - {x: 1.52, y: 1.99} + - {x: 1.37, y: 2.12} + - {x: 1.1899999, y: 2.24} + - {x: 1.0699999, y: 2.28} + - {x: 0.94, y: 2.29} + - {x: 0.76, y: 2.29} + - {x: 0.69, y: 2.26} + - {x: 0.56, y: 2.1299999} + - {x: 0.45999998, y: 2.01} + - {x: 0.41, y: 2.05} + - {x: 0.32999998, y: 2.08} + - {x: 0.26999998, y: 2.1} + - {x: 0.13, y: 2.12} + - {x: -0.08, y: 2.1299999} + - {x: -0.71999997, y: 2.1299999} + - {x: -0.82, y: 2.12} + - {x: -0.94, y: 2.1} + - {x: -1.16, y: 2.04} + - {x: -1.43, y: 1.9599999} + - {x: -1.7099999, y: 1.89} + - {x: -1.92, y: 1.8199999} + - {x: -2.06, y: 1.68} + - {x: -2.09, y: 1.5899999} + - {x: -2.11, y: 1.51} + - {x: -2.12, y: 1.4399999} + - {x: -2.12, y: 1.15} + - {x: -2.1, y: 1.05} + - {x: -2.05, y: 0.87} + - {x: -2, y: 0.74} + - {x: -1.88, y: 0.42999998} + - {x: -1.8299999, y: 0.35} + - {x: -1.7099999, y: -0.049999997} + - {x: -1.67, y: -0.17} + - {x: -1.56, y: -0.52} + - {x: -1.51, y: -0.72999996} + - {x: -1.43, y: -1.04} + - {x: -1.38, y: -1.28} + - {x: -1.35, y: -1.37} + - {x: -1.3, y: -1.49} + - {x: -1.1999999, y: -1.79} + - {x: -1.14, y: -1.9599999} + - {x: -1.09, y: -2.1299999} + - {x: -1.05, y: -2.21} + - {x: -0.96999997, y: -2.29} + - {x: -0.89, y: -2.29} + - {x: -0.78999996, y: -2.28} + - {x: -0.7, y: -2.25} + - {x: -0.59999996, y: -2.1299999} +--- !u!50 &1885377154 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1885377150} + m_BodyType: 0 + m_Simulated: 1 + m_UseFullKinematicContacts: 0 + m_UseAutoMass: 0 + m_Mass: 1 + m_LinearDrag: 0 + m_AngularDrag: 0.05 + m_GravityScale: 0 + m_Material: {fileID: 0} + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 diff --git a/Assets/Scripts/GameScript.cs b/Assets/Scripts/GameScript.cs index 8ecca07..5247cd0 100644 --- a/Assets/Scripts/GameScript.cs +++ b/Assets/Scripts/GameScript.cs @@ -6,6 +6,7 @@ public class GameScript : MonoBehaviour { public GameObject Object; + public Sprite[] ObjectSprites; private bool clicked = false; private GameObject pickedUpItem; @@ -14,6 +15,13 @@ public class GameScript : MonoBehaviour void Start() { clicked = false; + + Object.GetComponent().sprite = + ObjectSprites[Random.Range(0, ObjectSprites.Length)]; + Object.AddComponent(); + + Object.transform.GetChild(0).gameObject.SetActive(true); + } // Update is called once per frame @@ -34,13 +42,14 @@ public class GameScript : MonoBehaviour pickedUpItem = hit.collider.gameObject; clicked = true; Cursor.visible = false; + } else if (hit.collider.gameObject.tag == "Item" && clicked) { clicked = false; Cursor.visible = true; } - Debug.Log("Clicked " + pickedUpItem.name); + //Debug.Log("Clicked " + pickedUpItem.name); }