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:
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<SpriteRenderer>().color;
|
||||
|
||||
if(other.gameObject.name == "Rag")
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
|
||||
wiped++;
|
||||
|
||||
tmp.a -= 0.15f;
|
||||
this.GetComponent<SpriteRenderer>().color = tmp;
|
||||
|
||||
if(wiped >= 3) Destroy(this.gameObject);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user