public FootstepAudioPlayer GetPlayerFootstep() { FootstepAudioPlayer playerFootstep = null; foreach (FootstepAudioPlayer footstep in _playerFootsteps) { if (!footstep.gameObject.activeSelf) { footstep.gameObject.SetActive(true); playerFootstep = footstep; break; } } if (playerFootstep == null) { Debug.LogWarning("PlayerFootstep object pool not big enough! Adding."); GameObject footstep = new GameObject("Player Footstep"); footstep.layer = LayerMask.NameToLayer("SoundStealth"); footstep.transform.parent = transform; footstep.AddComponent <SoundEvent>(); playerFootstep = footstep.AddComponent <FootstepAudioPlayer>(); playerFootstep.Lifetime = 10; _playerFootsteps.Add(playerFootstep); } return(playerFootstep); }
void OnTriggerEnter(Collider other) { // Manage the list of sounds this character has heard SoundEvent sound = other.GetComponent <SoundEvent>(); FootstepAudioPlayer footstep = other.GetComponent <FootstepAudioPlayer>(); if (sound && footstep != null && footstep.LifetimeLived == 0) { // NOTE: THE SIMPLICITY OF THIS SPHERECOLLIDER ALLOWS SOUNDS TO BE HEARD THROUGH WALLS sound.HeardBy.Add(this); // HACK: THIS CHECK ALLOWS BABYBOT TO NOT HEAR THE SIGHT PUZZLE IN THE SEWER TUTORIAL if (!IgnoreAbove || other.transform.position.y < 70) { _objectsHeard.AddFirst(sound); } } HeartBox heart = other.GetComponent <HeartBox>(); if (heart && !_charactersCouldHear.Contains(heart)) { _charactersCouldHear.Add(heart); } OutlineInteractive barrier = other.GetComponent <OutlineInteractive>(); if (barrier && !_barriers.Contains(barrier)) { _barriers.Add(barrier); } }
public FootstepAudioPlayer CreateRobotFootstep(Vector3 position, AudioClip clip, float volume) { FootstepAudioPlayer robotFootstep = GetRobotFootstep(); robotFootstep.transform.position = position; robotFootstep.Play(clip, volume); return(robotFootstep); }
public FootstepAudioPlayer CreatePlayerFootstep(Vector3 position, AudioClip clip, float volume) { FootstepAudioPlayer playerFootstep = GetPlayerFootstep(); playerFootstep.transform.position = position; playerFootstep.Play(clip, volume); return(playerFootstep); }
void Start() { _playerFootsteps = new List <FootstepAudioPlayer>(); for (int i = 0; i < 75; i++) { GameObject footstep = new GameObject("Footstep - Player"); footstep.layer = LayerMask.NameToLayer("SoundStealth"); footstep.transform.parent = transform; footstep.AddComponent <SoundEvent>(); FootstepAudioPlayer footAudio = footstep.AddComponent <FootstepAudioPlayer>(); footAudio.Lifetime = 10; footstep.gameObject.SetActive(false); _playerFootsteps.Add(footAudio); } _robotFootsteps = new List <FootstepAudioPlayer>(); for (int i = 0; i < 100; i++) { GameObject footstep = new GameObject("Footstep - Robot"); footstep.layer = LayerMask.NameToLayer("SoundStealth"); footstep.transform.parent = transform; FootstepAudioPlayer footAudio = footstep.AddComponent <FootstepAudioPlayer>(); _robotFootsteps.Add(footAudio); } _hitboxes = new List <HitBox>(); for (int i = 0; i < 25; i++) { GameObject hitbox = new GameObject("Hitbox"); hitbox.transform.parent = transform; _hitboxes.Add(hitbox.AddComponent <HitBox>()); } // Load the particle effects for the hitboxes _gravityGunShot = Resources.Load("Prefabs/Particles/Babybot Explosion") as GameObject; _vetoGunShot = Resources.Load("Prefabs/Particles/Babybot Explosion") as GameObject; _mineExplosion = Resources.Load("Prefabs/Particles/Babybot Explosion") as GameObject; _babyBotExplosion = Resources.Load("Prefabs/Particles/Babybot Explosion") as GameObject; _ready = true; }