public void PlayMusic(AudioEvent audioEvent, bool force = false) { if (Music || force) { audioEvent.Play(sourceMusic); } }
public void OnUnitySampleBuffer(AudioEvent audioEvent, float[] sampleBuffer, long timestamp, Format unused2) { if (audioEvent == AudioEvent.OnSampleBuffer) { unityBuffer.Write(sampleBuffer); } }
public void PlaySFX(AudioEvent audioEvent, bool force = false) { if (Sounds || force) { audioEvent.Play(sourceEffects); } }
private void PlayAudioEvent(AudioEvent audioE, AudioSource audioS) { if (audioE != null && audioS != null) { audioE.Play(audioS); } }
public void OnMicrophoneSampleBuffer(AudioEvent audioEvent, float[] sampleBuffer, long timestamp, Format unused2) { if (audioEvent == AudioEvent.OnSampleBuffer) { commitBuffer.Write(sampleBuffer); } }
public static void PostEventAtPosition(GameObject controllingObject, AudioEvent postEvent, Vector3 position) { if (instance != null && controllingObject != null && postEvent != null) { instance.OnPostEventAtPosition(controllingObject, postEvent, position); } }
private void LogIfCustomEventMissing(AudioEvent aEvent) { if (!logMissingEvents) { return; } if (aEvent.isCustomEvent) { if (!aEvent.customSoundActive || string.IsNullOrEmpty(aEvent.customEventName)) { return; } } else { if (aEvent.currentSoundFunctionType != MasterAudio.EventSoundFunctionType.CustomEventControl) { return; } } string customEventName = aEvent.customEventName; if (!MasterAudio.CustomEventExists(customEventName)) { MasterAudio.LogWarning("Transform '" + this.name + "' is set up to receive or fire Custom Event '" + customEventName + "', which does not exist in Master Audio."); } }
private void OnPostEventAtPosition(GameObject controllingObject, AudioEvent audioEvent, Vector3 position) { if (instance != null && controllingObject != null && audioEvent != null) { instance.OnPostEvent(controllingObject, audioEvent, position); } }
private void OnPostEvent(GameObject controllingObject, AudioEvent postEvent, Vector3 postAt) { bool areAnyDelayed = false; if (postEvent.Delay > 0) { StartCoroutine(DelayedEvent(controllingObject, postEvent, postAt)); } else { areAnyDelayed = PostUndelayedActions(controllingObject, postEvent, postAt); } if (areAnyDelayed) { for (int i = 0; i < postEvent.ActionList.Count; ++i) { var eventData = postEvent.ActionList[i]; if (eventData != null && eventData.Delay > 0) { StartCoroutine(PostDelayedActions(controllingObject, eventData, postAt)); } } } }
/******************/ /*Public interface*/ /******************/ #region Post Event by reference public static void PostEvent(GameObject controllingObject, AudioEvent postEvent) { if (instance != null && controllingObject != null && postEvent != null) { instance.OnPostEvent(controllingObject, postEvent, controllingObject); } }
public static void PostEventAttachedTo(GameObject controllingObject, AudioEvent postEvent, GameObject attachedToOther) { if (instance != null && controllingObject != null && postEvent != null) { instance.OnPostEvent(controllingObject, postEvent, attachedToOther); } }
/// <summary> /// Performs Dash Action if charged or Move otherwise. /// </summary> public void Release(Vector3 direction) { // Play Animation _anim.Release(); // Play Sound AudioEvent.SendAudioEvent( IsDashing ? AudioEvent.AudioEventType.ChargedDash : AudioEvent.AudioEventType.Dash, _audioEvents, gameObject ); // Initiate Vibration if (IsDashing) { Vibration.Vibrate(200); } // Perform Action _attachToPlane.Detach(); StartCoroutine(MoveRoutine( transform.position + direction * (IsDashing ? DashDistance: MoveDistance), IsDashing ? DashDuration : MoveDuration )); // Reset State IsCharging = false; IsDashing = false; _dashTimer = 0; }
public override void OnEnterState(AudioEvent audioEvent) { //todo do some initialize work base.OnEnterState(audioEvent); AudioEvent.Loaded = false; AudioEvent.EnterState("ToPlay"); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); AudioEvent audioListener = target as AudioEvent; switch (audioListener.WwiseType) { case AudioEvent.WwiseFunction.PostEvent: audioListener.EventName = EditorGUILayout.TextField("Event Name: ", audioListener.EventName); break; case AudioEvent.WwiseFunction.RTPCValue: audioListener.RTPCName = EditorGUILayout.TextField("RTPC Value: ", audioListener.RTPCName); audioListener.RTPCValue = EditorGUILayout.ObjectField("Float Variable: ", audioListener.RTPCValue, typeof(FloatVariable)) as FloatVariable; break; case AudioEvent.WwiseFunction.State: audioListener.SetStateGroup = EditorGUILayout.TextField("State Group: ", audioListener.SetStateGroup); audioListener.SetStateValue = EditorGUILayout.TextField("State Value: ", audioListener.SetStateValue); break; case AudioEvent.WwiseFunction.PostEventName: audioListener.EventName = audioListener.TriggerType.ToString(); break; } }
void Awake() { if (!overrideDefaults) { dopplerLevel = 0.0f; minDistance = 1f; maxDistance = 400f; } if (instantiateEvents) { for (int i = 0; i < audioEvents.Count; i++) { string str = audioEvents[i].name; AudioEvent instance = Instantiate(audioEvents[i]); audioEvents[i] = instance; instance.name = str; } } foreach (AudioEvent e in audioEvents) { e.Initialize(this); } }
void TryPlayingEvent(AudioEvent audioEvent) { if (audioEvent != null) { audioEvent.Play(true); } }
private void PlaySound(AudioEvent aEvent) { if (disableSounds) { return; } float volume = aEvent.volume; string sType = aEvent.soundType; float? pitch = aEvent.pitch; if (!aEvent.useFixedPitch) { pitch = null; } PlaySoundResult soundPlayed = null; switch (soundSpawnMode) { case MasterAudio.SoundSpawnLocationMode.CallerLocation: soundPlayed = MasterAudio.PlaySound3D(sType, this.trans, false, volume, pitch); break; case MasterAudio.SoundSpawnLocationMode.AttachToCaller: soundPlayed = MasterAudio.PlaySound3D(sType, this.trans, true, volume, pitch); break; case MasterAudio.SoundSpawnLocationMode.MasterAudioLocation: soundPlayed = MasterAudio.PlaySound(sType, volume); break; } if (soundPlayed == null || !soundPlayed.SoundPlayed) { return; } if (aEvent.emitParticles) { MasterAudio.TriggerParticleEmission(this.trans, aEvent.particleCountToEmit); } }
public void Init(AudioEvent myEvent) { this.myEvent = myEvent; switch (condition) { case Condition.EnergyGreaterThan: case Condition.EnergyLessThan: if (energy) { energy.EnergyEvent += new EnergyEventHandler(EnergyListener); } else { Debug.LogError("Event will never auto-trigger because you haven't given it an Energy object."); } break; case Condition.TimeElapsed: StartTimeElapsed(); break; case Condition.BeatsElapsed: StartBeatsElapsed(); break; } }
public void EnablePopUpButton() { GameObject canvas = GameObject.FindGameObjectWithTag(PopUpCanvasTag); if (canvas == null) { Debug.LogWarning("Unable to find Pop-up canvas to display image on"); } else { if (gameObject.CompareTag("pic1")) { AudioEvent.SendAudioEvent(AudioEvent.AudioEventType.PictureOff_01, audioEvents, gameObject); } else if (gameObject.CompareTag("pic2")) { AudioEvent.SendAudioEvent(AudioEvent.AudioEventType.PictureOff_02, audioEvents, gameObject); } else if (gameObject.CompareTag("pic3")) { AudioEvent.SendAudioEvent(AudioEvent.AudioEventType.PictureOff_03, audioEvents, gameObject); } else if (gameObject.CompareTag("pic4")) { AudioEvent.SendAudioEvent(AudioEvent.AudioEventType.PictureOff_04, audioEvents, gameObject); } PopUpCanvas popUpCanvasComponent = canvas.GetComponent <PopUpCanvas>(); popUpCanvasComponent.EnableButton(); } }
static string GetAudioEventTooltip(AudioEvent ev) { switch (ev.currentSoundFunctionType) { case MasterAudio.EventSoundFunctionType.PlaySound: { var bus = GetGroupBus(ev.soundType); if (bus != null) { return("Bus: " + bus.busName); } } break; case MasterAudio.EventSoundFunctionType.GroupControl: { if (ev.allSoundTypesForGroupCmd) { return(string.Empty); } var bus = GetGroupBus(ev.soundType); if (bus != null) { return("Bus: " + bus.busName); } } break; default: return(string.Empty); } return(string.Empty); }
public void Win() { AudioEvent.SendAudioEvent(AudioEvent.AudioEventType.WinPuzzle, audioEvents, gameObject); GameEnd(); WinText.SetActive(true); NextSceneButton.SetActive(true); }
private void StopFollowing() { if (!alreadyFinished) { isMoving = false; isUsed = true; if (OnlyUsedOnce) { gameObject.SetActive(false); } if (generated.transform.parent != null) { generated.transform.parent = null; } movementController.IsFuseMoving = false; alreadyFinished = true; AudioEvent.SendAudioEvent(AudioEvent.AudioEventType.OffRope, audioEvents, gameObject); _flameAttachToggler.FlameOff(); movementController.IsInvulnerable = false; if (playerRigidbody != null) { playerRigidbody.velocity = Vector3.zero; } movementController.StopMoving(InteractibleObject.InteractType.Fuse); } }
static bool IncludeAudioEvent(AudioEvent ev) { switch (ev.currentSoundFunctionType) { case MasterAudio.EventSoundFunctionType.PlaySound: case MasterAudio.EventSoundFunctionType.GroupControl: return(!FilterSoundGroup(ev.soundType)); case MasterAudio.EventSoundFunctionType.BusControl: if (!string.IsNullOrEmpty(groupFilter)) { return(false); } return(ev.allSoundTypesForBusCmd || string.IsNullOrEmpty(busFilter) || ev.busName == busFilter); case MasterAudio.EventSoundFunctionType.PlaylistControl: #if UNITY_4_5 || UNITY_4_6 || UNITY_4_7 #else case MasterAudio.EventSoundFunctionType.UnityMixerControl: #endif case MasterAudio.EventSoundFunctionType.CustomEventControl: case MasterAudio.EventSoundFunctionType.PersistentSettingsControl: return(string.IsNullOrEmpty(busFilter) && string.IsNullOrEmpty(groupFilter)); } return(true); }
private void PlaySound(AudioEvent aEvent) { if (!this.disableSounds) { float volume = aEvent.volume; string soundType = aEvent.soundType; float? pitch = new float?(aEvent.pitch); if (!aEvent.useFixedPitch) { pitch = null; } PlaySoundResult result = null; switch (this.soundSpawnMode) { case MasterAudio.SoundSpawnLocationMode.MasterAudioLocation: result = MasterAudio.PlaySound(soundType, volume, null, 0f, null, false); break; case MasterAudio.SoundSpawnLocationMode.CallerLocation: result = MasterAudio.PlaySound3DAtTransform(soundType, this.trans, volume, pitch, 0f, null, false); break; case MasterAudio.SoundSpawnLocationMode.AttachToCaller: result = MasterAudio.PlaySound3DFollowTransform(soundType, this.trans, volume, pitch, 0f, null, false); break; } if (((result != null) && result.SoundPlayed) && aEvent.emitParticles) { MasterAudio.TriggerParticleEmission(this.trans, aEvent.particleCountToEmit); } } }
/// <summary> /// Performs Dash Action. /// </summary> public void Dash(Vector3 dashDirection) { if (IsMoving) { TriggerCoyoteTime = true; return; } // checks if you have enough moves left for a dash int movesLeft = AmountOfMoves - DashCost; if (movesLeft < 0) { AudioEvent.SendAudioEvent(AudioEvent.AudioEventType.ChargingRejection, audioEvents, gameObject); StartCoroutine(ChangeTextColorRoutine()); return; } attachToPlane.Detach(); isDashing = true; trailRenderer.enabled = true; previousPosition = transform.position; AudioEvent.SendAudioEvent(AudioEvent.AudioEventType.ChargedDash, audioEvents, gameObject); previousPosition = transform.position; Vector3 targetPosition = transform.position + dashDirection * DashDistance; StartCoroutine(MoveRoutine(targetPosition, DashDuration, DashCost)); ResetDash(); }
public void Play(AudioEvent simpleAudioEvent) { var source = Get(); source.outputAudioMixerGroup = simpleAudioEvent.MixerGroup; simpleAudioEvent.Play(source); }
/*private void OnCollisionEnter(Collision collision) * { * if (collision.gameObject.tag != "Player") * { * if (transform.childCount > 1) * { * transform.Find("Player").GetComponent<AttachToPlane>().Detach(false); * _destroyThis = true; * } * * _destroyThis = true; * * } * }*/ public override void Interact(GameObject player) { // Play sound AudioEvent.SendAudioEvent(AudioEvent.AudioEventType.OnPlane, audioEvents, gameObject); // Attach Player to PaperPlane playerAttached = player.GetComponent <AttachToPlane>(); playerAttachedToThis = true; player.transform.SetParent(gameObject.transform); player.transform.position = player.transform.parent.position; player.GetComponent <Rigidbody>().useGravity = false; player.GetComponent <Rigidbody>().velocity = new Vector3(); playerAttached._attached = true; //turn flame on player.GetComponent <FlameAttachToggler>().FlameOn(); // Update Animator player.GetComponent <MovementController>().CollidePaperPlane(); isBurning = true; //Debug.Log("Collision with: " + gameObject.name); }
public static void PlayRandom(AudioEvent audioEvent) { if (Instance != null) { Instance.PlayEventRandom(audioEvent); } }
public static void PlayAtIndex(AudioEvent audioEvent, int index) { if (Instance != null) { Instance.PlayEventAtIndex(audioEvent, index); } }
private static void OnAudio(Message msg, bool isEdited) { AudioEvent?.Invoke(new MessageEventArgs() { msg = msg, isEdited = isEdited }); }
IEnumerator Unlock() { yield return(new WaitForSeconds(DelaySeconds)); AudioEvent.SendAudioEvent(AudioEvent.AudioEventType.GateUnlocked, audioEvents, gameObject); gameObject.SetActive(false); }
private static void NewEventArea(AudioEvent audioevent) { var defaultAlignment = GUI.skin.label.alignment; EditorGUILayout.BeginHorizontal(); GUI.skin.label.alignment = TextAnchor.MiddleLeft; EditorGUILayout.LabelField(""); EditorGUILayout.EndHorizontal(); Rect lastArea = GUILayoutUtility.GetLastRect(); lastArea.height *= 1.5f; if (GUI.Button(lastArea, "Click or drag here to add event")) { ShowCreationContext(audioevent); } if (Event.current.type != EventType.Repaint) { var dragging = DragAndDrop.objectReferences; OnDragging.OnDraggingObject(dragging, lastArea, objects => AudioEventWorker.CanDropObjects(audioevent, dragging), objects => AudioEventWorker.OnDrop(audioevent, dragging)); } GUI.skin.label.alignment = defaultAlignment; }
public ActiveEvent(AudioEvent audioEvent, GameObject emitter, AudioSource primarySource, AudioSource secondarySource) { this.audioEvent = audioEvent; AudioEmitter = emitter; PrimarySource = primarySource; SecondarySource = secondarySource; SetSourceProperties(); }
public void RunAudioEvent(AudioEvent ae) { if (!disabled) { source.Stop(); source.clip = audioClips[ae]; source.volume = (ae == AudioEvent.ZOOM_CHANGED) ? 0.1f : 1f; source.Play(); } }
public ActiveEvent(AudioEvent audioEvent, GameObject emitter, AudioSource primarySource, AudioSource secondarySource, string messageOnAudioEnd = null) { this.audioEvent = audioEvent; AudioEmitter = emitter; PrimarySource = primarySource; SecondarySource = secondarySource; MessageOnAudioEnd = messageOnAudioEnd; SetSourceProperties(); }
public void OnCollisionEnter(Collision col) { float volume = col.impulse.magnitude *this.volume; if (volume > volumeThreshold) { source.volume = volume; if (source.clip == null) source.clip = clip; source.Play(0); LabelHandle audioLabel = new LabelHandle(transform.position, "rock"); audioLabel.addTag(new Tag(TagEnum.Sound, volume)); audioLabel.addTag(new Tag(TagEnum.Threat, 5f)); AudioEvent rockCollisionSound = new AudioEvent(transform.position, audioLabel, transform.position); rockCollisionSound.broadcast(volume); } }
public void Init (AudioEvent myEvent) { this.myEvent = myEvent; switch (condition) { case Condition.EnergyGreaterThan: case Condition.EnergyLessThan: if (energy) { energy.EnergyEvent += new EnergyEventHandler (EnergyListener); } else { Debug.LogError ("Event will never auto-trigger because you haven't given it an Energy object."); } break; case Condition.TimeElapsed: StartTimeElapsed (); break; case Condition.BeatsElapsed: StartBeatsElapsed (); break; } }
private PlaySoundResult PlaySound(AudioEvent aEvent, EventType eType, bool isFirstTry = true) { if (disableSounds || MasterAudio.AppIsShuttingDown) { return null; } float volume = aEvent.volume; string sType = aEvent.soundType; float? pitch = aEvent.pitch; if (!aEvent.useFixedPitch) { pitch = null; } PlaySoundResult soundPlayed = null; var soundSpawnModeToUse = soundSpawnMode; if (aEvent == disableSound || aEvent == despawnedSound) { soundSpawnModeToUse = MasterAudio.SoundSpawnLocationMode.CallerLocation; } switch (aEvent.currentSoundFunctionType) { case MasterAudio.EventSoundFunctionType.PlaySound: string variationName = null; if (aEvent.variationType == VariationType.PlaySpecific) { variationName = aEvent.variationName; } if (eType == EventType.OnStart && isFirstTry && !MasterAudio.SoundGroupExists(sType)) { // don't try to play sound yet. } else { switch (soundSpawnModeToUse) { case MasterAudio.SoundSpawnLocationMode.CallerLocation: soundPlayed = MasterAudio.PlaySound3DAtTransform(sType, this.trans, volume, pitch, aEvent.delaySound, variationName); break; case MasterAudio.SoundSpawnLocationMode.AttachToCaller: soundPlayed = MasterAudio.PlaySound3DFollowTransform(sType, this.trans, volume, pitch, aEvent.delaySound, variationName); break; case MasterAudio.SoundSpawnLocationMode.MasterAudioLocation: soundPlayed = MasterAudio.PlaySound(sType, volume, pitch, aEvent.delaySound, variationName); break; } } if (soundPlayed == null || !soundPlayed.SoundPlayed) { if (eType == EventType.OnStart && isFirstTry) { // race condition met. So try to play it a few more times. StartCoroutine(TryPlayStartSound(aEvent)); } return soundPlayed; } break; case MasterAudio.EventSoundFunctionType.PlaylistControl: soundPlayed = new PlaySoundResult() { ActingVariation = null, SoundPlayed = true, SoundScheduled = false }; switch (aEvent.currentPlaylistCommand) { case MasterAudio.PlaylistCommand.None: soundPlayed.SoundPlayed = false; break; case MasterAudio.PlaylistCommand.ChangePlaylist: if (string.IsNullOrEmpty(aEvent.playlistName)) { Debug.Log("You have not specified a Playlist name for Event Sounds on '" + this.trans.name + "'."); soundPlayed.SoundPlayed = false; } else { if (aEvent.playlistControllerName == MasterAudio.NO_GROUP_NAME) { // don't play } else { MasterAudio.ChangePlaylistByName(aEvent.playlistControllerName, aEvent.playlistName, aEvent.startPlaylist); } } break; case MasterAudio.PlaylistCommand.FadeToVolume: if (aEvent.allPlaylistControllersForGroupCmd) { MasterAudio.FadeAllPlaylistsToVolume(aEvent.fadeVolume, aEvent.fadeTime); } else if (aEvent.playlistControllerName == MasterAudio.NO_GROUP_NAME) { // don't play } else { MasterAudio.FadePlaylistToVolume(aEvent.playlistControllerName, aEvent.fadeVolume, aEvent.fadeTime); } break; case MasterAudio.PlaylistCommand.PlayClip: if (string.IsNullOrEmpty(aEvent.clipName)) { Debug.Log("You have not specified a clip name for Event Sounds on '" + this.trans.name + "'."); soundPlayed.SoundPlayed = false; } else { if (aEvent.playlistControllerName == MasterAudio.NO_GROUP_NAME) { // don't play } else { MasterAudio.TriggerPlaylistClip(aEvent.playlistControllerName, aEvent.clipName); } } break; case MasterAudio.PlaylistCommand.PlayRandomSong: if (aEvent.allPlaylistControllersForGroupCmd) { MasterAudio.TriggerRandomClipAllPlaylists(); } else if (aEvent.playlistControllerName == MasterAudio.NO_GROUP_NAME) { // don't play } else { MasterAudio.TriggerRandomPlaylistClip(aEvent.playlistControllerName); } break; case MasterAudio.PlaylistCommand.PlayNextSong: if (aEvent.allPlaylistControllersForGroupCmd) { MasterAudio.TriggerNextClipAllPlaylists(); } else if (aEvent.playlistControllerName == MasterAudio.NO_GROUP_NAME) { // don't play } else { MasterAudio.TriggerNextPlaylistClip(aEvent.playlistControllerName); } break; case MasterAudio.PlaylistCommand.Pause: if (aEvent.allPlaylistControllersForGroupCmd) { MasterAudio.PauseAllPlaylists(); } else if (aEvent.playlistControllerName == MasterAudio.NO_GROUP_NAME) { // don't play } else { MasterAudio.PausePlaylist(aEvent.playlistControllerName); } break; case MasterAudio.PlaylistCommand.Stop: if (aEvent.allPlaylistControllersForGroupCmd) { MasterAudio.StopAllPlaylists(); } else if (aEvent.playlistControllerName == MasterAudio.NO_GROUP_NAME) { // don't play } else { MasterAudio.StopPlaylist(aEvent.playlistControllerName); } break; case MasterAudio.PlaylistCommand.Resume: if (aEvent.allPlaylistControllersForGroupCmd) { MasterAudio.ResumeAllPlaylists(); } else if (aEvent.playlistControllerName == MasterAudio.NO_GROUP_NAME) { // don't play } else { MasterAudio.ResumePlaylist(aEvent.playlistControllerName); } break; } break; case MasterAudio.EventSoundFunctionType.GroupControl: soundPlayed = new PlaySoundResult() { ActingVariation = null, SoundPlayed = true, SoundScheduled = false }; var soundTypesForCmd = new List<string>(); if (!aEvent.allSoundTypesForGroupCmd) { soundTypesForCmd.Add(aEvent.soundType); } else { soundTypesForCmd.AddRange(MasterAudio.RuntimeSoundGroupNames); } for (var i = 0 ; i < soundTypesForCmd.Count; i++) { var soundType = soundTypesForCmd[i]; switch (aEvent.currentSoundGroupCommand) { case MasterAudio.SoundGroupCommand.None: soundPlayed.SoundPlayed = false; break; case MasterAudio.SoundGroupCommand.FadeToVolume: MasterAudio.FadeSoundGroupToVolume(soundType, aEvent.fadeVolume, aEvent.fadeTime); break; case MasterAudio.SoundGroupCommand.FadeOutAllOfSound: MasterAudio.FadeOutAllOfSound(soundType, aEvent.fadeTime); break; case MasterAudio.SoundGroupCommand.Mute: MasterAudio.MuteGroup(soundType); break; case MasterAudio.SoundGroupCommand.Pause: MasterAudio.PauseSoundGroup(soundType); break; case MasterAudio.SoundGroupCommand.Solo: MasterAudio.SoloGroup(soundType); break; case MasterAudio.SoundGroupCommand.StopAllOfSound: MasterAudio.StopAllOfSound(soundType); break; case MasterAudio.SoundGroupCommand.Unmute: MasterAudio.UnmuteGroup(soundType); break; case MasterAudio.SoundGroupCommand.Unpause: MasterAudio.UnpauseSoundGroup(soundType); break; case MasterAudio.SoundGroupCommand.Unsolo: MasterAudio.UnsoloGroup(soundType); break; } } break; case MasterAudio.EventSoundFunctionType.BusControl: soundPlayed = new PlaySoundResult() { ActingVariation = null, SoundPlayed = true, SoundScheduled = false }; var busesForCmd = new List<string>(); if (!aEvent.allSoundTypesForBusCmd) { busesForCmd.Add(aEvent.busName); } else { busesForCmd.AddRange(MasterAudio.RuntimeBusNames); } for (var i = 0; i < busesForCmd.Count; i++) { var busName = busesForCmd[i]; switch (aEvent.currentBusCommand) { case MasterAudio.BusCommand.None: soundPlayed.SoundPlayed = false; break; case MasterAudio.BusCommand.FadeToVolume: MasterAudio.FadeBusToVolume(busName, aEvent.fadeVolume, aEvent.fadeTime); break; case MasterAudio.BusCommand.Pause: MasterAudio.PauseBus(busName); break; case MasterAudio.BusCommand.Stop: MasterAudio.StopBus(busName); break; case MasterAudio.BusCommand.Unpause: MasterAudio.UnpauseBus(busName); break; case MasterAudio.BusCommand.Mute: MasterAudio.MuteBus(busName); break; case MasterAudio.BusCommand.Unmute: MasterAudio.UnmuteBus(busName); break; case MasterAudio.BusCommand.Solo: MasterAudio.SoloBus(busName); break; case MasterAudio.BusCommand.Unsolo: MasterAudio.UnsoloBus(busName); break; } } break; case MasterAudio.EventSoundFunctionType.CustomEventControl: soundPlayed = new PlaySoundResult() { ActingVariation = null, SoundPlayed = false, SoundScheduled = false }; if (eType == EventType.UserDefinedEvent) { Debug.LogError("Custom Event Receivers cannot fire events. Occured in Transform '" + this.name + "'."); break; } switch (aEvent.currentCustomEventCommand) { case MasterAudio.CustomEventCommand.FireEvent: MasterAudio.FireCustomEvent(aEvent.customEventName); break; } break; } if (aEvent.emitParticles && soundPlayed != null && (soundPlayed.SoundPlayed || soundPlayed.SoundScheduled)) { MasterAudio.TriggerParticleEmission(this.trans, aEvent.particleCountToEmit); } return soundPlayed; }
private bool RenderAudioEvent(AudioEvent aEvent, bool showLayerTagFilter) { bool isDirty = false; EditorGUI.indentLevel = 2; if (maInScene) { var existingIndex = groupNames.IndexOf(aEvent.soundType); int? groupIndex = null; if (existingIndex >= 0) { groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, groupNames.ToArray()); } else if (existingIndex == -1 && aEvent.soundType == MasterAudio.NO_GROUP_NAME) { groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, groupNames.ToArray()); } else { // non-match GUIHelper.ShowColorWarning("Sound Group found no match. Choose one from 'All Sound Groups'."); aEvent.soundType = EditorGUILayout.TextField("Sound Group", aEvent.soundType); var newIndex = EditorGUILayout.Popup("All Sound Groups", -1, groupNames.ToArray()); if (newIndex >= 0) { groupIndex = newIndex; } } if (groupIndex.HasValue) { if (groupIndex.Value == -1) { aEvent.soundType = MasterAudio.NO_GROUP_NAME; } else { aEvent.soundType = groupNames[groupIndex.Value]; } } } else { aEvent.soundType = EditorGUILayout.TextField("Sound Group", aEvent.soundType); } aEvent.volume = EditorGUILayout.Slider("Volume", aEvent.volume, 0f, 1f); #if UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 #else aEvent.delaySound = EditorGUILayout.Slider("Delay Sound (sec)", aEvent.delaySound, 0f, 10f); #endif aEvent.emitParticles = EditorGUILayout.Toggle("Emit Particle", aEvent.emitParticles); if (aEvent.emitParticles) { aEvent.particleCountToEmit = EditorGUILayout.IntSlider("Particle Count", aEvent.particleCountToEmit, 1, 100); } if (showLayerTagFilter) { aEvent.useLayerFilter = EditorGUILayout.BeginToggleGroup("Layer filters", aEvent.useLayerFilter); if (aEvent.useLayerFilter) { for (var i = 0; i < aEvent.matchingLayers.Count; i++) { aEvent.matchingLayers[i] = EditorGUILayout.LayerField("Layer Match " + (i + 1), aEvent.matchingLayers[i]); } EditorGUILayout.BeginHorizontal(); GUILayout.Space(24); if (GUILayout.Button(new GUIContent("Add", "Click to add a layer match at the end"), GUILayout.Width(60))) { aEvent.matchingLayers.Add(0); isDirty = true; } if (aEvent.matchingLayers.Count > 1) { if (GUILayout.Button(new GUIContent("Remove", "Click to remove the last layer match"), GUILayout.Width(60))) { aEvent.matchingLayers.RemoveAt(aEvent.matchingLayers.Count - 1); isDirty = true; } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndToggleGroup(); aEvent.useTagFilter = EditorGUILayout.BeginToggleGroup("Tag filter", aEvent.useTagFilter); if (aEvent.useTagFilter) { for (var i = 0; i < aEvent.matchingTags.Count; i++) { aEvent.matchingTags[i] = EditorGUILayout.TagField("Tag Match " + (i + 1), aEvent.matchingTags[i]); } EditorGUILayout.BeginHorizontal(); GUILayout.Space(24); if (GUILayout.Button(new GUIContent("Add", "Click to add a tag match at the end"), GUILayout.Width(60))) { aEvent.matchingTags.Add("Untagged"); isDirty = true; } if (aEvent.matchingTags.Count > 1) { if (GUILayout.Button(new GUIContent("Remove", "Click to remove the last tag match"), GUILayout.Width(60))) { aEvent.matchingTags.RemoveAt(aEvent.matchingLayers.Count - 1); isDirty = true; } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndToggleGroup(); } return isDirty; }
public void processAudioEvent(AudioEvent eventMessage) { if(hasPower) { //Debug.Log("sound heard"); roboController.enqueueMessage(eventMessage); } }
private bool RenderAudioEvent(AudioEvent aEvent, EventSounds.EventType eType) { bool showLayerTagFilter = EventSounds.layerTagFilterEvents.Contains(eType.ToString()); bool isDirty = false; EditorGUI.indentLevel = 0; if (eType == EventSounds.EventType.OnEnable) { GUIHelper.ShowColorWarning("*If this prefab is in the scene at startup, use Start event instead."); } var newSoundType = (MasterAudio.EventSoundFunctionType) EditorGUILayout.EnumPopup("Action Type", aEvent.currentSoundFunctionType); if (newSoundType != aEvent.currentSoundFunctionType) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Action Type"); aEvent.currentSoundFunctionType = newSoundType; } switch (aEvent.currentSoundFunctionType) { case MasterAudio.EventSoundFunctionType.PlaySound: if (maInScene) { var existingIndex = groupNames.IndexOf(aEvent.soundType); int? groupIndex = null; EditorGUI.indentLevel = 1; if (existingIndex >= 1) { groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, groupNames.ToArray()); if (existingIndex == 1) { GUIHelper.ShowColorWarning("*No Sound Group specified. Event will do nothing."); } } else if (existingIndex == -1 && aEvent.soundType == MasterAudio.NO_GROUP_NAME) { groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, groupNames.ToArray()); } else { // non-match GUIHelper.ShowColorWarning("Sound Group found no match. Type in or choose one."); var newSound = EditorGUILayout.TextField("Sound Group", aEvent.soundType); if (newSound != aEvent.soundType) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Group"); aEvent.soundType = newSound; } var newIndex = EditorGUILayout.Popup("All Sound Groups", -1, groupNames.ToArray()); if (newIndex >= 0) { groupIndex = newIndex; } } if (groupIndex.HasValue) { if (existingIndex != groupIndex.Value) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Group"); } if (groupIndex.Value == -1) { aEvent.soundType = MasterAudio.NO_GROUP_NAME; } else { aEvent.soundType = groupNames[groupIndex.Value]; } } } else { var newSType = EditorGUILayout.TextField("Sound Group", aEvent.soundType); if (newSType != aEvent.soundType) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Group"); aEvent.soundType = newSType; } } var newVarType = (EventSounds.VariationType) EditorGUILayout.EnumPopup("Variation Mode", aEvent.variationType); if (newVarType != aEvent.variationType) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Variation Mode"); aEvent.variationType = newVarType; } if (aEvent.variationType == EventSounds.VariationType.PlaySpecific) { var newVarName = EditorGUILayout.TextField("Variation Name", aEvent.variationName); if (newVarName != aEvent.variationName) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Variation Name"); aEvent.variationName = newVarName; } if (string.IsNullOrEmpty(aEvent.variationName)) { GUIHelper.ShowColorWarning("*Variation Name is empty. No sound will play."); } } var newVol = EditorGUILayout.Slider("Volume", aEvent.volume, 0f, 1f); if (newVol != aEvent.volume) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Volume"); aEvent.volume = newVol; } var newFixedPitch = EditorGUILayout.Toggle("Override pitch?", aEvent.useFixedPitch); if (newFixedPitch != aEvent.useFixedPitch) { UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Override pitch"); aEvent.useFixedPitch = newFixedPitch; } if (aEvent.useFixedPitch) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Pitch"); aEvent.pitch = EditorGUILayout.Slider("Pitch", aEvent.pitch, -3f, 3f); } var newDelay = EditorGUILayout.Slider("Delay Sound (sec)", aEvent.delaySound, 0f, 10f); if (newDelay != aEvent.delaySound) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Delay Sound"); aEvent.delaySound = newDelay; } break; case MasterAudio.EventSoundFunctionType.PlaylistControl: var newPlaylistCmd = (MasterAudio.PlaylistCommand) EditorGUILayout.EnumPopup("Playlist Command", aEvent.currentPlaylistCommand); if (newPlaylistCmd != aEvent.currentPlaylistCommand) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Playlist Command"); aEvent.currentPlaylistCommand = newPlaylistCmd; } EditorGUI.indentLevel = 1; if (aEvent.currentPlaylistCommand != MasterAudio.PlaylistCommand.None) { // show Playlist Controller dropdown if (EventSounds.playlistCommandsWithAll.Contains(aEvent.currentPlaylistCommand)) { var newAllControllers = EditorGUILayout.Toggle("All Playlist Controllers?", aEvent.allPlaylistControllersForGroupCmd); if (newAllControllers != aEvent.allPlaylistControllersForGroupCmd) { UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle All Playlist Controllers"); aEvent.allPlaylistControllersForGroupCmd = newAllControllers; } } if (!aEvent.allPlaylistControllersForGroupCmd) { if (playlistControllerNames.Count > 0) { var existingIndex = playlistControllerNames.IndexOf(aEvent.playlistControllerName); int? playlistControllerIndex = null; if (existingIndex >= 1) { playlistControllerIndex = EditorGUILayout.Popup("Playlist Controller", existingIndex, playlistControllerNames.ToArray()); if (existingIndex == 1) { GUIHelper.ShowColorWarning("*No Playlist Controller specified. Event will do nothing."); } } else if (existingIndex == -1 && aEvent.playlistControllerName == MasterAudio.NO_GROUP_NAME) { playlistControllerIndex = EditorGUILayout.Popup("Playlist Controller", existingIndex, playlistControllerNames.ToArray()); } else { // non-match GUIHelper.ShowColorWarning("Playlist Controller found no match. Type in or choose one."); var newPlaylistController = EditorGUILayout.TextField("Playlist Controller", aEvent.playlistControllerName); if (newPlaylistController != aEvent.playlistControllerName) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Playlist Controller"); aEvent.playlistControllerName = newPlaylistController; } var newIndex = EditorGUILayout.Popup("All Playlist Controllers", -1, playlistControllerNames.ToArray()); if (newIndex >= 0) { playlistControllerIndex = newIndex; } } if (playlistControllerIndex.HasValue) { if (existingIndex != playlistControllerIndex.Value) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Playlist Controller"); } if (playlistControllerIndex.Value == -1) { aEvent.playlistControllerName = MasterAudio.NO_GROUP_NAME; } else { aEvent.playlistControllerName = playlistControllerNames[playlistControllerIndex.Value]; } } } else { var newPlaylistControllerName = EditorGUILayout.TextField("Playlist Controller", aEvent.playlistControllerName); if (newPlaylistControllerName != aEvent.playlistControllerName) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Playlist Controller"); aEvent.playlistControllerName = newPlaylistControllerName; } } } } switch (aEvent.currentPlaylistCommand) { case MasterAudio.PlaylistCommand.ChangePlaylist: // show playlist name dropdown if (maInScene) { var existingIndex = playlistNames.IndexOf(aEvent.playlistName); int? playlistIndex = null; if (existingIndex >= 1) { playlistIndex = EditorGUILayout.Popup("Playlist Name", existingIndex, playlistNames.ToArray()); if (existingIndex == 1) { GUIHelper.ShowColorWarning("*No Playlist Name specified. Event will do nothing."); } } else if (existingIndex == -1 && aEvent.playlistName == MasterAudio.NO_GROUP_NAME) { playlistIndex = EditorGUILayout.Popup("Playlist Name", existingIndex, playlistNames.ToArray()); } else { // non-match GUIHelper.ShowColorWarning("Playlist Name found no match. Type in or choose one."); var newPlaylist = EditorGUILayout.TextField("Playlist Name", aEvent.playlistName); if (newPlaylist != aEvent.playlistName) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Playlist Name"); aEvent.playlistName = newPlaylist; } var newIndex = EditorGUILayout.Popup("All Playlists", -1, playlistNames.ToArray()); if (newIndex >= 0) { playlistIndex = newIndex; } } if (playlistIndex.HasValue) { if (existingIndex != playlistIndex.Value) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Playlist Name"); } if (playlistIndex.Value == -1) { aEvent.playlistName = MasterAudio.NO_GROUP_NAME; } else { aEvent.playlistName = playlistNames[playlistIndex.Value]; } } } else { var newPlaylistName = EditorGUILayout.TextField("Playlist Name", aEvent.playlistName); if (newPlaylistName != aEvent.playlistName) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Playlist Name"); aEvent.playlistName = newPlaylistName; } } var newStartPlaylist = EditorGUILayout.Toggle("Start Playlist?", aEvent.startPlaylist); if (newStartPlaylist != aEvent.startPlaylist) { UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Start Playlist"); aEvent.startPlaylist = newStartPlaylist; } break; case MasterAudio.PlaylistCommand.FadeToVolume: var newFadeVol = EditorGUILayout.Slider("Target Volume", aEvent.fadeVolume, 0f, 1f); if (newFadeVol != aEvent.fadeVolume) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Target Volume"); aEvent.fadeVolume = newFadeVol; } var newFadeTime = EditorGUILayout.Slider("Fade Time", aEvent.fadeTime, 0f, 10f); if (newFadeTime != aEvent.fadeTime) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Fade Time"); aEvent.fadeTime = newFadeTime; } break; case MasterAudio.PlaylistCommand.PlayClip: var newClip = EditorGUILayout.TextField("Clip Name", aEvent.clipName); if (newClip != aEvent.clipName) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Clip Name"); aEvent.clipName = newClip; } if (string.IsNullOrEmpty(aEvent.clipName)) { GUIHelper.ShowColorWarning("*Clip name is empty. Event will do nothing."); } break; } break; case MasterAudio.EventSoundFunctionType.GroupControl: EditorGUI.indentLevel = 1; var newGroupCmd = (MasterAudio.SoundGroupCommand) EditorGUILayout.EnumPopup("Group Command", aEvent.currentSoundGroupCommand); if (newGroupCmd != aEvent.currentSoundGroupCommand) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Group Command"); aEvent.currentSoundGroupCommand = newGroupCmd; } if (aEvent.currentSoundGroupCommand != MasterAudio.SoundGroupCommand.None) { var newAllTypes = EditorGUILayout.Toggle("Do For Every Group?", aEvent.allSoundTypesForGroupCmd); if (newAllTypes != aEvent.allSoundTypesForGroupCmd) { UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Do For Every Group?"); aEvent.allSoundTypesForGroupCmd = newAllTypes; } if (!aEvent.allSoundTypesForGroupCmd) { if (maInScene) { var existingIndex = groupNames.IndexOf(aEvent.soundType); int? groupIndex = null; if (existingIndex >= 1) { groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, groupNames.ToArray()); } else if (existingIndex == -1 && aEvent.soundType == MasterAudio.NO_GROUP_NAME) { groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, groupNames.ToArray()); } else { // non-match GUIHelper.ShowColorWarning("Sound Group found no match. Type in or choose one."); var newSType = EditorGUILayout.TextField("Sound Group", aEvent.soundType); if (newSType != aEvent.soundType) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Group"); aEvent.soundType = newSType; } var newIndex = EditorGUILayout.Popup("All Sound Groups", -1, groupNames.ToArray()); if (newIndex >= 0) { groupIndex = newIndex; } } if (groupIndex.HasValue) { if (existingIndex != groupIndex.Value) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Group"); } if (groupIndex.Value == -1) { aEvent.soundType = MasterAudio.NO_GROUP_NAME; } else { aEvent.soundType = groupNames[groupIndex.Value]; } } } else { var newSoundT = EditorGUILayout.TextField("Sound Group", aEvent.soundType); if (newSoundT != aEvent.soundType) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Group"); aEvent.soundType = newSoundT; } } } } switch (aEvent.currentSoundGroupCommand) { case MasterAudio.SoundGroupCommand.None: break; case MasterAudio.SoundGroupCommand.FadeToVolume: var newFadeVol = EditorGUILayout.Slider("Target Volume", aEvent.fadeVolume, 0f, 1f); if (newFadeVol != aEvent.fadeVolume) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Target Volume"); aEvent.fadeVolume = newFadeVol; } var newFadeTime = EditorGUILayout.Slider("Fade Time", aEvent.fadeTime, 0f, 10f); if (newFadeTime != aEvent.fadeTime) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Fade Time"); aEvent.fadeTime = newFadeTime; } break; case MasterAudio.SoundGroupCommand.FadeOutAllOfSound: var newFadeT = EditorGUILayout.Slider("Fade Time", aEvent.fadeTime, 0f, 10f); if (newFadeT != aEvent.fadeTime) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Fade Time"); aEvent.fadeTime = newFadeT; } break; case MasterAudio.SoundGroupCommand.Mute: break; case MasterAudio.SoundGroupCommand.Pause: break; case MasterAudio.SoundGroupCommand.Solo: break; case MasterAudio.SoundGroupCommand.Unmute: break; case MasterAudio.SoundGroupCommand.Unpause: break; case MasterAudio.SoundGroupCommand.Unsolo: break; } break; case MasterAudio.EventSoundFunctionType.BusControl: var newBusCmd = (MasterAudio.BusCommand) EditorGUILayout.EnumPopup("Bus Command", aEvent.currentBusCommand); if (newBusCmd != aEvent.currentBusCommand) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Bus Command"); aEvent.currentBusCommand = newBusCmd; } EditorGUI.indentLevel = 1; if (aEvent.currentBusCommand != MasterAudio.BusCommand.None) { var newAllTypes = EditorGUILayout.Toggle("Do For Every Bus?", aEvent.allSoundTypesForBusCmd); if (newAllTypes != aEvent.allSoundTypesForBusCmd) { UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Do For Every Bus?"); aEvent.allSoundTypesForBusCmd = newAllTypes; } if (!aEvent.allSoundTypesForBusCmd) { if (maInScene) { var existingIndex = busNames.IndexOf(aEvent.busName); int? busIndex = null; if (existingIndex >= 1) { busIndex = EditorGUILayout.Popup("Bus Name", existingIndex, busNames.ToArray()); if (existingIndex == 1) { GUIHelper.ShowColorWarning("*No Bus Name specified. Event will do nothing."); } } else if (existingIndex == -1 && aEvent.busName == MasterAudio.NO_GROUP_NAME) { busIndex = EditorGUILayout.Popup("Bus Name", existingIndex, busNames.ToArray()); } else { // non-match var newBusName = EditorGUILayout.TextField("Bus Name", aEvent.busName); if (newBusName != aEvent.busName) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Bus Name"); aEvent.busName = newBusName; } var newIndex = EditorGUILayout.Popup("All Buses", -1, busNames.ToArray()); if (newIndex >= 0) { busIndex = newIndex; } GUIHelper.ShowColorWarning("*Bus Name found no match. Type in or choose one."); } if (busIndex.HasValue) { if (existingIndex != busIndex.Value) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Bus"); } if (busIndex.Value == -1) { aEvent.busName = MasterAudio.NO_GROUP_NAME; } else { aEvent.busName = busNames[busIndex.Value]; } } } else { var newBusName = EditorGUILayout.TextField("Bus Name", aEvent.busName); if (newBusName != aEvent.busName) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Bus Name"); aEvent.busName = newBusName; } } } var newVolume = EditorGUILayout.Slider("Volume", aEvent.volume, 0f, 1f); if (newVolume != aEvent.volume) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Volume"); aEvent.volume = newVolume; } var newFixPitch = EditorGUILayout.Toggle("Override pitch?", aEvent.useFixedPitch); if (newFixPitch != aEvent.useFixedPitch) { UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Override pitch"); aEvent.useFixedPitch = newFixPitch; } if (aEvent.useFixedPitch) { GUIHelper.ShowColorWarning("*Random pitches for the variation will not be used."); var newPitch = EditorGUILayout.Slider("Pitch", aEvent.pitch, -3f, 3f); if (newPitch != aEvent.pitch) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Pitch"); aEvent.pitch = newPitch; } } } switch (aEvent.currentBusCommand) { case MasterAudio.BusCommand.FadeToVolume: var newFadeVol = EditorGUILayout.Slider("Target Volume", aEvent.fadeVolume, 0f, 1f); if (newFadeVol != aEvent.fadeVolume) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Target Volume"); aEvent.fadeVolume = newFadeVol; } var newFadeTime = EditorGUILayout.Slider("Fade Time", aEvent.fadeTime, 0f, 10f); if (newFadeTime != aEvent.fadeTime) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Fade Time"); aEvent.fadeTime = newFadeTime; } break; case MasterAudio.BusCommand.Pause: break; case MasterAudio.BusCommand.Unpause: break; } break; } EditorGUI.indentLevel = 0; var newEmit = EditorGUILayout.Toggle("Emit Particle", aEvent.emitParticles); if (newEmit != aEvent.emitParticles) { UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Emit Particle"); aEvent.emitParticles = newEmit; } if (aEvent.emitParticles) { var newParticleCount = EditorGUILayout.IntSlider("Particle Count", aEvent.particleCountToEmit, 1, 100); if (newParticleCount != aEvent.particleCountToEmit) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Particle Count"); aEvent.particleCountToEmit = newParticleCount; } } if (showLayerTagFilter) { var newUseLayers = EditorGUILayout.BeginToggleGroup("Layer filters", aEvent.useLayerFilter); if (newUseLayers != aEvent.useLayerFilter) { UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Layer filters"); aEvent.useLayerFilter = newUseLayers; } if (aEvent.useLayerFilter) { for (var i = 0; i < aEvent.matchingLayers.Count; i++) { var newLayer = EditorGUILayout.LayerField("Layer Match " + (i + 1), aEvent.matchingLayers[i]); if (newLayer != aEvent.matchingLayers[i]) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Layer filter"); aEvent.matchingLayers[i] = newLayer; } } EditorGUILayout.BeginHorizontal(); GUILayout.Space(24); if (GUILayout.Button(new GUIContent("Add", "Click to add a layer match at the end"), GUILayout.Width(60))) { UndoHelper.RecordObjectPropertyForUndo(sounds, "add Layer filter"); aEvent.matchingLayers.Add(0); isDirty = true; } if (aEvent.matchingLayers.Count > 1) { if (GUILayout.Button(new GUIContent("Remove", "Click to remove the last layer match"), GUILayout.Width(60))) { UndoHelper.RecordObjectPropertyForUndo(sounds, "remove Layer filter"); aEvent.matchingLayers.RemoveAt(aEvent.matchingLayers.Count - 1); isDirty = true; } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndToggleGroup(); var newTagFilter = EditorGUILayout.BeginToggleGroup("Tag filter", aEvent.useTagFilter); if (newTagFilter != aEvent.useTagFilter) { UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Tag filter"); aEvent.useTagFilter = newTagFilter; } if (aEvent.useTagFilter) { for (var i = 0; i < aEvent.matchingTags.Count; i++) { var newTag = EditorGUILayout.TagField("Tag Match " + (i + 1), aEvent.matchingTags[i]); if (newTag != aEvent.matchingTags[i]) { UndoHelper.RecordObjectPropertyForUndo(sounds, "change Tag filter"); aEvent.matchingTags[i] = newTag; } } EditorGUILayout.BeginHorizontal(); GUILayout.Space(24); if (GUILayout.Button(new GUIContent("Add", "Click to add a tag match at the end"), GUILayout.Width(60))) { UndoHelper.RecordObjectPropertyForUndo(sounds, "Add Tag filter"); aEvent.matchingTags.Add("Untagged"); isDirty = true; } if (aEvent.matchingTags.Count > 1) { if (GUILayout.Button(new GUIContent("Remove", "Click to remove the last tag match"), GUILayout.Width(60))) { UndoHelper.RecordObjectPropertyForUndo(sounds, "remove Tag filter"); aEvent.matchingTags.RemoveAt(aEvent.matchingLayers.Count - 1); isDirty = true; } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndToggleGroup(); } return isDirty; }
public void processAudioEvent(AudioEvent eventMessage) { if(hasPower) { Debug.Log("Sound heard!"); } }
void FixedUpdate() { // change collider height float desiredHeight = crouching? crouchHeight: normHeight; if (col.height < desiredHeight) { if (freeFallDelay == 0) setColliderHeight(col.height + climbRate /5); else setColliderHeight(col.height + climbRate); if (col.height > desiredHeight) setColliderHeight(desiredHeight); } else if (col.height > desiredHeight) { setColliderHeight(col.height - climbRate); if (col.height < desiredHeight) setColliderHeight(desiredHeight); } // update past forces int newForceCount = pastForces.Count -lastForceCount; pastForcesAddedCount.Add(newForceCount); if (pastForcesAddedCount.Count > pastForceCount) { int forcesToRemove = pastForcesAddedCount[0]; pastForcesAddedCount.RemoveAt(0); pastForces.RemoveRange(0, forcesToRemove); } for (int i = 0; i < pastForces.Count; ++i) pastForces[i] *= 0.8f; lastForceCount = pastForces.Count; // move the player if (freeFallDelay < 0) { ++freeFallDelay; return; } if (!isGrounded()) { if (freeFallDelay > 0) --freeFallDelay; else { nextFootstep = 1; return; } } else freeFallDelay = 2; // get the move direction and speed if (!canMove) { rightSpeed = 0; forwardSpeed = 0; } desiredVel = new Vector3(rightSpeed, 0, forwardSpeed); float speed = desiredVel.magnitude * (sprinting ? calculateSprintMultiplier() : 1) *(crouching? crouchSpeedMultiplier: 1); desiredVel = myPlayer.cam.transform.TransformDirection(desiredVel); desiredVel.y = 0; desiredVel.Normalize(); // move parallel to the ground if (isGrounded()) { Vector3 sideways = Vector3.Cross(Vector3.up, desiredVel); desiredVel = Vector3.Cross(sideways, groundNormal).normalized; } desiredVel *= speed; // slow down when moving up a slope if (desiredVel.y > 0) desiredVel *= 1 - Mathf.Pow(desiredVel.y / speed, 2); if (!isGrounded()) desiredVel.y = GetComponent<Rigidbody>().velocity.y; // handle the maximum acceleration Vector3 force = desiredVel -GetComponent<Rigidbody>().velocity +groundSpeed; float maxAccel = Mathf.Min(Mathf.Max(acceleration *force.magnitude, acceleration /3), acceleration *2); if (force.magnitude > maxAccel) { force.Normalize(); force *= maxAccel; } GetComponent<Rigidbody>().AddForce(force, ForceMode.VelocityChange); // play footstep sounds float currentSpeed = GetComponent<Rigidbody>().velocity.sqrMagnitude; if (nextFootstep <= Time.fixedTime && currentSpeed > 0.1f) { if (nextFootstep != 0) { float volume = 0.8f -(0.8f / (1 + currentSpeed /100)); playFootstep(volume); AudioEvent footStepsEvent = new AudioEvent(transform.position, new Tag(TagEnum.Threat, 5f)); footStepsEvent.broadcast(volume); } nextFootstep = Time.fixedTime + minimumFoostepOccurence / (1 + currentSpeed * foostepSpeedScale); } if (desiredVel.sqrMagnitude == 0 && currentSpeed < 1f && nextFootstep != 0) { float volume = 0.1f * currentSpeed; playFootstep(volume); nextFootstep = 0; } // update sprinting if (desiredVel.sqrMagnitude > 0.1f && sprinting) { if (myPlayer.oxygen < oxygenStopSprint) myPlayer.oxygen -= myPlayer.oxygenRecoveryRate *Time.deltaTime; else if (crouching) sprinting = false; else myPlayer.oxygen -= oxygenSprintUsage * Time.deltaTime; } // THE NEW STEP SYSTEM!!! //climb(); // check for no more floor, in case it was deleted //if (floor == null) groundNormal = Vector3.zero; }
private IEnumerator TryPlayStartSound(AudioEventGroup grp, AudioEvent aEvent) { for (var i = 0; i < 3; i++) { if (MasterAudio.IgnoreTimeScale) { yield return StartCoroutine(CoroutineHelper.WaitForActualSeconds(MasterAudio.INNER_LOOP_CHECK_INTERVAL)); } else { yield return MasterAudio.InnerLoopDelay; } var result = PerformSingleAction(grp, aEvent, EventType.OnStart, false); if (result != null && result.SoundPlayed) { break; } } }
public void processAudioEvent(AudioEvent eventMessage) { if(hasPower) { getController().enqueueMessage(eventMessage); } }
public void PlaySoundInRoom(AudioEvent s){ //Plays the sound in the room (triggered by the game), which activates the AudioObject script. roomAudio[s.sound].PlayAudio(soundIsPlayingPrefab); }
private void CreateCustomEvent(bool recordUndo) { var newEvent = new AudioEvent(); if (recordUndo) { AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "add Custom Event Sound"); } var newGrp = new AudioEventGroup { isCustomEvent = true, customSoundActive = true }; newGrp.SoundEvents.Add(newEvent); _sounds.userDefinedSounds.Add(newGrp); }
private void CreateMechanimStateEntered(bool recordUndo) { var newEvent = new AudioEvent(); if (recordUndo) { AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "add Mechanim State Entered Sound"); } var newGrp = new AudioEventGroup { isMechanimStateCheckEvent = true, mechanimEventActive = true }; newGrp.SoundEvents.Add(newEvent); _sounds.mechanimStateChangedSounds.Add(newGrp); }
public void DoAudioEvent(AudioEvent e){ try{ roomM.PlaySoundInRoom(e); } catch{ Debug.LogError("COULD NOT PLAY "+e.name); } }
private IEnumerator TryPlayStartSound(AudioEvent aEvent) { for (var i = 0; i < 3; i++) { yield return new WaitForSeconds(MasterAudio.INNER_LOOP_CHECK_INTERVAL); var result = PlaySound(aEvent, EventType.OnStart, false); if (result != null && result.SoundPlayed) { break; } } }
public void PlaySounds(AudioEventGroup eventGrp, EventType eType) { if (!CheckForRetriggerLimit(eventGrp)) { return; } // set the last triggered time or frame switch (eventGrp.retriggerLimitMode) { case RetriggerLimMode.FrameBased: eventGrp.triggeredLastFrame = Time.frameCount; break; case RetriggerLimMode.TimeBased: eventGrp.triggeredLastTime = Time.time; break; } // Pre-warm event sounds! if (!MasterAudio.AppIsShuttingDown && MasterAudio.IsWarming) { var evt = new AudioEvent(); PerformSingleAction(eventGrp, evt, eType); return; } for (var i = 0; i < eventGrp.SoundEvents.Count; i++) { PerformSingleAction(eventGrp, eventGrp.SoundEvents[i], eType); } }
public int ScheduleAudioClips( string clipName, float delay, float startFrame, float frameRate ) { //Message.Log( "ScheduleAudioClips delay: " + delay + " startFrame: " + startFrame + " frameRate: " + frameRate ); if ( !audioSequences.ContainsKey( clipName ) ) return -1; AudioEvent audioEvent = new AudioEvent(); List< AudioSequence > clipAudioSequences = audioSequences[clipName]; for ( int i=0 ; i<clipAudioSequences.Count ; ++i ) { AudioSequence audioSequence = clipAudioSequences[i]; if ( audioSequence.startFrame >= startFrame ) { AudioSource audioSource = null; if ( audioSourcePool.Count > 0 ) { audioSource = audioSourcePool[0]; audioSourcePool.RemoveAt(0); } else { string audioName = "audioObject_" + string.Format( "{0:0,0}", ++audioIndex ); // Parent audio game object to current game object. GameObject audioObject = new GameObject(audioName); audioObject.transform.parent = gameObject.transform; // Reset transform in audioObject audioObject.transform.localPosition = Vector3.zero; audioObject.transform.localScale = Vector3.one; audioObject.transform.localRotation = Quaternion.identity; // Create default AudioSource object. audioSource = audioObject.AddComponent<AudioSource>(); audioSource.playOnAwake = false; // handled by us. audioSource.loop = false; // handled by us. AudioSource templateAudioSource = gameObject.GetComponent<AudioSource>(); if ( templateAudioSource != null ) { // Could not find any better way to copy parameters from template AudioSource // to target AudioSource. Cannot only Instantiate a Component without its // GameObject, and Type.GetFields returns empty collection for Unity Components. audioSource.mute = templateAudioSource.mute; audioSource.bypassEffects = templateAudioSource.bypassEffects; audioSource.priority = templateAudioSource.priority; audioSource.volume = templateAudioSource.volume; audioSource.pitch = templateAudioSource.pitch; // 3D sound settings. audioSource.dopplerLevel = templateAudioSource.dopplerLevel; audioSource.minDistance = templateAudioSource.minDistance; audioSource.maxDistance = templateAudioSource.maxDistance; #if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 audioSource.panLevel = templateAudioSource.panLevel; #else // UNITY_5_0 audioSource.spatialBlend = templateAudioSource.spatialBlend; #endif audioSource.spread = templateAudioSource.spread; audioSource.rolloffMode = templateAudioSource.rolloffMode; // 2D sound settings. #if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 audioSource.pan = templateAudioSource.pan; #else // UNITY_5_0 audioSource.panStereo = templateAudioSource.panStereo; #endif } } audioSource.clip = clipAudioSequences[i].audioClip; float clipDelay = ((audioSequence.startFrame-startFrame) / frameRate) + delay; audioSource.PlayScheduled(AudioSettings.dspTime + clipDelay); audioEvent.audioSources.Add(audioSource); } } if ( audioEvent.audioSources.Count > 0 ) { int id = ++audioEventId; audioEvents.Add( id, audioEvent ); return id; } return -1; }
void Update() { // Obtain samples of output data over dbSamples.Length samples aSource.GetOutputData(this.dbSamples, 0); // Obtain the samples from the frequency bands of the attached AudioSource aSource.GetSpectrumData(this.spectrumSamples, 0, FFTWindow.BlackmanHarris); // Create an AudioEvent to be passed into the receivers. AudioEvent frameAudioEvent = new AudioEvent(); frameAudioEvent.dbData = this.dbSamples; frameAudioEvent.spectrumData = this.spectrumSamples; float averageDbSample = 0.0f; // Take the RMS of the db samples and set it on the frameAudioEvent for (int i = 0; i < dbSamples.Length; i++) { averageDbSample += dbSamples[i] * dbSamples[i]; } averageDbSample = Mathf.Sqrt(averageDbSample / dbSamples.Length); frameAudioEvent.averageDbSample = Mathf.Exp(-2f * averageDbSample) * averageDbSample * volume; // Calculate the color based on the samples data. Most of the samples after a certain index // are 0 so we stop float maxValue = -1f; int maxIndex = 0; int maxImportantIndex = spectrumSamples.Length; for (int i = 0; i < spectrumSamples.Length; i++) { if (spectrumSamples[i] > maxValue) { maxIndex = i; maxValue = spectrumSamples[i]; } if (spectrumSamples[i] * volume > minimumVolume) { maxImportantIndex = i; } } int currentFrequencySplit = 0; float[] frequencySplits = new float[4]; for (int i = 0; i < maxIndex; i++) { currentFrequencySplit = (int)(4 * i / maxIndex); frequencySplits[currentFrequencySplit] += spectrumSamples[i] * spectrumSamples[i]; } for (int i = 0; i < frequencySplits.Length; i++) { frequencySplits[i] = Mathf.Sqrt(frequencySplits[i]); } frameAudioEvent.frequencySplitData = frequencySplits; // Turn the int from 0 to maxValue into a color based on an hsv algorithm Color calculatedColor = new Color(0, 0, 0, 0); if (maxImportantIndex >= 6) { calculatedColor.a = 1; calculatedColor = intToColor(maxIndex, maxImportantIndex); } frameAudioEvent.spectrumColorRepresetation = calculatedColor; // Send the audio event to all the receivers foreach (AudioEventListener audioListener in expandableAudioListeners) { audioListener.OnAudioEvent(frameAudioEvent); } }
private void CreateCustomEvent(bool recordUndo) { var newEvent = new AudioEvent(); newEvent.isCustomEvent = true; newEvent.customSoundActive = true; if (recordUndo) { UndoHelper.RecordObjectPropertyForUndo(sounds, "add Custom Event Sound"); } sounds.userDefinedSounds.Add(newEvent); }
private bool Load(string fileName) { string line; line = ""; StringReader theReader = new StringReader(fileName); using (theReader) { // While there's lines left in the text file, do this: int lineCounter = 0; while(line != null){ instances.Clear(); e.Clear(); //print("reading line"); line = theReader.ReadLine(); if(line != null && !firstTime && line.Substring(0,4) != "SKIP"){ //print ("LINE: "+line); e = (line.Split(';').ToList()); //U+03B1 THAT SUCKS //foreach(string s in e){ // print (s); //} Event ev = null; //print(e[0]); if(e[0] == "TEXT"){ //CREATE TEXT EVENT ev = new TextEvent(e[1],int.Parse(e[5]),e[2],e[3],e[4]); // ("<"+e[2]+">") // print(e[2]); } else if(e[0] == "AUDIO"){ ev = new AudioEvent(e[1],int.Parse(e[5]),e[2],e[3]); } //print("parsed "+ev.name); if(ev != null){ switch(e[3]){ case "L": ev.room = "Living Room"; break; case "K": ev.room = "Kitchen"; break; case "B": ev.room = "Bedroom"; break; case "T": ev.room = "Bathroom"; break; } eventsParsed.Add(ev); //print("parsed room "+ev.name); } //print ("EVENT PARSED: "+eventsParsed[lineCounter].name+" "+eventsParsed[lineCounter].time+" "+eventsParsed[lineCounter].room); lineCounter++; } if(firstTime){ firstTime = false; } } // Done reading, close the reader and return true to broadcast success theReader.Close(); return true; } }