public ActionSound( ActionSoundKey key, string soundName) { Key = key; SoundName = soundName; }
public ActionSound( string actionName, string materialName, string soundName) { Key = new ActionSoundKey(actionName, materialName); SoundName = soundName; }
void UpdateAudio() { UpdateListener(); if (IsJumping) { if (jumpSound == null) { var emitter = new AudioEmitter(); UpdateActorEmitter(emitter); var key = new ActionSoundKey("Jump", null); string soundName; if (Character.ActionSounds.TryGetValue(key, out soundName)) { jumpSound = Scene.CharacterAudioManager.CreateSound(soundName, emitter); jumpSound.Play(); } } else if (jumpSound.IsPlaying) { UpdateActorEmitter(jumpSound.Emitter); } } else { if (jumpSound != null) { if (jumpSound.IsDisposed) { jumpSound = null; } else if (jumpSound.IsPlaying) { UpdateActorEmitter(jumpSound.Emitter); } } } if (footstepSound != null) { if (footstepSound.IsDisposed) { footstepSound = null; //footstepStartPartIndex = 0; } else if (footstepSound.IsPlaying) { UpdateActorEmitter(footstepSound.Emitter); } } // 重力方向に対して衝突があるかどうかを判定します。 Vector3 gravity; Character.RigidBody.GetGravity(out gravity); bool isStanding = Character.CollisionBounds.IsCollidedForDirection(ref gravity); if (isStanding) { Vector3 velocity; Character.RigidBody.GetVeclocity(out velocity); velocity.Y = 0; if (0 < velocity.LengthSquared()) { if (footstepSound == null) { var model = Character.ActorModel as CubeAnimateCharacterActorModel; var currentPartIndex = model.CurrentPartIndex; if (footstepStartPartIndex != currentPartIndex) { var emitter = new AudioEmitter(); UpdateActorEmitter(emitter); var key = new ActionSoundKey("Footstep", null); string soundName; if (Character.ActionSounds.TryGetValue(key, out soundName)) { footstepSound = Scene.CharacterAudioManager.CreateSound(soundName, emitter); footstepSound.Play(); footstepStartPartIndex = currentPartIndex; } } } } } }