Ejemplo n.º 1
0
        /// <summary>
        /// Creating a randomized code sequence is totally doable.
        /// This is a less than ideal approach (because static method)
        /// In your code you shouldn't use a static method like this (Do as I say, not as I do)
        /// </summary>
        /// <param name="randSeed">Hand in a random seed (or better yet, don't use random in static functions</param>
        /// <returns>A CodeSequence reference for use in Impulses</returns>
        public static CodeSequence RandomPulses(int randSeed)
        {
            //Debug.Log(randSeed + "\n");
            System.Random rand = new System.Random(randSeed);

            CodeSequence seq = new CodeSequence();

            float      dur   = ((float)rand.Next(0, 15)) / 10;
            float      delay = ((float)rand.Next(0, 10)) / 20;
            CodeEffect eff   = new CodeEffect("pulse", dur, ((float)rand.Next(0, 10)) / 10);

            seq.AddEffect(0.0, eff);
            float offset = dur;

            dur   = ((float)rand.Next(0, 15)) / 20;
            delay = ((float)rand.Next(0, 8)) / 20;
            //Debug.Log(dur + "\n");
            eff = new CodeEffect("pulse", dur, ((float)rand.Next(0, 10)) / 10);
            seq.AddEffect(offset + delay, eff);
            offset = dur;

            dur   = ((float)rand.Next(0, 15)) / 20;
            delay = ((float)rand.Next(0, 8)) / 20;
            //Debug.Log(dur + "\n");
            eff = new CodeEffect("pulse", dur, ((float)rand.Next(0, 10)) / 10);
            seq.AddEffect(offset + delay, eff);

            return(seq);
        }
Ejemplo n.º 2
0
        public static CodeSequence ClickHum()
        {
            CodeSequence seq = new CodeSequence();
            CodeEffect   eff = new CodeEffect("click", 0.0f, 1.0f);

            seq.AddEffect(0, eff);
            eff = new CodeEffect("hum", .2f, .5f);
            seq.AddEffect(.15, eff);
            return(seq);
        }
Ejemplo n.º 3
0
        public static CodeSequence ThockClunk()
        {
            CodeSequence seq = new CodeSequence();
            CodeEffect   eff = new CodeEffect("sharp_click", 0.15f, 1.0f);

            seq.AddEffect(0, eff);
            eff = new CodeEffect("fuzz", .2f, 1.0f);
            seq.AddEffect(.15, eff);
            return(seq);
        }
Ejemplo n.º 4
0
        public static CodeSequence ClickStorm()
        {
            CodeSequence seq = new CodeSequence();

            CodeEffect eff = new CodeEffect("double_click", .0f, 1.0f);

            seq.AddEffect(0, eff);

            eff = new CodeEffect("click", .0f, 1.0f);
            seq.AddEffect(0.1, eff);

            eff = new CodeEffect("long_double_sharp_tick", .0f, 1.0f);
            seq.AddEffect(0.2, eff);

            eff = new CodeEffect("sharp_click", .0f, 1.0f);
            seq.AddEffect(0.3, eff);

            eff = new CodeEffect("sharp_tick", .0f, 1.0f);
            seq.AddEffect(0.4, eff);

            eff = new CodeEffect("short_double_click", .0f, 1.0f);
            seq.AddEffect(0.5, eff);

            eff = new CodeEffect("short_double_sharp_tick", .0f, 1.0f);
            seq.AddEffect(0.6, eff);

            eff = new CodeEffect("triple_click", .0f, 1.0f);
            seq.AddEffect(0.7, eff);

            return(seq);
        }
Ejemplo n.º 5
0
        public static CodeSequence DoubleClickImpact()
        {
            CodeSequence seq = new CodeSequence();
            CodeEffect   eff = new CodeEffect("double_click", 0.00f, 1.0f);

            seq.AddEffect(0, eff);
            eff = new CodeEffect("buzz", .05f, 1.0f);
            seq.AddEffect(.05, eff);
            eff = new CodeEffect("buzz", .10f, .6f);
            seq.AddEffect(.10, eff);
            eff = new CodeEffect("buzz", .15f, .2f);
            seq.AddEffect(.2, eff);

            return(seq);
        }
Ejemplo n.º 6
0
        public static CodeSequence TripleClickFuzzFalloff()
        {
            CodeSequence seq = new CodeSequence();

            CodeEffect eff = new CodeEffect("triple_click", 0.20f, 0.7f);

            seq.AddEffect(0.0, eff);

            eff = new CodeEffect("fuzz", .20f, 1.0f);
            seq.AddEffect(0.2, eff);

            eff = new CodeEffect("fuzz", .20f, 0.5f);
            seq.AddEffect(0.4, eff);

            return(seq);
        }
Ejemplo n.º 7
0
        public static CodeSequence PulseBumpPulse()
        {
            CodeSequence seq = new CodeSequence();

            CodeEffect eff = new CodeEffect("pulse", 0.40f, 0.7f);

            seq.AddEffect(0.0, eff);

            eff = new CodeEffect("bump", .0f, 1.0f);
            seq.AddEffect(0.40, eff);

            eff = new CodeEffect("pulse", 0.0f, 0.2f);
            seq.AddEffect(0.55, eff);

            return(seq);
        }
Ejemplo n.º 8
0
        public static CodeSequence ClickHumDoubleClick()
        {
            CodeSequence seq = new CodeSequence();

            CodeEffect eff = new CodeEffect("click", 0.0f, 1.0f);

            seq.AddEffect(0, eff);

            eff = new CodeEffect("transition_hum", .50f, 1.0f);
            seq.AddEffect(0.10, eff);

            eff = new CodeEffect("double_click", .0f, 1.0f);
            seq.AddEffect(0.6, eff);

            return(seq);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// A VERY random effect. More just for showing haptic varion
        /// </summary>
        /// <param name="randSeed"></param>
        /// <returns></returns>
        public static CodeSequence VeryRandomEffect(int randSeed)
        {
            //Debug.Log(randSeed + "\n");
            System.Random rand = new System.Random(randSeed);

            CodeSequence seq = new CodeSequence();

            int effIndex = rand.Next(0, SuitImpulseDemo.effectOptions.Length);

            float      dur    = ((float)rand.Next(0, 6)) / 3;
            float      delay  = 0;
            float      offset = 0;
            CodeEffect eff    = null;

            int HowManyEffects = rand.Next(2, 11);

            //Debug.Log("How many effects: " + HowManyEffects + "\n");
            for (int i = 0; i < HowManyEffects; i++)
            {
                effIndex = rand.Next(0, SuitImpulseDemo.effectOptions.Length);
                dur      = ((float)rand.Next(0, 6)) / 3;
                delay    = ((float)rand.Next(0, 8)) / 20;
                eff      = new CodeEffect(SuitImpulseDemo.effectOptions[effIndex], dur, ((float)rand.Next(0, 10)) / 10);
                seq.AddEffect(offset + delay, eff);
                offset = dur;
            }

            return(seq);
        }
Ejemplo n.º 10
0
    void OnCollisionEnter(Collision collision)
    {
        var seq = new CodeSequence();

        //  seq.AddEffect(0.0, new CodeEffect("double_click", 1 - (playerHealth / playerMaxHealth), (playerMaxHealth / playerHealth)));
        seq.AddEffect(0.0, new CodeEffect("double_click", 0.9f));
        seq.Play(AreaFlag.All_Areas);
    }
Ejemplo n.º 11
0
        /// <summary>
        /// This is the Impulse that was used for the Desert of Danger recoil effect.
        /// It is imperfect in the implementation because it doesn't allow for flexibility to pick the effect.
        /// It could also take a more flexible Duration component but the core here is to give you what we used.
        /// Use ImpulseGenerator.CreateImpulse() function instead of modifying this.
        /// This sample does work.
        /// </summary>
        /// <param name="StartLocation">Pick the location to begin. DO NOT PROVIDE MULTIPLE AREAS.</param>
        /// <param name="EndLocation">Pick the destination to reach. DO NOT PROVIDE MULTIPLE AREAS.</param>
        /// <returns>Don't forget to call .Play() on the returned Impulse to create an instance of the haptic effect it defines.</returns>
        public static ImpulseGenerator.Impulse DesertOfDangerRecoil(AreaFlag StartLocation = AreaFlag.Forearm_Left, AreaFlag EndLocation = AreaFlag.Upper_Arm_Left)
        {
            //A simple code sequence
            CodeSequence seq = new CodeSequence();

            //The elements we will add
            CodeEffect eff  = new CodeEffect("buzz", 0.00f, 1.0f);
            CodeEffect eff2 = new CodeEffect("buzz", 0.15f, 0.5f);

            //The time stamps of the different effects.
            seq.AddEffect(0, eff);
            seq.AddEffect(.1, eff2);

            //In Desert of Danger, we used a duration of .1 seconds. This means the recoil effect took .1 seconds to hit ALL pads it aimed to. If you hand in different pads, it'll likely want a longer duration.
            //Since we only used the forearm and the upper arm, .1s is more than sufficient.
            //We could've used a file for this, but this was right as we were conceptualizing and beginning the usage of the ImpulseGenerator.
            return(ImpulseGenerator.BeginTraversingImpulse(StartLocation, EndLocation)
                   .WithDuration(.10f)
                   .WithEffect(seq));
        }
Ejemplo n.º 12
0
        public HapticHandle CreateCodeHaptic()
        {
            //Debug.Log("Hit\n");
            CodeSequence seq = new CodeSequence();

            seq.AddEffect(0.0f, new CodeEffect("buzz", .2f));
            seq.AddEffect(0.3f, new CodeEffect("click", 0.0f));
            //seq.Play(AreaFlag.All_Areas);

            CodePattern pat = new CodePattern();

            pat.AddSequence(0.5f, AreaFlag.Lower_Ab_Both, seq);
            pat.AddSequence(1.0f, AreaFlag.Mid_Ab_Both, seq);
            pat.AddSequence(1.5f, AreaFlag.Upper_Ab_Both, seq);
            pat.AddSequence(2.0f, AreaFlag.Chest_Both, seq);
            pat.AddSequence(2.5f, AreaFlag.Shoulder_Both, seq);
            pat.AddSequence(2.5f, AreaFlag.Back_Both, seq);
            pat.AddSequence(3.0f, AreaFlag.Upper_Arm_Both, seq);
            pat.AddSequence(3.5f, AreaFlag.Forearm_Both, seq);
            return(pat.Play());
        }
Ejemplo n.º 13
0
        public static CodeSequence Shimmer()
        {
            CodeSequence seq = new CodeSequence();
            CodeEffect   eff = new CodeEffect("double_click", 0.00f, 1.0f);

            //This is from the NS.DoD.Shimmer.sequence reimplemented as CodeSequence. this is because we don't yet have CodeSequence+File Sequence cross use.
            //{ "time" : 0.0, "effect" : "transition_hum", "strength" : 0.1, "duration" : 0.05},
            //{ "time" : 0.05, "effect" : "hum", "strength" : 0.1, "duration" : 0.1},
            //{ "time" : 0.15, "effect" : "hum", "strength" : 0.5, "duration" : 0.1},
            //{ "time" : 0.25, "effect" : "hum", "strength" : 0.1, "duration" : 0.1}

            seq.AddEffect(0, eff);
            eff = new CodeEffect("transition_hum", 0.05f, 0.1f);
            seq.AddEffect(.05, eff);
            eff = new CodeEffect("hum", .1f, .1f);
            seq.AddEffect(.15, eff);
            eff = new CodeEffect("hum", .1f, .5f);
            seq.AddEffect(.25, eff);
            eff = new CodeEffect("hum", .1f, .1f);

            return(seq);
        }
Ejemplo n.º 14
0
    IEnumerator MyHeartbeat()
    {
        IsHeartBeating = true;
        var seq = new CodeSequence();

        //seq.AddEffect(0.0, new CodeEffect("double_click", 1 - (playerHealth / playerMaxHealth), (playerMaxHealth / playerHealth)));
        seq.AddEffect(0.0, new CodeEffect("double_click", 0.6f));
        while (IsHeartBeating)
        {
            seq.Play(AreaFlag.Chest_Left);
            yield return(new WaitForSeconds(1.0f));
            //yield return new WaitForSeconds((playerHealth / playerMaxHealth));
        }
    }
Ejemplo n.º 15
0
        /// <summary>
        /// Creating a randomized code sequence is totally doable.
        /// This is a less than ideal approach (because static method)
        /// In your code you shouldn't use a static method like this (Do as I say, not as I do)
        /// This one is about picking three effects at random (with random strength levels as well)
        /// </summary>
        /// <param name="randSeed">Hand in a random seed (or better yet, don't use random in static functions</param>
        /// <returns>A CodeSequence reference for use in Impulses</returns>
        public static CodeSequence ThreeRandomEffects(int randSeed)
        {
            //Debug.Log(randSeed + "\n");
            System.Random rand = new System.Random(randSeed);

            CodeSequence seq = new CodeSequence();

            int effIndex = rand.Next(0, SuitImpulseDemo.effectOptions.Length);

            CodeEffect eff = new CodeEffect(SuitImpulseDemo.effectOptions[effIndex], 0.0f, ((float)rand.Next(2, 10)) / 10);

            seq.AddEffect(0.0, eff);

            effIndex = rand.Next(0, SuitImpulseDemo.effectOptions.Length);
            eff      = new CodeEffect(SuitImpulseDemo.effectOptions[effIndex], 0.0f, ((float)rand.Next(2, 10)) / 10);
            seq.AddEffect(.20f, eff);

            effIndex = rand.Next(0, SuitImpulseDemo.effectOptions.Length);
            eff      = new CodeEffect(SuitImpulseDemo.effectOptions[effIndex], 0.0f, ((float)rand.Next(2, 10)) / 10);
            seq.AddEffect(.4f, eff);

            return(seq);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Shoots the player body somewhere with a simple buzz emanation impulse.
        /// </summary>
        /// <param name="ShotWhere">Self explanator. DO NOT PROVIDE MULTIPLE AREAS.</param>
        /// <returns>Don't forget to call .Play() on the returned Impulse to create an instance of the haptic effect it defines.</returns>
        public static ImpulseGenerator.Impulse DesertOfDangerShot(AreaFlag ShotWhere = AreaFlag.Chest_Right)
        {
            CodeSequence seq = new CodeSequence();

            //This will be slightly different then the default "buzz" effect Impulse. If you ask for an effect with a duration of 0, it'll play the natural duration.
            //Natural durations range from .05s (click, buzz, etc) to .25s (the multiple click families)
            //So by providing a duration of .1, this will be slightly different than the line:
            //		CodeEffect eff = new CodeEffect("buzz", 0.00f, 1.0f);

            CodeEffect eff = new CodeEffect("buzz", 0.10f, 1.0f);

            seq.AddEffect(0, eff);

            //The Desert of Danger demo set the entire impulse duration to .25s,
            //this means that it emanated out from where the playerwas hit.
            return(ImpulseGenerator.BeginEmanatingEffect(ShotWhere)
                   .WithEffect(seq)
                   .WithDuration(.25f));
        }
Ejemplo n.º 17
0
            /// <summary>
            /// Creates a new CodeSequence and overwrites this Impulse's current Sequence.
            /// </summary>
            /// <param name="effect">The effect family to play.</param>
            /// <param name="duration">The duration of the sequence.</param>
            /// <param name="strength">The strength of the effect (which selects the corresponding family member under the hood)</param>
            /// <returns>The Impulse that you can call .Play() on to play a create a HapticHandle referencing that Haptic</returns>
            public Impulse WithEffect(string effect, float duration = 0.0f, float strength = 1.0f)
            {
                if (duration < 0.0f)
                {
                    throw new ArgumentException("Attempted to assign a negative duration for Impulse's WithEffect(). How would that even work?", "duration");
                }
                if (strength < 0.0f)
                {
                    Debug.LogWarning("[ImpulseGenerator] was provided a negative effect strength. Clamped to 0.0f");
                    strength = 0.0f;
                }

                CodeSequence seq = new CodeSequence();

                seq.AddEffect(0.0f, new CodeEffect(effect, duration, strength));
                if (seq == null)
                {
                    throw new ArgumentException("Attempted to assign a null CodeSequence seq - retaining previous CodeSequence", "seq");
                }
                this.seq = seq;
                return(this);
            }