public virtual void Death() { anim.Stop(true); anim.Play(dieAnimName); if (disableCollidersOnDeath) { foreach (Collider collider in colliders) { collider.enabled = false; } } if (lookAtPlayer != null) { lookAtPlayer.enabled = false; } if (triggerOnDeath != null) { triggerOnDeath.Trigger(); } SoundEffect.Settings deathSoundSettings = new SoundEffect.Settings(); deathSoundSettings.audioClip = AudioManager.Instance.deathSounds[Random.Range(0, AudioManager.Instance.deathSounds.Length)]; deathSoundSettings.speakerTrs = trs; AudioManager.Instance.MakeSoundEffect(deathSoundSettings); makeMagicIndicator.enabled = false; if (prefabIndex != -1) { ObjectPool.Instance.DelayDespawn(prefabIndex, gameObject, trs, despawnDelay); } else { Destroy(gameObject, despawnDelay); } GameManager.updatables = GameManager.updatables.Remove(this); }
public virtual SoundEffect MakeSoundEffect(SoundEffect.Settings soundEffectSettings) { SoundEffect output = Instantiate(soundEffectPrefab, soundEffectSettings.Position, soundEffectSettings.Rotation); output.settings = soundEffectSettings; output.Play(); return(output); }
public override void ApplyDamage(IDestructable destructable, float amount) { if (destructable.Hp == 0) { return; } base.ApplyDamage(destructable, amount); if (destructable.Hp == 0 && shooter != null) { SoundEffect.Settings deathResponseSettings = new SoundEffect.Settings(); deathResponseSettings.audioClip = AudioManager.Instance.deathResponses[Random.Range(0, AudioManager.Instance.deathResponses.Length)]; deathResponseSettings.persistant = true; SoundEffect soundEffect = AudioManager.Instance.MakeSoundEffect(deathResponseSettings); soundEffect.trs.SetParent(shooter); soundEffect.trs.localPosition = Vector3.zero; soundEffect.trs.localEulerAngles = Vector3.zero; } }