Exemplo n.º 1
0
    protected override void WhenAttack()
    {
        var sound = new ZombieSoundData()
                    .SetState(ZombieSoundData.State.Attack);

        PlaySound(sound, Mode.Loop);
    }
Exemplo n.º 2
0
    protected override void WhenTrigger()
    {
        var sound = new ZombieSoundData()
                    .SetState(ZombieSoundData.State.Trigger);

        PlaySound(sound, Mode.Loop);
    }
Exemplo n.º 3
0
    protected override void WhenDie()
    {
        var sound = new ZombieSoundData()
                    .SetState(ZombieSoundData.State.Die);

        PlaySound(sound, Mode.Once);
    }
Exemplo n.º 4
0
    //WhenPatrol()
    protected override void WhenChasing()
    {
        var sound = new ZombieSoundData()
                    .SetState(ZombieSoundData.State.Chasing);

        PlaySound(sound, Mode.Loop);
    }
Exemplo n.º 5
0
    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));
    }
Exemplo n.º 6
0
    protected override void WhenAngry()
    {
        var sound = new ZombieSoundData()
                    .SetState(ZombieSoundData.State.Angry);

        PlaySound(sound, Mode.Once);
        nowIdlePatrol = false;
    }
Exemplo n.º 7
0
    protected override void WhenIdle()
    {
        if (nowIdlePatrol)
        {
            return;
        }
        var sound = new ZombieSoundData()
                    .SetState(ZombieSoundData.State.Idle);

        PlaySound(sound, Mode.Loop);
        nowIdlePatrol = true;
    }
Exemplo n.º 8
0
    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;
            }
        }
    }
Exemplo n.º 9
0
    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();
        }
    }
Exemplo n.º 10
0
    public AudioClip GetRandomSound(ZombieSoundData zombieSoundData)
    {
        var clips = GetSounds(zombieSoundData);

        return(clips[Random.Range(0, clips.Length)]);
    }
Exemplo n.º 11
0
 public AudioClip[] GetSounds(ZombieSoundData zombieSoundData)
 {
     return(AudioClipsMap[zombieSoundData.Key]);
 }