Added SFX to entity

This commit is contained in:
Yann Dupont 01 2022-04-03 17:00:42 -04:00
parent b08d297b76
commit 960109e3e4
2 changed files with 13 additions and 1 deletions

View File

@ -254,6 +254,7 @@ public class AIEntity : Entity {
}
public override void EnterState() {
entity.soundManager.PlaySound(entity.attackSource, entity.attackSounds, randomPitch: true, createTempSourceIfBusy: true);
entity.animator.Play("Attack");
}

View File

@ -44,11 +44,19 @@ public class Entity : MonoBehaviour {
[SerializeField] protected Color emptyColor = Color.grey;
[HideInInspector] public Animator animator;
bool beingSucked;
[HideInInspector] public SoundManager soundManager;
[SerializeField] protected AudioSource hurtSource;
[SerializeField] protected AudioSource deathSource;
[SerializeField] protected AudioSource attackSource;
[SerializeField] protected AudioClip[] hurtSounds;
[SerializeField] protected AudioClip[] deathSounds;
[SerializeField] protected AudioClip[] attackSounds;
virtual protected void Awake(){
rb = GetComponent<Rigidbody2D>();
collider = GetComponent<Collider2D>();
animator = GetComponentInChildren<Animator>();
soundManager = FindObjectOfType<SoundManager>();
}
protected virtual void Start() {
@ -95,6 +103,8 @@ public class Entity : MonoBehaviour {
OnDied();
return false;
}
soundManager.PlaySound(hurtSource, hurtSounds, randomPitch:true, createTempSourceIfBusy:true);
return true;
}
@ -122,6 +132,7 @@ public class Entity : MonoBehaviour {
}
protected virtual void OnDied() {
soundManager.PlaySound(deathSource, deathSounds, randomPitch: true, createTempSourceIfBusy: true);
isAlive = false;
if(!(collider is null)){
collider.isTrigger = true;