diff --git a/Assets/Scenes/Main Scene.unity b/Assets/Scenes/Main Scene.unity index b6c78a7..19b02d7 100644 --- a/Assets/Scenes/Main Scene.unity +++ b/Assets/Scenes/Main Scene.unity @@ -360,7 +360,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1425971015} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -0.07614236, y: 0.02538085, z: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} @@ -397,6 +397,7 @@ MonoBehaviour: m_EditorClassIdentifier: Object: {fileID: 317481903} Dirt: {fileID: 5810670192936853663, guid: 6c319566e78e59d4b848e83cbf6cb8c5, type: 3} + Restart: {fileID: 2120053446} ObjectSprites: - {fileID: 21300000, guid: f86f46202b4377743b719984d5bb8396, type: 3} - {fileID: 21300000, guid: bf9a4d7870709424d95eaad944a6363b, type: 3} @@ -829,3 +830,111 @@ Rigidbody2D: m_SleepingMode: 1 m_CollisionDetection: 1 m_Constraints: 0 +--- !u!1 &2120053446 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2120053449} + - component: {fileID: 2120053448} + - component: {fileID: 2120053447} + m_Layer: 0 + m_Name: Restart + m_TagString: Restart + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!61 &2120053447 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2120053446} + 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: 2.56} + newSize: {x: 5.12, y: 2.56} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 5.12, y: 2.56} + m_EdgeRadius: 0 +--- !u!212 &2120053448 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2120053446} + 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: -125711741 + m_SortingLayer: 2 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: 37bbc33a2db94e3488a80d2998d18e82, 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: 2.56} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!4 &2120053449 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2120053446} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: -2, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scripts/GameScript.cs b/Assets/Scripts/GameScript.cs index 3ecacda..8729fae 100644 --- a/Assets/Scripts/GameScript.cs +++ b/Assets/Scripts/GameScript.cs @@ -7,9 +7,9 @@ public class GameScript : MonoBehaviour public GameObject Object; public GameObject Dirt; + public GameObject Restart; public Sprite[] ObjectSprites; - private bool clickDown = false; private bool clicked = false; private bool gameOver = false; private int objectsPolished = 0; @@ -28,32 +28,29 @@ public class GameScript : MonoBehaviour // Update is called once per frame void Update() { + if (Input.GetMouseButtonDown(0)) { - clickDown = true; - } - } - - void FixedUpdate() - { - - timer += Time.deltaTime; - float seconds = timeLimit - timer; - - //Debug.Log((int)seconds); - - Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); - Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y); - - if (clickDown) - { - - clickDown = false; - - RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero); + Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); + Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y); + RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero); + if (hit.collider != null) { + + if(hit.collider.gameObject.tag == "Restart" && gameOver) + { + + Restart.SetActive(false); + Object.SetActive(true); + Setup(); + gameOver = false; + timer = 0.0f; + objectsPolished = 0; + + } + if (hit.collider.gameObject.tag == "Item" && !clicked && !gameOver) { pickedUpItem = hit.collider.gameObject; @@ -82,6 +79,21 @@ public class GameScript : MonoBehaviour } + + } + + + void FixedUpdate() + { + + timer += Time.deltaTime; + float seconds = timeLimit - timer; + + Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); + Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y); + + //Debug.Log((int)seconds); + if(clicked) { pickedUpItem.transform.position = mousePos2D; @@ -110,6 +122,8 @@ public class GameScript : MonoBehaviour GameObject[] leftovers = GameObject.FindGameObjectsWithTag("Dirt"); foreach(GameObject residue in leftovers) GameObject.Destroy(residue); + + Restart.SetActive(true); } diff --git a/Assets/Textures/Restart.png b/Assets/Textures/Restart.png new file mode 100644 index 0000000..6ca3c98 Binary files /dev/null and b/Assets/Textures/Restart.png differ diff --git a/Assets/Textures/Restart.png.meta b/Assets/Textures/Restart.png.meta new file mode 100644 index 0000000..0208f13 --- /dev/null +++ b/Assets/Textures/Restart.png.meta @@ -0,0 +1,92 @@ +fileFormatVersion: 2 +guid: 37bbc33a2db94e3488a80d2998d18e82 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Textures/Restart.xcf b/Assets/Textures/Restart.xcf new file mode 100644 index 0000000..23cb26b Binary files /dev/null and b/Assets/Textures/Restart.xcf differ diff --git a/Assets/Textures/Restart.xcf.meta b/Assets/Textures/Restart.xcf.meta new file mode 100644 index 0000000..1ebf81c --- /dev/null +++ b/Assets/Textures/Restart.xcf.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 240c241852845174b83fa5c770c325dc +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 7d8073c..0f87f2d 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -7,6 +7,7 @@ TagManager: - Object - Item - Dirt + - Restart layers: - Default - TransparentFX