Added the need for multiple wipes to rid dirt and spray while also fading the dirt and spray texture with each wipe

This commit is contained in:
Gregory Campbell
2020-06-03 18:27:09 -04:00
parent eea7c91968
commit b51a31b643
6 changed files with 30 additions and 3 deletions
+16 -1
View File
@@ -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<SpriteRenderer>().color;
if(other.gameObject.name == "Rag" && sprayed)
{
Destroy(this.gameObject);
wiped++;
tmp.a -= 0.15f;
this.GetComponent<SpriteRenderer>().color = tmp;
if(wiped >= 3) Destroy(this.gameObject);
}
}