protected void HandleDetent(Message msg)
        {
            VectorPayload payload = JsonUtility.FromJson <VectorPayload>(msg.payload);

            if (activeDetent < DateTime.Now)
            {
                if (payload.vector.x < 0)
                {
                    ArmStimulation.StimulateArmBurst(
                        new StimulationInfo(
                            Part.Biceps,
                            Side.Right,
                            widthDetentB,
                            currentDetentB
                            ),
                        detentDuration
                        );
                }
                else
                {
                    ArmStimulation.StimulateArmBurst(
                        new StimulationInfo(
                            Part.Triceps,
                            Side.Right,
                            widthDetentT,
                            currentDetentT
                            ),
                        detentDuration
                        );
                }
                activeDetent = DateTime.Now.AddMilliseconds(cooldownDetent);
            }
        }
Ejemplo n.º 2
0
        protected virtual void HandleImpact(Message msg)
        {
            VectorPayload payload = JsonUtility.FromJson <VectorPayload>(msg.payload);

            if (payload.vector.Equals(Vector3.down))
            {
                StimulationInfo[] infos = new StimulationInfo[]
                {
                    new StimulationInfo(
                        Part.Triceps,
                        Side.Right,
                        impactWidth,
                        currentTriceps
                        ),
                    new StimulationInfo(
                        Part.Triceps,
                        Side.Left,
                        impactWidth,
                        currentTriceps
                        ),
                };
                // Ramp up shortly
                ArmStimulation.StimulateArmBurst(
                    infos,
                    impactDuration
                    );
            }
        }
Ejemplo n.º 3
0
        protected virtual void HandlePosition(Message msg)
        {
            VectorPayload payload = JsonUtility.FromJson <VectorPayload>(msg.payload);

            float t      = (0.5f + payload.vector.x);
            int   widthL = (int)Mathf.Lerp(offset, tricepsL, (1 - t) * positionFactor);
            int   widthR = (int)Mathf.Lerp(offset, tricepsR, t * positionFactor);

            ArmStimulation.StimulateArm(
                Part.Triceps,
                Side.Left,
                widthL,
                currentTriceps
                );

            ArmStimulation.StimulateArm(
                Part.Triceps,
                Side.Right,
                widthR,
                currentTriceps
                );

            stopTime    = DateTime.Now.AddMilliseconds(500);
            stimulating = true;
        }
Ejemplo n.º 4
0
 public static SpeckleVector ToSpeckleVector(this VectorPayload payload)
 {
     return(new SpeckleVector
     {
         Value = payload.Value
     });
 }
Ejemplo n.º 5
0
        public override void HandleMessage(Message msg)
        {
            VectorPayload payload = JsonUtility.FromJson <VectorPayload>(msg.payload);

            switch (payload.source)
            {
            case "Position":
                hand.position = tracker.TransformPoint(payload.vector);
                break;

            case "Rotation":
                //hand.localEulerAngles = tracker.InverseTransformDirection(payload.vector);
                break;
            }
        }
Ejemplo n.º 6
0
        protected virtual void HandleWallCollision(Message msg)
        {
            VectorPayload payload = JsonUtility.FromJson <VectorPayload>(msg.payload);

            if (Mathf.Abs(payload.vector.z) < wallThreshold)
            {
                return;
            }

            // z-Axis looks to the left
            Side sideB = payload.vector.z > 0 ? Side.Left : Side.Right;
            Side sideT = payload.vector.z > 0 ? Side.Right : Side.Left;

            Debug.Log(payload.vector.z);

            StimulationInfo[] infos = new StimulationInfo[]
            {
                new StimulationInfo(
                    Part.Triceps,
                    sideT,
                    wallImpactWidthTriceps,
                    currentTriceps
                    ),
                new StimulationInfo(
                    Part.Biceps,
                    sideB,
                    wallImpactWidthBiceps,
                    currentBiceps
                    ),
            };
            // Ramp up shortly
            ArmStimulation.StimulateArmBurst(
                infos,
                wallImpactDuration
                );
        }
        protected void HandleDialDetent(Message msg)
        {
            VectorPayload payload = JsonUtility.FromJson <VectorPayload>(msg.payload);


            Debug.Log(payload.source + (payload.vector.x < 0).ToString());

            switch (payload.source)
            {
            case "Thermo":
                if (!activeThermo)
                {
                    break;
                }

                if (activeTimeThermo < DateTime.Now)
                {
                    if (payload.vector.x < 0)
                    {
                        ArmStimulation.StimulateArmBurst(
                            new StimulationInfo(
                                Part.InwardsWrist,
                                Side.Right,
                                inDetentR,
                                current
                                ),
                            detentDuration
                            );
                    }
                    else
                    {
                        ArmStimulation.StimulateArmBurst(
                            new StimulationInfo(
                                Part.OutwardsWrist,
                                Side.Right,
                                outDetentsR,
                                current
                                ),
                            detentDuration
                            );
                    }

                    activeTimeThermo = DateTime.Now.AddMilliseconds(cooldown);
                }
                break;

            case "Intensity":
                currentIntensity = (int)payload.vector.y;

                if (targetIntensity == currentIntensity)
                {
                    ChannelList.Stop();
                    targetIntensity = -1;
                    Debug.Log("Snapped to last Intensity");
                }

                if (changing && !invalidCombination())
                {
                    ChannelList.Stop();

                    Debug.Log("Changed To Valid Combination");
                    changing = false;
                }
                else if (invalidCombination())
                {
                    Debug.Log("Invalid Combination");
                    changing = true;
                }

                if (!activeIntensity)
                {
                    break;
                }

                if (activeTimeIntensity < DateTime.Now)
                {
                    if (payload.vector.x < 0)
                    {
                        ArmStimulation.StimulateArmBurst(
                            new StimulationInfo(
                                Part.InwardsWrist,
                                Side.Right,
                                inDetentR,
                                current
                                ),
                            detentDuration
                            );
                    }
                    else
                    {
                        ArmStimulation.StimulateArmBurst(
                            new StimulationInfo(
                                Part.OutwardsWrist,
                                Side.Right,
                                outDetentsR,
                                current
                                ),
                            detentDuration
                            );
                    }

                    activeTimeIntensity = DateTime.Now.AddMilliseconds(cooldown);
                }
                break;

            case "Color":
                if (!activeColor)
                {
                    break;
                }

                currentColor = (int)payload.vector.y;

                // snap to intensity 2
                if (invalidCombination())
                {
                    Debug.Log("Invalid Combination");
                    changing = true;
                }

                if (activeTimeColor < DateTime.Now)
                {
                    if (payload.vector.x < 0)
                    {
                        ArmStimulation.StimulateArmBurst(
                            new StimulationInfo(
                                Part.InwardsWrist,
                                Side.Left,
                                outDetentL,
                                current
                                ),
                            detentDuration
                            );
                    }
                    else
                    {
                        ArmStimulation.StimulateArmBurst(
                            new StimulationInfo(
                                Part.OutwardsWrist,
                                Side.Left,
                                inDetentL,
                                current
                                ),
                            detentDuration
                            );
                    }

                    activeTimeColor = DateTime.Now.AddMilliseconds(cooldown);
                }
                break;
            }
        }
Ejemplo n.º 8
0
        protected void HandleTarget(Message msg)
        {
            VectorPayload payload = JsonUtility.FromJson <VectorPayload>(msg.payload);

            Debug.Log("Target hit:" + payload.source);
        }