protected override void WhenAttack() { var sound = new ZombieSoundData() .SetState(ZombieSoundData.State.Attack); PlaySound(sound, Mode.Loop); }
protected override void WhenTrigger() { var sound = new ZombieSoundData() .SetState(ZombieSoundData.State.Trigger); PlaySound(sound, Mode.Loop); }
protected override void WhenDie() { var sound = new ZombieSoundData() .SetState(ZombieSoundData.State.Die); PlaySound(sound, Mode.Once); }
//WhenPatrol() protected override void WhenChasing() { var sound = new ZombieSoundData() .SetState(ZombieSoundData.State.Chasing); PlaySound(sound, Mode.Loop); }
void LoadSounds() { var sd = new ZombieSoundData(); sd.SetDictionary(AudioClipsMap); sd.SetState(ZombieSoundData.State.Idle) .AddToMap(Resources.LoadAll <AudioClip>(idlePatrol)); sd.SetState(ZombieSoundData.State.Patrol) .AddToMap(Resources.LoadAll <AudioClip>(idlePatrol)); sd.SetState(ZombieSoundData.State.Trigger) .AddToMap(Resources.LoadAll <AudioClip>(chasing)); sd.SetState(ZombieSoundData.State.Chasing) .AddToMap(Resources.LoadAll <AudioClip>(chasing)); sd.SetState(ZombieSoundData.State.Attack) .AddToMap(Resources.LoadAll <AudioClip>(attack)); sd.SetState(ZombieSoundData.State.Die) .AddToMap(Resources.LoadAll <AudioClip>(die)); sd.SetState(ZombieSoundData.State.Talk) .AddToMap(Resources.LoadAll <AudioClip>(talk)); sd.SetState(ZombieSoundData.State.Angry) .AddToMap(Resources.LoadAll <AudioClip>(talk)); sd.SetState(ZombieSoundData.State.Bite) .AddToMap(Resources.LoadAll <AudioClip>(eating)); }
protected override void WhenAngry() { var sound = new ZombieSoundData() .SetState(ZombieSoundData.State.Angry); PlaySound(sound, Mode.Once); nowIdlePatrol = false; }
protected override void WhenIdle() { if (nowIdlePatrol) { return; } var sound = new ZombieSoundData() .SetState(ZombieSoundData.State.Idle); PlaySound(sound, Mode.Loop); nowIdlePatrol = true; }
IEnumerator BiteSound() { while (behavior.CurrentState == ZombieBehavior.ZombieState.BITE) { yield return(new WaitForSeconds(0.5f)); if ((Vector3.Distance(controller.Target.position, transform.position) <= zombieData.AttackDist)) { var sound = new ZombieSoundData() .SetState(ZombieSoundData.State.Bite); PlaySound(sound, Mode.Loop); break; } } }
private void PlaySound(ZombieSoundData data, Mode mode) { var audioClip = ZombieSoundManager.Instance .GetRandomSound(data); if (audioSource.isPlaying) { audioSource.Stop(); } if (mode == Mode.Once) { audioSource.loop = false; audioSource.PlayOneShot(audioClip); } else { audioSource.loop = true; audioSource.clip = audioClip; audioSource.Play(); } }
public AudioClip GetRandomSound(ZombieSoundData zombieSoundData) { var clips = GetSounds(zombieSoundData); return(clips[Random.Range(0, clips.Length)]); }
public AudioClip[] GetSounds(ZombieSoundData zombieSoundData) { return(AudioClipsMap[zombieSoundData.Key]); }