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() {
|
public override void EnterState() {
|
||||||
|
entity.soundManager.PlaySound(entity.attackSource, entity.attackSounds, randomPitch: true, createTempSourceIfBusy: true);
|
||||||
entity.animator.Play("Attack");
|
entity.animator.Play("Attack");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -44,11 +44,19 @@ public class Entity : MonoBehaviour {
|
|||||||
[SerializeField] protected Color emptyColor = Color.grey;
|
[SerializeField] protected Color emptyColor = Color.grey;
|
||||||
[HideInInspector] public Animator animator;
|
[HideInInspector] public Animator animator;
|
||||||
bool beingSucked;
|
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(){
|
virtual protected void Awake(){
|
||||||
rb = GetComponent<Rigidbody2D>();
|
rb = GetComponent<Rigidbody2D>();
|
||||||
collider = GetComponent<Collider2D>();
|
collider = GetComponent<Collider2D>();
|
||||||
animator = GetComponentInChildren<Animator>();
|
animator = GetComponentInChildren<Animator>();
|
||||||
|
soundManager = FindObjectOfType<SoundManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Start() {
|
protected virtual void Start() {
|
||||||
@ -95,6 +103,8 @@ public class Entity : MonoBehaviour {
|
|||||||
OnDied();
|
OnDied();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
soundManager.PlaySound(hurtSource, hurtSounds, randomPitch:true, createTempSourceIfBusy:true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +131,8 @@ public class Entity : MonoBehaviour {
|
|||||||
return isAlive;
|
return isAlive;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnDied() {
|
protected virtual void OnDied() {
|
||||||
|
soundManager.PlaySound(deathSource, deathSounds, randomPitch: true, createTempSourceIfBusy: true);
|
||||||
isAlive = false;
|
isAlive = false;
|
||||||
if(!(collider is null)){
|
if(!(collider is null)){
|
||||||
collider.isTrigger = true;
|
collider.isTrigger = true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user