Ejemplo n.º 1
0
    private void MakeNoise(Noise.Type type)
    {
        Noise noise = new Noise();

        noise.m_Position = this.m_Player.transform.position;
        noise.m_Time     = Time.time;
        noise.m_Type     = type;
        this.m_NoiseManager.MakeNoise(noise);
    }
Ejemplo n.º 2
0
    public void PlayFootstepSound()
    {
        if ((Player.Get().GetFPPController().m_LastCollisionFlags & CollisionFlags.Below) == CollisionFlags.None)
        {
            return;
        }
        Vector3 wantedSpeed = this.m_FPPController.m_WantedSpeed;

        wantedSpeed.y = 0f;
        if (wantedSpeed.magnitude < 0.1f)
        {
            return;
        }
        if (Time.time - this.m_LastFootstepSound < 0.1f)
        {
            return;
        }
        List <AudioClip> list            = null;
        bool             flag            = Player.Get().GetFPPController().IsRunning();
        EObjectMaterial  eobjectMaterial = EObjectMaterial.Unknown;

        if (this.m_Player.IsInWater() && !this.m_Player.m_SwimController.IsActive())
        {
            list = ((!flag) ? this.m_ShallowWaterWalkSounds : this.m_ShallowWaterRunSounds);
        }
        else
        {
            eobjectMaterial = Player.Get().GetMaterial();
            switch (eobjectMaterial)
            {
            case EObjectMaterial.Unknown:
            case EObjectMaterial.Sand:
                list = ((!flag) ? this.m_SandStepWalkSounds : this.m_SandStepRunSounds);
                break;

            case EObjectMaterial.Bush:
            case EObjectMaterial.Grass:
                list = ((!flag) ? this.m_GrassStepWalkSounds : this.m_GrassStepRunSounds);
                break;

            case EObjectMaterial.Stone:
                list = ((!flag) ? this.m_StoneStepWalkSounds : this.m_StoneStepRunSounds);
                break;

            case EObjectMaterial.DryLeaves:
                list = ((!flag) ? this.m_DryLeavesStepWalkSounds : this.m_DryLeavesStepRunSounds);
                break;

            case EObjectMaterial.Mud:
                list = ((!flag) ? this.m_MudStepWalkSounds : this.m_MudStepRunSounds);
                break;

            case EObjectMaterial.Soil:
                list = ((!flag) ? this.m_SoilStepWalkSounds : this.m_SoilStepRunSounds);
                break;
            }
        }
        Noise.Type noise_type = Noise.Type.None;
        if (FPPController.Get().IsWalking())
        {
            noise_type = ((!FPPController.Get().IsDuck()) ? Noise.Type.Walk : Noise.Type.Sneak);
        }
        else if (flag)
        {
            noise_type = ((!FPPController.Get().IsDuck()) ? Noise.Type.Run : Noise.Type.Sneak);
        }
        else if (SwimController.Get().IsSwimming())
        {
            noise_type = Noise.Type.Swim;
        }
        if (list == null)
        {
            Debug.Log("ERROR PlayerAudioModule PlayFootstepSound no sounds clips player_pos=" + Player.Get().transform.position.ToString() + " Material = " + eobjectMaterial.ToString());
        }
        this.PlayRandomSound(list, 1f, false, noise_type);
        this.m_LastFootstepSound = Time.time;
    }
Ejemplo n.º 3
0
    public AudioSource PlayRandomSound(List <AudioClip> clips, float volume = 1f, bool loop = false, Noise.Type noise_type = Noise.Type.None)
    {
        if (clips == null || clips.Count == 0)
        {
            return(null);
        }
        if (clips.Count == 1)
        {
            return(this.PlaySound(clips[0], volume, loop, noise_type));
        }
        int       index     = UnityEngine.Random.Range(1, clips.Count);
        AudioClip audioClip = clips[index];

        clips[index] = clips[0];
        clips[0]     = audioClip;
        return(this.PlaySound(audioClip, volume, loop, noise_type));
    }
Ejemplo n.º 4
0
 private AudioSource PlaySound(AudioSource source, AudioClip clip, float volume = 1f, bool loop = false, Noise.Type noise_Type = Noise.Type.None)
 {
     if (!source || !clip)
     {
         return(null);
     }
     source.clip   = clip;
     source.loop   = loop;
     source.volume = volume;
     source.Play();
     if (noise_Type != Noise.Type.None)
     {
         this.MakeNoise(noise_Type);
     }
     return(source);
 }
Ejemplo n.º 5
0
 public AudioSource PlaySound(AudioClip clip, float volume = 1f, bool loop = false, Noise.Type noise_type = Noise.Type.None)
 {
     return(this.PlaySound(this.GetFreeSource(), clip, volume, loop, noise_type));
 }