add sounds to enemy dead and edit player for shot gun sounds
This commit is contained in:
@@ -12,6 +12,8 @@ public class EnemyManager : MonoBehaviour
|
||||
public float actualHealth;
|
||||
public float findRate = 1;
|
||||
private float findTime = 1;
|
||||
public List<AudioClip> deadSounds = new List<AudioClip>();
|
||||
public AudioSource audio;
|
||||
private NavMeshAgent navMeshAgent;
|
||||
private PlayerManager player;
|
||||
public BarricadeManager barricadeManager;
|
||||
@@ -33,6 +35,11 @@ public class EnemyManager : MonoBehaviour
|
||||
DropBodyPart();
|
||||
if (actualHealth <= 0)
|
||||
{
|
||||
if (deadSounds.Count > 0)
|
||||
{
|
||||
int rand = Random.Range(0, deadSounds.Count);
|
||||
audio.PlayOneShot(deadSounds[rand]);
|
||||
}
|
||||
Destroy(transform.gameObject, 0.1f);
|
||||
}
|
||||
DestroyBarricades();
|
||||
|
@@ -230,7 +230,7 @@ public class PlayerManager : MonoBehaviour
|
||||
BlockManager blockManager = hit.transform.GetComponent<BlockManager>();
|
||||
blockManager.Action();
|
||||
}
|
||||
else if (hit.transform.gameObject.layer == LayerMask.NameToLayer("BuildPlace") && Input.GetKeyDown(KeyCode.E) && buildTime < Time.time && barricadeMaterials > 0)
|
||||
else if (hit.transform.gameObject.layer == LayerMask.NameToLayer("BuildPlace") && Input.GetKeyDown(KeyCode.E) && buildTime < Time.time && barricadeMaterials > 2)
|
||||
{
|
||||
BlockManager blockManager = spikes.GetComponent<BlockManager>();
|
||||
if (blockManager != null)
|
||||
|
@@ -17,7 +17,7 @@ public class WeaponManager : MonoBehaviour
|
||||
public bool hit = false;
|
||||
|
||||
public AudioSource audioSource = new AudioSource();
|
||||
public AudioClip shootSound;
|
||||
public List<AudioClip> shootSound = new List<AudioClip>();
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
@@ -39,7 +39,11 @@ public class WeaponManager : MonoBehaviour
|
||||
if (particleShoot != null && player.ammo > 1)
|
||||
{
|
||||
GameObject shoot = Instantiate(particleShoot, spawnShoot.transform.position, spawnShoot.transform.rotation);
|
||||
audioSource.PlayOneShot(shootSound);
|
||||
if (shootSound.Count > 0)
|
||||
{
|
||||
int rand = Random.Range(0, shootSound.Count);
|
||||
audioSource.PlayOneShot(shootSound[rand]);
|
||||
}
|
||||
player.ammo -= 2;
|
||||
Destroy(shoot, 0.3f);
|
||||
fireTime = fireRate + Time.time;
|
||||
|
Reference in New Issue
Block a user