diff --git a/Assets/Scripts/DirtScript.cs b/Assets/Scripts/DirtScript.cs index 0c7be59..5e6e16b 100644 --- a/Assets/Scripts/DirtScript.cs +++ b/Assets/Scripts/DirtScript.cs @@ -7,6 +7,8 @@ public class DirtScript : MonoBehaviour public GameObject Spray; private bool sprayed = false; + private int wiped = 0; + Color tmp; void OnCollisionEnter2D(Collision2D other){ @@ -16,9 +18,22 @@ public class DirtScript : MonoBehaviour Instantiate(Spray, new Vector2(this.transform.position.x, this.transform.position.y), Quaternion.identity); } + } + + void OnCollisionExit2D(Collision2D other){ + + tmp = this.GetComponent().color; + if(other.gameObject.name == "Rag" && sprayed) { - Destroy(this.gameObject); + + wiped++; + + tmp.a -= 0.15f; + this.GetComponent().color = tmp; + + if(wiped >= 3) Destroy(this.gameObject); + } } diff --git a/Assets/Scripts/SprayScript.cs b/Assets/Scripts/SprayScript.cs index 62bef36..f0d556b 100644 --- a/Assets/Scripts/SprayScript.cs +++ b/Assets/Scripts/SprayScript.cs @@ -5,11 +5,23 @@ using UnityEngine; public class SprayScript : MonoBehaviour { - void OnCollisionEnter2D(Collision2D other){ + private int wiped = 0; + Color tmp; + + void OnCollisionExit2D(Collision2D other){ + + tmp = this.GetComponent().color; if(other.gameObject.name == "Rag") { - Destroy(this.gameObject); + + wiped++; + + tmp.a -= 0.15f; + this.GetComponent().color = tmp; + + if(wiped >= 3) Destroy(this.gameObject); + } } diff --git a/Assets/Textures/CleanerFluid.png b/Assets/Textures/CleanerFluid.png index 4279bd7..7d681c9 100644 Binary files a/Assets/Textures/CleanerFluid.png and b/Assets/Textures/CleanerFluid.png differ diff --git a/Assets/Textures/CleanerFluid.xcf b/Assets/Textures/CleanerFluid.xcf index 4cfae12..d4c3ed5 100644 Binary files a/Assets/Textures/CleanerFluid.xcf and b/Assets/Textures/CleanerFluid.xcf differ diff --git a/Assets/Textures/Dirt.png b/Assets/Textures/Dirt.png index 2333c41..54be4a6 100644 Binary files a/Assets/Textures/Dirt.png and b/Assets/Textures/Dirt.png differ diff --git a/Assets/Textures/Dirt.xcf b/Assets/Textures/Dirt.xcf index d0bb711..cf8f01c 100644 Binary files a/Assets/Textures/Dirt.xcf and b/Assets/Textures/Dirt.xcf differ