Inheritance: MonoBehaviour
Beispiel #1
0
 void PlaySound(AudioTrigger audioTrigger)
 {
     audioTrigger.Source.clip   = audioTrigger.Clip;
     audioTrigger.Source.volume = audioTrigger.Volume;
     audioTrigger.Source.loop   = audioTrigger.Loop;
     audioTrigger.Source.PlayDelayed(audioTrigger.Delay);
 }
Beispiel #2
0
 // For StoryManager to call when it's setting up the scene.
 public void AddTrigger(float timestamp, Action action, bool disallowAfterStop = false) {
     Logger.Log("trigger timestamp " + timestamp);
     if (!this.triggers.ContainsKey(timestamp)) {
         this.triggers[timestamp] = new List<AudioTrigger>();
     }
     AudioTrigger newTrigger = new AudioTrigger();
     newTrigger.disallowInvokePastStop = disallowAfterStop;
     newTrigger.action += action;
     this.triggers[timestamp].Add(newTrigger);
 }
Beispiel #3
0
 private void StopAudioTrigger(AudioTrigger audioTrigger)
 {
     if (audioTrigger.emitter == null)
     {
         UAudioManager.Instance.StopEvent(audioTrigger.audioEvent, this.gameObject);
     }
     else
     {
         UAudioManager.Instance.StopEvent(audioTrigger.audioEvent, audioTrigger.emitter);
     }
 }
Beispiel #4
0
 private void Start()
 {
     for (int i = 0; i < this.audioEvents.Length; i++)
     {
         AudioTrigger currentEvent = this.audioEvents[i];
         if (currentEvent.playOnStart)
         {
             PlayAudioTrigger(currentEvent);
         }
     }
 }
Beispiel #5
0
 private void PlayAudioTrigger(AudioTrigger audioTrigger)
 {
     if (audioTrigger.emitter == null)
     {
         UAudioManager.Instance.PlayEvent(audioTrigger.audioEvent);
     }
     else
     {
         UAudioManager.Instance.PlayEvent(audioTrigger.audioEvent, audioTrigger.emitter);
     }
 }
        private void PlayRandomTrigger()
        {
            this.currentTime = 0;
            int          rndTrigger  = Random.Range(0, this.audioTriggers.Length);
            AudioTrigger tempTrigger = this.audioTriggers[rndTrigger];

            if (tempTrigger.emitter == null || string.IsNullOrEmpty(tempTrigger.eventName))
            {
                return;
            }

            UAudioManager.Instance.PlayEvent(tempTrigger.eventName, tempTrigger.emitter);
        }
Beispiel #7
0
 private void Update()
 {
     for (int i = 0; i < this.audioEvents.Length; i++)
     {
         AudioTrigger currentEvent = this.audioEvents[i];
         if (Input.GetKeyDown(currentEvent.playOnKeyHit))
         {
             PlayAudioTrigger(currentEvent);
         }
         if (Input.GetKeyDown(currentEvent.stopOnKeyHit))
         {
             StopAudioTrigger(currentEvent);
         }
     }
 }
    private void OnTriggerEnter(Collider other)
    {
        Enemy              enemy  = other.gameObject.GetComponent <Enemy>();
        WadeMachine        wade   = other.gameObject.GetComponent <WadeMachine>();
        WadeBoatController boat   = other.gameObject.GetComponent <WadeBoatController>();
        BulletStandard     bullet = other.gameObject.GetComponent <BulletStandard>();
        Slash              slash  = other.gameObject.GetComponent <Slash>();
        AudioTrigger       mt     = other.gameObject.GetComponent <AudioTrigger>();

        if (!slash)
        {
            if (wade)
            {
                if (!wadesBullet)
                {
                    wade.DoTakeDamage(damage);
                    Instantiate(explosionEffect, transform.position, transform.rotation);
                    Destroy(gameObject);
                }
            }

            if (enemy)
            {
                if (wadesBullet)
                {
                    enemy.DoTakeDamage(damage);
                    Instantiate(explosionEffect, transform.position, transform.rotation);
                    Destroy(gameObject);
                }
            }


            if (!wade && !bullet && !boat && !mt)
            {
                if (other.gameObject.name != "BoatTrigger" && other.gameObject.name != "Mover")
                {
                    Instantiate(explosionEffect, transform.position, transform.rotation);
                    Destroy(gameObject);
                }
            }
        }
    }
Beispiel #9
0
        public void Initialize(PYAudioTags audioTag, PYAudioManager.AudioTrack track)
        {
            AudioTag = audioTag;
            Track    = track;
            Group    = PYAudioManager.Instance.Groups[Track.GroupTag];

            if (_source == null)
            {
                _source = GetComponent <AudioSource>();
            }

            _source.playOnAwake           = false;
            _source.clip                  = Track.Clip;
            _source.loop                  = false;
            _source.mute                  = Group.Mute;
            _source.volume                = Group.Volume;
            _source.pitch                 = 1;
            _source.outputAudioMixerGroup = PYAudioManager.Instance.Mixer.FindMatchingGroups(Track.GroupTag.ToString())[0];

            if (_source.clip != null)
            {
                _duration = _source.clip.length;
            }

            _delay              = 0;
            _loop               = false;
            IsPlaying           = IsPaused = false;
            _isStoppingWithFade = false;

            OnStartPlaying = null;
            OnPlaying      = null;
            OnResume       = null;
            OnPaused       = null;
            OnCompleted    = null;
            OnStopped      = null;

            AudioTrigger.Initialize(audioTag);
        }
Beispiel #10
0
        private void DrawAudioTriggers()
        {
            EditorGUIUtil.Toggle("Lock", ref locked);
            // set missing triggers
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Missing");
            if (missingTriggerInspector.DrawInspectorGUI(ref missingTable, ref missingClip) && missingClip.IsNotEmpty())
            {
                foreach (AudioTriggerInspectorImpl i in triggers)
                {
                    if (i.trigger.audioGroupGuid.IsEmpty() || i.trigger.clip.IsEmpty())
                    {
                        i.SelectTable(missingTable);
                        i.trigger.clip = missingClip;
                        CompatibilityEditor.SetDirty(i.trigger);
                        changedList.Add(i.trigger.gameObject);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUIUtil.DrawSeparator();
            // Search AudioTriggers
            if ((roots.IsEmpty() || !locked) && Selection.gameObjects.IsNotEmpty() && !Array.Equals(roots, Selection.gameObjects))
            {
                Clear();
                roots = Selection.gameObjects;
                List <AudioTrigger> audio = new List <AudioTrigger> ();
                foreach (GameObject o in roots)
                {
                    foreach (UIButton btn in o.GetComponentsInChildren <UIButton>(true))
                    {
                        AudioTrigger[] t = btn.GetComponents <AudioTrigger> ();
                        if (t.IsEmpty())
                        {
                            t = new AudioTrigger[] { btn.gameObject.AddComponent <AudioTrigger> () };
                            changedList.Add(btn.gameObject);
                            CompatibilityEditor.SetDirty(btn.gameObject);
                        }
                        audio.AddRange(t);
                    }
                }
                AudioDataTable[] tables = AudioTriggerInspectorImpl.LoadTables();
                triggers = new AudioTriggerInspectorImpl[audio.Count];
                for (int i = 0; i < audio.Count; ++i)
                {
                    triggers [i]           = new AudioTriggerInspectorImpl(audio [i], tables);
                    triggers [i].showLabel = false;
                }
            }

            // draw trigger list
            EditorGUILayout.BeginVertical();
            foreach (AudioTriggerInspectorImpl a in triggers)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.ObjectField(a.trigger.gameObject, typeof(GameObject), true);
                if (a.DrawInspectorGUI())
                {
                    changedList.Add(a.trigger.gameObject);
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();

            if (GUILayout.Button("Save"))
            {
                SaveChange(changedList);
                changedList.Clear();
            }
        }