private void setSlideTargetVolumes(PhysSoundBase otherObject, Vector3 relativeVelocity, Vector3 normal, Vector3 contactPoint, bool exit) { PhysSoundMaterial m = null; if (otherObject) { //Special case for sliding against a terrain if (otherObject is PhysSoundTerrain) { PhysSoundTerrain terr = otherObject as PhysSoundTerrain; Dictionary <int, PhysSoundComposition> compDic = terr.GetComposition(contactPoint); foreach (PhysSoundAudioContainer c in audioContainersDic.Values) { PhysSoundComposition comp; float mod = 0; if (compDic.TryGetValue(c.KeyIndex, out comp)) { mod = comp.GetAverage(); } c.SetTargetVolumeAndPitch(SoundMaterial, relativeVelocity, normal, exit, mod); } return; } else { m = otherObject.GetPhysSoundMaterial(contactPoint); } } //General cases //If the other object has a PhysSound material if (m) { PhysSoundAudioContainer aud; if (audioContainersDic.TryGetValue(m.MaterialTypeKey, out aud)) { aud.SetTargetVolumeAndPitch(SoundMaterial, relativeVelocity, normal, exit); } else if (SoundMaterial.FallbackTypeKey != -1 && audioContainersDic.TryGetValue(SoundMaterial.FallbackTypeKey, out aud)) { aud.SetTargetVolumeAndPitch(SoundMaterial, relativeVelocity, normal, exit); } } //If it doesnt we set vols based on the fallback setting of our material else { PhysSoundAudioContainer aud; if (SoundMaterial.FallbackTypeKey != -1 && audioContainersDic.TryGetValue(SoundMaterial.FallbackTypeKey, out aud)) { aud.SetTargetVolumeAndPitch(SoundMaterial, relativeVelocity, normal, exit); } } }
private void setSlideTargetVolumes(GameObject otherObject, Vector3 relativeVelocity, Vector3 normal, Vector3 contactPoint, bool exit) { //log("Sliding! " + gameObject.name + " against " + otherObject.name + " - Relative Velocity: " + relativeVelocity + ", Normal: " + normal + ", Contact Point: " + contactPoint + ", Exit: " + exit); if (SoundMaterial == null || !this.enabled || SoundMaterial.AudioSets.Count == 0) { return; } PhysSoundMaterial m = null; PhysSoundBase b = otherObject == null ? null : otherObject.GetComponent <PhysSoundBase>(); if (b) { //Special case for sliding against a terrain if (b is PhysSoundTerrain) { PhysSoundTerrain terr = b as PhysSoundTerrain; Dictionary <int, PhysSoundComposition> compDic = terr.GetComposition(contactPoint); foreach (PhysSoundAudioContainer c in _audioContainersDic.Values) { PhysSoundComposition comp; float mod = 0; if (compDic.TryGetValue(c.KeyIndex, out comp)) { mod = comp.GetAverage(); } c.SetTargetVolumeAndPitch(this.gameObject, otherObject, relativeVelocity, normal, exit, mod); } return; } else { m = b.GetPhysSoundMaterial(contactPoint); } } //General cases //If the other object has a PhysSound material if (m) { PhysSoundAudioContainer aud; if (_audioContainersDic.TryGetValue(m.MaterialTypeKey, out aud)) { aud.SetTargetVolumeAndPitch(this.gameObject, otherObject, relativeVelocity, normal, exit); } else if (!SoundMaterial.HasAudioSet(m.MaterialTypeKey) && SoundMaterial.FallbackTypeKey != -1 && _audioContainersDic.TryGetValue(SoundMaterial.FallbackTypeKey, out aud)) { aud.SetTargetVolumeAndPitch(this.gameObject, otherObject, relativeVelocity, normal, exit); } } //If it doesnt we set volumes based on the fallback setting of our material else { PhysSoundAudioContainer aud; if (SoundMaterial.FallbackTypeKey != -1 && _audioContainersDic.TryGetValue(SoundMaterial.FallbackTypeKey, out aud)) { aud.SetTargetVolumeAndPitch(this.gameObject, otherObject, relativeVelocity, normal, exit); } } }