diff --git a/Assets/Prefabs/Dirt.prefab b/Assets/Prefabs/Dirt.prefab index 8d9efeb..bcbe646 100644 --- a/Assets/Prefabs/Dirt.prefab +++ b/Assets/Prefabs/Dirt.prefab @@ -14,7 +14,7 @@ GameObject: - component: {fileID: -4157908487798694971} m_Layer: 0 m_Name: Dirt - m_TagString: Untagged + m_TagString: Dirt m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 diff --git a/Assets/Scripts/GameScript.cs b/Assets/Scripts/GameScript.cs index 75e3cec..44e11a9 100644 --- a/Assets/Scripts/GameScript.cs +++ b/Assets/Scripts/GameScript.cs @@ -10,33 +10,14 @@ public class GameScript : MonoBehaviour public Sprite[] ObjectSprites; private bool clicked = false; + private int objectsPolished = 0; private GameObject pickedUpItem; // Start is called before the first frame update void Start() { - clicked = false; - - float sizeChange = Random.Range(0.75f, 1.5f); - - Object.GetComponent().sprite = - ObjectSprites[Random.Range(0, ObjectSprites.Length)]; - Object.transform.localScale *= sizeChange; - Object.AddComponent(); - Object.GetComponent().size *= sizeChange; - - Vector3 boundary = Object.GetComponent().size * 0.45f; - - Destroy(Object.GetComponent()); - Object.AddComponent(); - - for(int i = 0; i < Random.Range(10, 30); i++) - { - float xBound = Random.Range(-boundary.x, boundary.x); - float yBound = Random.Range(-boundary.y, boundary.y); - - Instantiate(Dirt, new Vector2(xBound, yBound), Quaternion.identity); - } + + Setup(); } @@ -63,6 +44,16 @@ public class GameScript : MonoBehaviour { clicked = false; Cursor.visible = true; + + if(pickedUpItem.name == "Rag") + { + pickedUpItem.transform.position = new Vector2(7.25f, 2.5f); + } else if (pickedUpItem.name == "SprayBottle"){ + pickedUpItem.transform.position = new Vector2(7.25f, -2.5f); + } + + pickedUpItem.transform.rotation = Quaternion.identity; + pickedUpItem = null; } //Debug.Log("Clicked " + pickedUpItem.name); @@ -77,8 +68,50 @@ public class GameScript : MonoBehaviour } if (GameObject.FindWithTag("Dirt") == null) { + Setup(); + objectsPolished++; //Debug.Log("Beat the game/Next Level"); } } + + void Setup() + { + clicked = false; + Cursor.visible = true; + Object.transform.localScale = new Vector3(1, 1, 1); + Object.GetComponent().sprite = null; + + if(pickedUpItem != null && pickedUpItem.name == "Rag") + { + pickedUpItem.transform.position = new Vector2(7.25f, 2.5f); + pickedUpItem.transform.rotation = Quaternion.identity; + } else if (pickedUpItem != null && pickedUpItem.name == "SprayBottle"){ + pickedUpItem.transform.position = new Vector2(7.25f, -2.5f); + pickedUpItem.transform.rotation = Quaternion.identity; + } + + pickedUpItem = null; + + float sizeChange = Random.Range(0.75f, 1.5f); + + Object.GetComponent().sprite = + ObjectSprites[Random.Range(0, ObjectSprites.Length)]; + Object.transform.localScale *= sizeChange; + Object.AddComponent(); + Object.GetComponent().size *= sizeChange; + + Vector3 boundary = Object.GetComponent().size * 0.45f; + + Destroy(Object.GetComponent()); + Object.AddComponent(); + + for(int i = 0; i < Random.Range(10, 30); i++) + { + float xBound = Random.Range(-boundary.x, boundary.x); + float yBound = Random.Range(-boundary.y, boundary.y); + + Instantiate(Dirt, new Vector2(xBound, yBound), Quaternion.identity); + } + } }