Ejemplo n.º 1
0
        /// <summary>
        /// Takes an impulse and plays it with the ImpulseDemo's parameters.
        /// This takes an impulse so you don't need to instantiate one every time.
        /// If you're doing the same impulse regularly, it saves traversal/breadth first searching
        /// </summary>
        /// <param name="imp">A constructed impulse of the emanation or traversal</param>
        private void ConfigureAndPlayImpulse(ImpulseGenerator.Impulse imp)
        {
            if (CurrentMode == ImpulseType.Emanating)
            {
                StartCoroutine(ColorSuitForEmanation());
            }
            else
            {
                StartCoroutine(ColorSuitForTraversal());
            }

            //To support CodeSequence Samples
            if (SelectedCodeSequence < 0)
            {
                //These are broken up by lines for readability
                imp.WithDuration(ImpulseDuration);
                imp.WithAttenuation(Attenuation);
                imp.WithEffect(effectOptions[currentEffect], EffectDuration, EffectStrength);
                imp.Play();

                //You can do something like:
                //i.WithAttenuation(Attenuation).WithDuration(ImpulseDuration).WithEffect(effectOptions[CurrentEffect], EffectDuration, EffectStrength).Play();
                //Chaining and Functional Programming!
            }
            else
            {
                //These are broken up by lines for readability
                imp.WithDuration(ImpulseDuration);
                imp.WithAttenuation(Attenuation);
                imp.WithEffect(GetCodeSequence());
                imp.Play();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Takes an impulse and plays it with the ImpulseDemo's parameters.
        /// This takes an impulse so you don't need to instantiate one every time.
        /// If you're doing the same impulse regularly, it saves traversal/breadth first searching
        /// </summary>
        /// <param name="imp">A constructed impulse of the emanation or traversal</param>
        private void ConfigureAndPlayImpulse(ImpulseGenerator.Impulse imp)
        {
            if (CurrentMode == ImpulseType.Emanating)
            {
                StartCoroutine(ColorSuitForEmanation());
            }
            else
            {
                StartCoroutine(ColorSuitForTraversal());
            }

            //To support HapticSequence Samples
            if (UseEffectSelectorSlider)
            {
                //Prevent array index out of bounds errors.
                Effect whichEffect = effectOptions[Mathf.Clamp(currentEffect, 0, effectOptions.Length - 1)];

                //These are broken up by lines for readability
                imp.WithDuration(ImpulseDuration);
                imp.WithAttenuation(Attenuation);
                imp.WithEffect(whichEffect, EffectDuration, EffectStrength);
                imp.Play();

                //You can do something like:
                //i.WithAttenuation(Attenuation).WithDuration(ImpulseDuration).WithEffect(effectOptions[CurrentEffect], EffectDuration, EffectStrength).Play();
                //Chaining and Functional Programming!
            }
            else
            {
                //These are broken up by lines for readability
                imp.WithDuration(ImpulseDuration);
                imp.WithAttenuation(Attenuation);
                imp.WithEffect(GetHapticSequence());
                imp.Play();
            }
        }
Ejemplo n.º 3
0
        private void Start()
        {
            Effect whichEffect          = Effect.Pulse;         //What's more electrical than pulses.
            float  totalImpulseDuration = .35f;                 //How long does the shock take to traverse to the heart.
            float  effectDuration       = 0.0f;                 //0.0 defaults to the natural duration of the pulse effect.
            float  effectStrength       = 1;                    //How strong is the pulse effect

            //Create the Impulse object (which can be told to play, which instantiates what it 'is')
            shockImpulse = ImpulseGenerator.BeginTraversingImpulse(AreaFlag.Forearm_Right, AreaFlag.Chest_Left);

            // This sets the duration to be .25 seconds
            shockImpulse.WithDuration(totalImpulseDuration);

            //This defines the base effect (which needs an effect name, a strength and a duration)
            shockImpulse.WithEffect(whichEffect, effectDuration, effectStrength);
        }