Added spray and wipe sounds for when dirt gets sprayed on and destroyed respectively
This commit is contained in:
@@ -2,13 +2,22 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(AudioSource))]
|
||||
public class DirtScript : MonoBehaviour
|
||||
{
|
||||
public GameObject Spray;
|
||||
public AudioClip[] WipeSounds;
|
||||
public AudioClip[] SpraySounds;
|
||||
|
||||
private bool sprayed = false;
|
||||
private int wiped = 0;
|
||||
Color tmp;
|
||||
AudioSource soundPlayer;
|
||||
|
||||
void Start()
|
||||
{
|
||||
soundPlayer = GetComponent<AudioSource>();
|
||||
}
|
||||
|
||||
void OnTriggerEnter2D(Collider2D other){
|
||||
|
||||
@@ -16,6 +25,7 @@ public class DirtScript : MonoBehaviour
|
||||
{
|
||||
sprayed = true;
|
||||
Instantiate(Spray, new Vector2(this.transform.position.x, this.transform.position.y), Quaternion.Euler(Random.Range(0, 2)*180, Random.Range(0, 2)*180, 0));
|
||||
soundPlayer.PlayOneShot(SpraySounds[Random.Range(0, SpraySounds.Length)]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,7 +42,13 @@ public class DirtScript : MonoBehaviour
|
||||
tmp.a -= 0.15f;
|
||||
this.GetComponent<SpriteRenderer>().color = tmp;
|
||||
|
||||
if(wiped >= 3) Destroy(this.gameObject);
|
||||
if(wiped >= 3)
|
||||
{
|
||||
|
||||
AudioSource.PlayClipAtPoint(WipeSounds[Random.Range(0, WipeSounds.Length)], Camera.main.transform.position );
|
||||
Destroy(this.gameObject);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user