예제 #1
0
 public void OnCollisionEnter()
 {
     if (Lefty)
     {
         BatHaptic.CreateHandle(AreaFlag.Forearm_Left).Play();
     }
     if (Righty)
     {
         BatHaptic.CreateHandle(AreaFlag.Forearm_Right).Play();
     }
 }
예제 #2
0
    public void ToggleSelectedArea()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            Debug.DrawRay(ray.origin, ray.direction * 100, Color.blue, 3.5f);

            if (Physics.Raycast(ray, out hit, 100))
            {
                if (hit.collider.gameObject.tag == "Haptic Region")
                {
                    SuitBodyCollider haptic = hit.collider.gameObject.GetComponent <SuitBodyCollider>();

                    if (haptic != null)
                    {
                        Debug.LogFormat("Starting Haptic: Region ID {0}\n", haptic.regionID);
                        five_second_hum.CreateHandle(haptic.regionID).Play();


                        hit.collider.gameObject.GetComponent <MeshRenderer>().material.color = Color.blue;
                        StartCoroutine(ChangeColorDelayed(
                                           hit.collider.gameObject,
                                           new Color(227 / 255f, 227 / 255f, 227 / 255f, 1f),
                                           5.0f));
                    }
                }
            }
        }
    }
예제 #3
0
        IEnumerator StomacheRumble()
        {
            gulpSource.volume = .85f;

            List <AreaFlag> locs = new List <AreaFlag>();

            locs.Add(AreaFlag.Lower_Ab_Left);
            locs.Add(AreaFlag.Lower_Ab_Right);
            locs.Add(AreaFlag.Mid_Ab_Left);
            locs.Add(AreaFlag.Mid_Ab_Right);

            while (true)
            {
                AreaFlag loc  = locs[Random.Range(0, locs.Count)];
                string   file = Random.Range(0, 1.0f) > .8f ? "Haptics/StomachRumbleHeavy" : "Haptics/StomachRumble";

                HapticSequence seq = new HapticSequence();
                seq.LoadFromAsset(file);
                seq.CreateHandle(loc).Play();

                float waitDur = Random.Range(.05f, .15f);

                yield return(new WaitForSeconds(waitDur));
            }
        }
예제 #4
0
        private HapticHandle CreateHandle(SideOfHaptic side)
        {
            HapticHandle handle = null;

            if (TypeOfPlayable == PlayableType.Sequence)
            {
                HapticSequence seq = new HapticSequence();
                seq.LoadFromAsset(PlayableResourceName);

                var areaFlag = side == SideOfHaptic.Left ? Where.Mirror() : Where;
                handle = seq.CreateHandle(areaFlag);
            }
            else if (TypeOfPlayable == PlayableType.Pattern)
            {
                HapticPattern pat = new HapticPattern();
                pat.LoadFromAsset(PlayableResourceName);
                handle = pat.CreateHandle();
            }
            else if (TypeOfPlayable == PlayableType.Experience)
            {
                HapticExperience exp = new HapticExperience();
                exp.LoadFromAsset(PlayableResourceName);
                handle = exp.CreateHandle();
            }
            else if (TypeOfPlayable == PlayableType.Impulse)
            {
                return(CreateImpulseHandle(side));
            }

            return(handle);
        }
        void Update()
        {
            if (SpherecastStartObject != null)
            {
                worldDirection = transform.rotation * localDirection;
                startLocation  = SpherecastStartObject.transform.position;

                var scaledDir = SphereCastRange * (Vector3.Dot(worldDirection, transform.lossyScale));
                //Debug.Log(Vector3.Dot(worldDirection, transform.lossyScale) + "\n" + worldDirection + "  " + transform.lossyScale + "\n",this);

                scaledRange = GrowRangeWithScale ? SphereCastRange * transform.lossyScale.z : SphereCastRange;

                if (Application.isPlaying && SphereCastActive)
                {
                    var Where = suit.HapticSphereCastForAreas(startLocation, worldDirection, sphereCastRadius, scaledRange);

                    var singles = Where.ToArray();

                    //for (int i = 0; i < singles.Length; i++)
                    //{
                    //}
                    if (!Ready)
                    {
                        timeSinceLastPlay -= Time.deltaTime;
                        if (timeSinceLastPlay <= 0)
                        {
                            Ready = true;
                        }
                    }
                    if (Where != AreaFlag.None && Ready)
                    {
                        var handle = mySequence.CreateHandle(Where, sequenceStrength);
                        handleList.Add(handle);
                        handle.Play();
                        timeSinceLastPlay = Random.Range(RangeOfDelayBetweenReplays.x, RangeOfDelayBetweenReplays.y);
                        Ready             = false;
                    }
                    if (Where == AreaFlag.None)
                    {
                        for (int i = 0; i < handleList.Count; i++)
                        {
                            if (handleList[i] != null)
                            {
                                handleList[i].Stop();
                            }
                            handleList.Clear();
                        }
                    }
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Plays the sequence on the single nearest HapticLocation
        /// Note: A HapticLocation can have an AreaFlag with multiple pads selected.
        /// </summary>
        /// <param name="point">A point in world space to compare</param>
        /// <param name="sequence">The sequence to play on the nearest location</param>
        /// <param name="maxDistance">The max distance the point can be from any HapticLocations</param>
        public AreaFlag HitNearest(Vector3 point, HapticSequence sequence, float maxDistance = 5.0f)
        {
            AreaFlag Where = FindNearestFlag(point, maxDistance);

            if (Where != AreaFlag.None)
            {
                sequence.CreateHandle(Where).Play();
            }
            else
            {
                Debug.Log("Projectile hit the HardlightSuit but found no objects hit. Perhaps the maxDistance (" + maxDistance + ") is too small?\n\tOr the suit/prefab wasn't configured correctly.\n");
            }
            return(Where);
        }
예제 #7
0
        /// <summary>
        /// Plays the sequence on all HapticLocations within a certain radius of the provided point.
        /// </summary>
        /// <param name="point">A point in world space to compare</param>
        /// <param name="sequence">The sequence to play on the nearby locations</param>
        /// <param name="impactRadius">The body is about .6 wide, .72 tall and .25 deep</param>
        public AreaFlag HitNearby(Vector3 point, HapticSequence sequence, float impactRadius = .35f)
        {
            AreaFlag Where = FindAllFlagsWithinRange(point, impactRadius, true);

            if (Where != AreaFlag.None)
            {
                sequence.CreateHandle(Where).Play();
            }
            else
            {
                Debug.Log("Projectile hit the HardlightSuit but found no objects hit. Perhaps the impactRadius (" + impactRadius + ") is too small?\n\tOr the suit/prefab wasn't configured correctly.\n");
            }

            return(Where);
        }
예제 #8
0
 // Update is called once per frame
 void OnTriggerEnter()
 {
     rumbl.CreateHandle(AreaFlag.Back_Both).Play();
     Debug.Log("Working");
 }
예제 #9
0