//
        IEnumerator ShockPlayer()
        {
            //This serves as the 'Is Coroutine Running' variable
            CurrentlyShocking = true;

            //This is a construct for our repetition of the traversal effect.
            float delay = .4f;

            //Prevent the loop/effect from running forever.
            int breakout = 0;

            //A handle for canceling the shock when the condition is no longer true.
            HapticHandle shockHandle = null;

            //This is the loop that will re-start the impulse
            //Remember that CurrentShocking is a bool from outside this function. Meaning it can be turned off and then we leave the loop.
            while (CurrentlyShocking && breakout < 25)
            {
                //Finally, don't forget to play the effect.
                shockHandle = shockImpulse.Play();

                //Wait before the next zap
                yield return(new WaitForSeconds(delay));

                //Max of X Zaps.
                breakout++;
            }

            //If we stop shocking the player, we want to clean up the last effect played. This means when the player stops touching the outlet, they stop getting shocked.
            shockHandle.Reset();

            //Mark that we aren't shocking the player.
            CurrentlyShocking = false;
        }
Exemplo n.º 2
0
        public void OnGUI()
        {
            if (GUI.Button(new Rect(50, 50, 120, 50), "Test Experience"))
            {
                new Experience("ns.demos.recharge_demo").CreateHandle().Play();
            }
            if (GUI.Button(new Rect(50, 100, 120, 50), "Test Pattern"))
            {
                new Pattern("ns.demos.recharge_reverse").CreateHandle().Play();
            }

            if (GUI.Button(new Rect(50, 150, 150, 50), "Test Sequence"))
            {
                new Sequence("ns.demos.five_second_hum").CreateHandle(AreaFlag.Chest_Both).Play();
            }

            if (GUI.Button(new Rect(400, 100, 100, 50), "Play Hum"))
            {
                clickerHandle.Play();
            }
            if (Input.GetKeyDown(KeyCode.I))
            {
                //	new Sequence("ns.click").CreateHandle(AreaFlag.Lower_Ab_Both).Play();
                new Pattern("ns.demos.pulse").CreateHandle().Play();
            }
            if (Input.GetKeyDown(KeyCode.O))
            {
                //	new Sequence("ns.click").CreateHandle(AreaFlag.Lower_Ab_Both).Play();
                //new Pattern("ns.demos.pulse").CreateHandle().Play();
            }
            if (GUI.Button(new Rect(500, 100, 100, 50), "Pause Hum"))
            {
                clickerHandle.Pause();
            }
            if (GUI.Button(new Rect(600, 100, 100, 50), "Reset Hum"))
            {
                clickerHandle.Reset();
            }
            if (GUI.Button(new Rect(740, 100, 120, 50), "Clear All Effects"))
            {
                NSManager.Instance.ClearAllEffects();
            }
            if (GUI.Button(new Rect(50, 250, 150, 50), "Massage"))
            {
                massage = !massage;
                StartCoroutine(MoveFromTo(new Vector3(0, -3.5f, 0), new Vector3(0, 4.5f, 0), .8f));
            }

            if (GUI.Button(new Rect(50, 200, 100, 40), "Jolt Left Body"))
            {
                new Sequence("ns.click").CreateHandle(AreaFlag.Left_All).Play();
            }
            if (GUI.Button(new Rect(150, 200, 100, 40), "Jolt Full Body"))
            {
                new Sequence("ns.click").CreateHandle(AreaFlag.All_Areas).Play();
            }
            if (GUI.Button(new Rect(250, 200, 100, 40), "Jolt Right Body"))
            {
                new Sequence("ns.click").CreateHandle(AreaFlag.Right_All).Play();
            }
        }