So much audio stuff holy shit
This commit is contained in:
@@ -5,12 +5,17 @@ using UnityEngine;
|
||||
public class BulletScript : MonoBehaviour
|
||||
{
|
||||
|
||||
public AudioClip[] hit;
|
||||
|
||||
private float speed;
|
||||
private Rigidbody2D rb;
|
||||
private ShakeScript shake;
|
||||
|
||||
private AudioSource audioSource;
|
||||
|
||||
void Start()
|
||||
{
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
rb = GetComponent<Rigidbody2D>();
|
||||
speed = Random.Range(3.0f, 8.0f);
|
||||
shake = GameObject.Find("Shake Manager").GetComponent<ShakeScript>();
|
||||
@@ -29,6 +34,8 @@ public class BulletScript : MonoBehaviour
|
||||
|
||||
if(other.gameObject.tag != "Player" && other.gameObject.tag != "Bullet")
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(
|
||||
hit[Random.Range(0,hit.Length)], new Vector3(0, 0, 0));
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,14 +4,21 @@ using UnityEngine;
|
||||
|
||||
public class EnemyScript : MonoBehaviour
|
||||
{
|
||||
|
||||
public AudioClip[] spawnSounds;
|
||||
public AudioClip[] defeatSounds;
|
||||
|
||||
private float speed;
|
||||
private GameObject player;
|
||||
|
||||
private AudioSource audioSource;
|
||||
|
||||
void Start()
|
||||
{
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
player = GameObject.FindWithTag("Player");
|
||||
speed = Random.Range(0.5f, 3.0f);
|
||||
audioSource.clip = spawnSounds[Random.Range(0,spawnSounds.Length)];
|
||||
audioSource.Play();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -32,11 +39,15 @@ public class EnemyScript : MonoBehaviour
|
||||
if(other.gameObject.tag == "Bullet")
|
||||
{
|
||||
PlayerPrefs.SetInt("Score", PlayerPrefs.GetInt("Score")+1);
|
||||
AudioSource.PlayClipAtPoint(
|
||||
defeatSounds[Random.Range(0,defeatSounds.Length)], new Vector3(0, 0, 0));
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
if(other.gameObject.tag == "Player")
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(
|
||||
defeatSounds[Random.Range(0,defeatSounds.Length)], new Vector3(0, 0, 0));
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,9 @@ public class PlayerScript : MonoBehaviour
|
||||
|
||||
if(other.gameObject.tag == "Enemy")
|
||||
{
|
||||
AudioSource.PlayClipAtPoint(
|
||||
damage[Random.Range(0,damage.Length)], new Vector3(0, 0, 0));
|
||||
|
||||
life--;
|
||||
|
||||
if(life > 0)
|
||||
|
||||
Reference in New Issue
Block a user