示例#1
0
 public void AddDelayedEvent(LightTriggerEvent e)
 {
     _triggeredEventsToTrack.Add(e);
 }
示例#2
0
        public void Trigger(TriggerLightEffect parentEffect, bool forceLooping = false, EightNightsMIDIMgr.EightNightsMIDIEventArgs midiEvent = null)
        {
            //if we have a looping effect playing, ignore...
             if (_spawnedObj != null)
            return;

             if (LightEffectToTrigger != null)
             {
            //instatiate new effect and override light if specified
            GameObject spawnedLightObj = Instantiate(LightEffectToTrigger.gameObject) as GameObject;
            spawnedLightObj.transform.parent = parentEffect.transform;
            LightEffect spawnedLightEffect = spawnedLightObj.GetComponent<LightEffect>();
            if (EnableLightOverride)
            {
               foreach (LightEffect.EffectKeyframe k in spawnedLightEffect.Keyframes)
               {
                  foreach (LightEffect.LightState s in k.LightKeys)
                  {
                     s.Light = LightOverride;
                  }
               }
            }
            spawnedLightEffect.LightGroup = parentEffect.MIDIGroup;
            spawnedLightEffect.MasterFader = parentEffect.ApplyNoteVelocity ? Mathf.Lerp(parentEffect.MinNoteVelocity, 1.0f, midiEvent.Velocity) : 1.0f;
            spawnedLightEffect.AutoTrigger = true;
            spawnedLightEffect.TriggerEffect(); //redundant, I know
            if (forceLooping)
            {
               KillEffect(); //kill any previous version of this effect

               spawnedLightEffect.Loop = true;
               _spawnedObj = spawnedLightObj;
               spawnedLightEffect.AutoDestroy = false;
               spawnedLightEffect.FadeWithStemVolume = false;
               spawnedLightEffect.FadeWithButtonCrescendo = true;

            }
            else //if we aren't looping then we auto destroy
            {
               spawnedLightEffect.FadeWithStemVolume = true;
               spawnedLightEffect.FadeWithButtonCrescendo = false;
               spawnedLightEffect.AutoDestroy = true;
               _spawnedObj = null;

               //Debug.Log("Note " + midiEvent.MidiNote + " velocity: " + midiEvent.Velocity);

               //send out event that we're triggering an effect on a particular light
               if ((EightNightsMgr.Instance != null) && (midiEvent != null))
               {
                  //assume all the lights its driving are the same
                  EightNightsMgr.LightID lID = spawnedLightEffect.Keyframes[0].LightKeys[0].Light;
                  //queue this up to send out once latency is elapsed
                  LightTriggerEvent delayedEvent = new LightTriggerEvent();
                  delayedEvent.Group = parentEffect.MIDIGroup;
                  delayedEvent.Light = lID;
                  delayedEvent.BeatTime = midiEvent.NoteBeat;
                  delayedEvent.Weight = midiEvent.Velocity;

                  //WHY?
                  delayedEvent.BeatTime -= (BeatClock.Instance.LatencySecs() / BeatClock.Instance.SecsPerBeat());

                  parentEffect.AddDelayedEvent(delayedEvent);
               }
            }

            //LightEffectToTrigger.TriggerEffect();
             }
        }