diff --git a/Assets/Scripts/AIEntity.cs b/Assets/Scripts/AIEntity.cs index 93c86c8..417c364 100644 --- a/Assets/Scripts/AIEntity.cs +++ b/Assets/Scripts/AIEntity.cs @@ -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"); } diff --git a/Assets/Scripts/Entity.cs b/Assets/Scripts/Entity.cs index f0c2422..bdde34e 100644 --- a/Assets/Scripts/Entity.cs +++ b/Assets/Scripts/Entity.cs @@ -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(); collider = GetComponent(); animator = GetComponentInChildren(); + soundManager = FindObjectOfType(); } 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; } @@ -121,7 +131,8 @@ public class Entity : MonoBehaviour { return isAlive; } - protected virtual void OnDied() { + protected virtual void OnDied() { + soundManager.PlaySound(deathSource, deathSounds, randomPitch: true, createTempSourceIfBusy: true); isAlive = false; if(!(collider is null)){ collider.isTrigger = true;