Added SFX to entity
This commit is contained in:
parent
b08d297b76
commit
960109e3e4
@ -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");
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user