public void ForceGrab(GameObject go, ControllerInformation info)
    {
        GrabObjectInformation grabObjInfo = (GrabObjectInformation)info.GetFunctionalityInfoByType(typeof(GrabObjectInformation));

        ReleaseObject(info);
        grabObjInfo.collidingObject = go;
        GrabObject(info);
    }
    private GameObject[] GetOrderedParts(ControllerInformation controller)
    {
        WatchInteractionInformation info = (WatchInteractionInformation)controller.GetFunctionalityInfoByType(typeof(WatchInteractionInformation));

        GameObject[] parts = new GameObject[12];
        for (int i = 0; i < parts.Length; i++)
        {
            parts[i] = info.watch.transform.GetChild(0).Find("Part" + (i + 1)).gameObject;
        }
        return(parts);
    }
    public void ShowWatch(ControllerInformation controller)
    {
        WatchInteractionInformation info = (WatchInteractionInformation)controller.GetFunctionalityInfoByType(typeof(WatchInteractionInformation));

        info.watch.SetActive(true);
        updateDisplay(controller);
        //foreach (var item in controllerManager.controllerInfos)
        //{
        //    Debug.Log(item.functionalityInformations.Count);
        //}
    }
    private void TriggerExit(Collider other, VRSensor sensor)
    {
        ControllerInformation info        = controllerManager.GetControllerInfo(sensor.GetComponent <SteamVR_TrackedObject>());
        GrabObjectInformation grabObjInfo = (GrabObjectInformation)info.GetFunctionalityInfoByType(typeof(GrabObjectInformation));

        if (!grabObjInfo.collidingObject)
        {
            return;
        }

        grabObjInfo.collidingObject = null;
    }
Ejemplo n.º 5
0
    protected override void AnyControllerUpdate(ControllerInformation controller)
    {
        ButtonInteractInformation grabObjInfo = (ButtonInteractInformation)controller.GetFunctionalityInfoByType(typeof(ButtonInteractInformation));

        if (controllerManager.GetController(controller.trackedObj).GetHairTriggerDown())
        {
            if (grabObjInfo.buttonInRange != null)
            {
                grabObjInfo.buttonInRange.Interact();
            }
        }
    }
    protected override void AnyControllerUpdate(ControllerInformation controller)
    {
        base.AnyControllerUpdate(controller);
        WatchInteractionInformation info = (WatchInteractionInformation)controller.GetFunctionalityInfoByType(typeof(WatchInteractionInformation));

        if (interactingWith)
        {
            if (controllerManager.GetController(controller.trackedObj).GetPressDown(gripButton))
            {
                StartCoroutine(SwitchSide(controller));
            }
        }
        info.watch.transform.LookAt(head);
    }
Ejemplo n.º 7
0
    private void TriggerExit(Collider other, VRSensor sensor)
    {
        ControllerInformation     controller  = controllerManager.GetControllerInfo(sensor.GetComponent <SteamVR_TrackedObject>());
        ButtonInteractInformation grabObjInfo = (ButtonInteractInformation)controller.GetFunctionalityInfoByType(typeof(ButtonInteractInformation));

        VRButton button = other.GetComponent <VRButton>();

        //we check if it was a button and if it was the one in range
        if (button != null && button == grabObjInfo.buttonInRange)
        {
            grabObjInfo.buttonInRange = null;
            //we get rid of the color again
            button.OnControllerLeave();
        }
    }
Ejemplo n.º 8
0
    private void TriggerStay(Collider other, VRSensor sensor)
    {
        ControllerInformation     controller  = controllerManager.GetControllerInfo(sensor.GetComponent <SteamVR_TrackedObject>());
        ButtonInteractInformation grabObjInfo = (ButtonInteractInformation)controller.GetFunctionalityInfoByType(typeof(ButtonInteractInformation));

        if (grabObjInfo.buttonInRange == null)
        {
            VRButton button = other.GetComponent <VRButton>();
            if (button != null)
            {
                grabObjInfo.buttonInRange = button;
                button.OnControllerEnter();
            }
        }
    }
Ejemplo n.º 9
0
    private void TriggerEnter(Collider other, VRSensor sensor)
    {
        ControllerInformation     controller  = controllerManager.GetControllerInfo(sensor.GetComponent <SteamVR_TrackedObject>());
        ButtonInteractInformation grabObjInfo = (ButtonInteractInformation)controller.GetFunctionalityInfoByType(typeof(ButtonInteractInformation));

        VRButton button = other.GetComponent <VRButton>();

        //we check if it is a button and we are not already interacting with one
        if (button != null && grabObjInfo.buttonInRange == null)
        {
            grabObjInfo.buttonInRange = button;
            //And then we apply color to the button..
            button.OnControllerEnter();
        }
    }
    public GameObject getCorrectPart(int time, ControllerInformation controller)
    {
        WatchInteractionInformation info = (WatchInteractionInformation)controller.GetFunctionalityInfoByType(typeof(WatchInteractionInformation));
        int newTime = time;

        if (newTime > 12)
        {
            newTime -= 12;
        }
        if (info.isWatchOnFront)
        {
            return(info.allParts[newTime - 1]);
        }
        else
        {
            return(info.allParts[12 - newTime]);
        }
    }
    public void SetTime(int newTime, ControllerInformation controller)
    {
        WatchInteractionInformation info = (WatchInteractionInformation)controller.GetFunctionalityInfoByType(typeof(WatchInteractionInformation));

        if (timeScript.Time != newTime)
        {
            float f = timeScript.Time - Mathf.Floor(timeScript.Time);
            timeScript.Time    = newTime + f;
            timeScript.isNight = !info.isWatchOnFront;
            OnTimeChanged(timeScript.Time);

            //notification for tutorial
            if (interactingClock.taskCompleted[2] != null)
            {
                interactingClock.taskCompleted[2].Invoke();
            }
        }
    }
    protected override void AnyControllerUpdate(ControllerInformation controller)
    {
        GrabObjectInformation grabObjInfo = (GrabObjectInformation)controller.GetFunctionalityInfoByType(typeof(GrabObjectInformation));

        if (controllerManager.GetController(controller.trackedObj).GetHairTriggerDown())
        {
            if (grabObjInfo.collidingObject)
            {
                GrabObject(controller);
            }
        }

        if (controllerManager.GetController(controller.trackedObj).GetHairTriggerUp())
        {
            ReleaseObject(controller);
        }

        if (controllerManager.GetController(controller.trackedObj).GetPressDown(SteamVR_Controller.ButtonMask.Grip))
        {
            if (grabObjInfo.objectInHand != null)
            {
                if (grabObjInfo.objectInHand.GetComponent <Lighter>())
                {
                    grabObjInfo.objectInHand.GetComponent <Lighter>().StartFire();
                }
            }
        }

        if (controllerManager.GetController(controller.trackedObj).GetPressUp(SteamVR_Controller.ButtonMask.Grip))
        {
            if (grabObjInfo.objectInHand != null)
            {
                if (grabObjInfo.objectInHand.GetComponent <Lighter>())
                {
                    grabObjInfo.objectInHand.GetComponent <Lighter>().StopFire();
                }
            }
        }
    }
    protected void UpdateDisplay(ControllerInformation controller)
    {
        WatchInteractionInformation info = (WatchInteractionInformation)controller.GetFunctionalityInfoByType(typeof(WatchInteractionInformation));

        if (info != null)
        {
            if (info.watch.activeSelf && vrInteraction.interactingWith == this)
            {
                foreach (var item in info.allParts)
                {
                    ((VRWatchInteraction)vrInteraction).SetPartToNormal(item, controller);
                }
                if (info.isWatchOnFront != timeScript.isNight)
                {
                    if (Mathf.FloorToInt(timeScript.Time) - 1 >= 0 && Mathf.FloorToInt(timeScript.Time) - 1 < info.allParts.Length)
                    {
                        ((VRWatchInteraction)vrInteraction).SetPartToSelected(((VRWatchInteraction)vrInteraction).getCorrectPart(Mathf.FloorToInt(timeScript.Time), controller), controller);
                    }
                }
            }
        }
    }
    public IEnumerator SwitchSide(ControllerInformation controller)
    {
        WatchInteractionInformation info = (WatchInteractionInformation)controller.GetFunctionalityInfoByType(typeof(WatchInteractionInformation));

        if (info.isSwitchingSide)
        {
            yield break;
        }
        updateDisplay(controller);
        info.isWatchOnFront  = !info.isWatchOnFront;
        info.isSwitchingSide = true;
        Transform child     = info.watch.transform.GetChild(0);
        Vector3   oldRot    = child.localRotation.eulerAngles;
        Vector3   targetRot = oldRot;

        targetRot.z += 180;
        while (child.transform.localRotation != Quaternion.Euler(targetRot))
        {
            child.transform.localRotation = Quaternion.RotateTowards(child.transform.localRotation, Quaternion.Euler(targetRot), TurnSpeed);
            yield return(0);
        }
        info.isSwitchingSide = false;
    }
    public void HideWatch(ControllerInformation controller)
    {
        WatchInteractionInformation info = (WatchInteractionInformation)controller.GetFunctionalityInfoByType(typeof(WatchInteractionInformation));

        info.watch.SetActive(false);
    }