47 lines
1.1 KiB
C#
47 lines
1.1 KiB
C#
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
|
||
|
|
[RequireComponent(typeof(AudioSource))]
|
||
|
|
public class NPCAquaGuardSoundPlay : MonoBehaviour
|
||
|
|
{
|
||
|
|
public AudioSource audioSourceAttack;
|
||
|
|
public AudioClip Attack_A;
|
||
|
|
public AudioClip Attack_B;
|
||
|
|
public AudioClip Attack_C;
|
||
|
|
public AudioClip BulletSoud;
|
||
|
|
private Animator anim;
|
||
|
|
void Awake()
|
||
|
|
{
|
||
|
|
audioSourceAttack = GetComponent<AudioSource>();
|
||
|
|
anim = GetComponent<Animator>();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void PlayA() //used in animation event
|
||
|
|
{
|
||
|
|
float randPitch = UnityEngine.Random.Range(0.85f, 1.2f);
|
||
|
|
Play(Attack_A,randPitch);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void PlayB() //used in animation event
|
||
|
|
{
|
||
|
|
float randPitch = UnityEngine.Random.Range(0.85f, 1.2f);
|
||
|
|
Play(Attack_B,randPitch);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void PlayC() //used in animation event
|
||
|
|
{
|
||
|
|
float randPitch = UnityEngine.Random.Range(0.85f, 1.2f);
|
||
|
|
Play(Attack_C,randPitch);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void PlayBullet()
|
||
|
|
{
|
||
|
|
Play(BulletSoud);
|
||
|
|
} //used in animation event
|
||
|
|
|
||
|
|
private void Play(AudioClip clip, float randPitch = 0)
|
||
|
|
{
|
||
|
|
audioSourceAttack.PlayOneShot(clip);
|
||
|
|
}
|
||
|
|
}
|