Ejemplo n.º 1
0
//	public LegMover legMover;


    // Update is called once per frame
    void Update()
    {
        if (!getRealUpdater)
        {
            getRealUpdater = getRealCamera.GetComponent <getRealCameraUpdater>();
        }

        if (CAVE2Manager.GetButtonDown(1, CAVE2Manager.Button.Button3))
        {
            bodyMover.SetTrigger();
            hipMover.SetTrigger();
            //hipScaler.ScaleUpperBody();
            bodyScaler.ScaleBody();
            if (ethanTutorial != null)
            {
                Destroy(ethanTutorial);
                CaveChefGameController.GetController().StartGame();
            }
            //legMover.SetTrigger();
        }
        if (CAVE2Manager.GetButtonDown(1, CAVE2Manager.Button.Button2))
        {
            SceneManager.LoadScene(0);
        }
    }
Ejemplo n.º 2
0
    void ProcessButtons(GameObject interactedObject, CAVE2.WandEvent playerInfo)
    {
        foreach (CAVE2.Button currentButton in CAVE2.Button.GetValues(typeof(CAVE2.Button)))
        {
            playerInfo.button = currentButton;

            // OnWandButtonDown
            if (CAVE2Manager.GetButtonDown(wandID, currentButton))
            {
                interactedObject.SendMessage("OnWandButtonDown", playerInfo, SendMessageOptions.DontRequireReceiver);
            }

            // OnWandButton
            else if (CAVE2Manager.GetButton(wandID, currentButton))
            {
                interactedObject.SendMessage("OnWandButton", playerInfo, SendMessageOptions.DontRequireReceiver);
            }

            // OnWandButtonUp
            if (CAVE2Manager.GetButtonUp(wandID, currentButton))
            {
                interactedObject.SendMessage("OnWandButtonUp", playerInfo, SendMessageOptions.DontRequireReceiver);
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        // Shoot a ray from the wand
        Ray        ray = new Ray(transform.position, transform.TransformDirection(Vector3.forward));
        RaycastHit hit;

        // Get the first collider that was hit by the ray
        bool wandHit = Physics.Raycast(ray, out hit, 100, wandLayerMask);

        Debug.DrawLine(ray.origin, hit.point); // Draws a line in the editor

        if (wandHit)                           // The wand is pointed at a collider
        {
            // Send a message to the hit object telling it that the wand is hovering over it
            hit.collider.gameObject.SendMessage("OnWandOver", SendMessageOptions.DontRequireReceiver);

            foreach (CAVE2.Button currentButton in CAVE2.Button.GetValues(typeof(CAVE2.Button)))
            {
                //object[] playerInfo = new object[] { playerID, wandID, currentButton };
                CAVE2.ButtonInfo playerInfo = new CAVE2.ButtonInfo(playerID, wandID, currentButton);

                // OnWandButtonDown
                if (CAVE2Manager.GetButtonDown(wandID, currentButton))
                {
                    hit.collider.gameObject.SendMessage("OnWandButtonDown", playerInfo, SendMessageOptions.DontRequireReceiver);

                    // Legacy Support
                    //hit.collider.gameObject.SendMessage("OnWandButtonDown", currentButton, SendMessageOptions.DontRequireReceiver);
                }

                // OnWandButton
                else if (CAVE2Manager.GetButton(wandID, currentButton))
                {
                    hit.collider.gameObject.SendMessage("OnWandButton", playerInfo, SendMessageOptions.DontRequireReceiver);

                    // Legacy Support
                    //hit.collider.gameObject.SendMessage("OnWandButtonDown", currentButton, SendMessageOptions.DontRequireReceiver);
                }

                // OnWandButtonUp
                if (CAVE2Manager.GetButtonDown(wandID, currentButton))
                {
                    hit.collider.gameObject.SendMessage("OnWandButtonUp", playerInfo, SendMessageOptions.DontRequireReceiver);

                    // Legacy Support
                    //hit.collider.gameObject.SendMessage("OnWandButtonDown", currentButton, SendMessageOptions.DontRequireReceiver);
                }
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        //GetComponent<SphereCollider>().enabled = false; // Disable sphere collider for raycast

        // Shoot a ray from the wand
        Ray        ray = new Ray(transform.position, transform.TransformDirection(Vector3.forward));
        RaycastHit hit;

        // Get the first collider that was hit by the ray
        wandHit = Physics.Raycast(ray, out hit, 100, wandLayerMask);
        Debug.DrawLine(ray.origin, hit.point); // Draws a line in the editor

        if (wandHit)                           // The wand is pointed at a collider
        {
            // Send a message to the hit object telling it that the wand is hovering over it
            hit.collider.gameObject.SendMessage("OnWandOver", SendMessageOptions.DontRequireReceiver);

            overGrabbable = (hit.transform.GetComponent <GrabbableObject>() != null);
            if (CAVE2Manager.GetButtonDown(wandID, grabButton))
            {
                if (hit.transform.GetComponent <GrabbableObject>())
                {
                    hit.collider.gameObject.SendMessage("OnWandGrab", transform, SendMessageOptions.DontRequireReceiver);
                    grabbedObjects.Add(hit.collider.transform);
                }
            }
        }
        else
        {
            overGrabbable = false;
        }

        if (CAVE2Manager.GetButtonUp(wandID, grabButton))
        {
            foreach (Transform t in grabbedObjects)
            {
                if (t != null)
                {
                    t.SendMessage("OnWandGrabRelease", SendMessageOptions.DontRequireReceiver);
                }
            }
            grabbedObjects.Clear();
        }
        //GetComponent<SphereCollider>().enabled = true; // Enable sphere collider after raycast
    }
Ejemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        // Shoot a ray from the wand
        Ray        ray = new Ray(transform.position, transform.TransformDirection(Vector3.forward));
        RaycastHit hit;

        // Get the first collider that was hit by the ray
        wandHit = Physics.Raycast(ray, out hit, 100, wandLayerMask);
        Debug.DrawLine(ray.origin, hit.point); // Draws a line in the editor

        if (wandHit)                           // The wand is pointed at a collider
        {
            if (CAVE2Manager.GetButtonDown(wandID, activateButton))
            {
                Instantiate(blastPrefab, hit.point, Quaternion.identity);
            }
        }

        //GetComponent<SphereCollider>().enabled = true; // Enable sphere collider after raycast
    }
Ejemplo n.º 6
0
 public static bool GetButtonDown(int wandID, CAVE2.Button button)
 {
     return(CAVE2Manager.GetButtonDown(wandID, button));
 }
    // Update is called once per frame
    void Update()
    {
        wandPosition = CAVE2Manager.GetWandPosition(wandID);
        wandRotation = CAVE2Manager.GetWandRotation(wandID);

        headPosition = CAVE2Manager.GetHeadPosition(headID);
        headRotation = CAVE2Manager.GetHeadRotation(headID).eulerAngles;

        if (headPosition.y == 0)
        {
            Debug.LogWarning("OmicronPlayerController: Head is at height (Y) 0.0 - This should never happen! Check your tracking system or enable mocap emulation in CAVE2Manager.");
        }

        if (!freezeMovement)
        {
            forward  = CAVE2Manager.GetAxis(wandID, forwardAxis);
            forward *= movementScale;

            strafe  = CAVE2Manager.GetAxis(wandID, strafeAxis);
            strafe *= movementScale;

            lookAround.x  = CAVE2Manager.GetAxis(wandID, lookUDAxis);
            lookAround.x *= movementScale;
            lookAround.y  = CAVE2Manager.GetAxis(wandID, lookLRAxis);
            lookAround.y *= movementScale;

            vertical  = CAVE2Manager.GetAxis(wandID, verticalAxis);
            vertical *= movementScale;
        }

        freeflyButtonDown = CAVE2Manager.GetButton(wandID, freeFlyButton);

        if (CAVE2Manager.GetButtonDown(wandID, freeFlyToggleButton))
        {
            navMode++;
            if ((int)navMode > 2)
            {
                navMode = 0;
            }

            SetNavigationMode((int)navMode);
        }

        if (CAVE2Manager.GetButtonDown(wandID, autoLevelButton))
        {
            transform.localEulerAngles = new Vector3(0, transform.localEulerAngles.y, 0);
        }

        if (CAVEFloor && !CAVEFloor.activeSelf)
        {
            CAVEFloor.SetActive(true);
        }

        if (CAVEFloor && showCAVEFloorOnlyOnMaster && CAVEFloor.activeSelf && !CAVE2Manager.IsMaster())
        {
            CAVEFloor.SetActive(false);
        }
        else if (CAVEFloor && !showCAVEFloorOnlyOnMaster && !CAVEFloor.activeSelf)
        {
            CAVEFloor.SetActive(true);
        }
    }
Ejemplo n.º 8
0
    // Update is called once per frame
    void Update()
    {
        GetComponent <SphereCollider>().enabled = false; // Disable sphere collider for raycast

        laserActivated = CAVE2Manager.GetButton(wandID, laserButton);
        laser.enabled  = laserActivated;

        // Shoot a ray from the wand
        Ray        ray = new Ray(transform.position, transform.TransformDirection(Vector3.forward));
        RaycastHit hit;

        // Get the first collider that was hit by the ray
        wandHit = Physics.Raycast(ray, out hit, 100, wandLayerMask);
        Debug.DrawLine(ray.origin, hit.point); // Draws a line in the editor

        if (wandHit)                           // The wand is pointed at a collider
        {
            // Send a message to the hit object telling it that the wand is hovering over it
            hit.collider.gameObject.SendMessage("OnWandOver", SendMessageOptions.DontRequireReceiver);

            // If the laser button has just been pressed, tell the hit object
            if (CAVE2Manager.GetButtonDown(wandID, CAVE2Manager.Button.Button3))
            {
                hit.collider.gameObject.SendMessage("OnWandButtonDown", laserButton, SendMessageOptions.DontRequireReceiver);
            }

            // If the laser button has just been pressed, tell the hit object
            if (CAVE2Manager.GetButtonUp(wandID, CAVE2Manager.Button.Button3))
            {
                hit.collider.gameObject.SendMessage("OnWandButtonUp", laserButton, SendMessageOptions.DontRequireReceiver);
            }

            if (CAVE2Manager.GetButtonDown(wandID, CAVE2Manager.Button.Button2))
            {
                hit.collider.gameObject.SendMessage("OnWandButtonDown", CAVE2Manager.Button.Button2, SendMessageOptions.DontRequireReceiver);
            }
            if (CAVE2Manager.GetButtonUp(wandID, CAVE2Manager.Button.Button2))
            {
                hit.collider.gameObject.SendMessage("OnWandGrabRelease", SendMessageOptions.DontRequireReceiver);
            }

            if (CAVE2Manager.GetButton(wandID, CAVE2Manager.Button.Button2))
            {
                hit.collider.gameObject.SendMessage("OnWandButtonHold", CAVE2Manager.Button.Button2, SendMessageOptions.DontRequireReceiver);
            }

            // DPad Click
            if (CAVE2Manager.GetButtonDown(wandID, CAVE2Manager.Button.ButtonUp))
            {
                hit.collider.gameObject.SendMessage("OnWandButtonDown", CAVE2Manager.Button.ButtonUp, SendMessageOptions.DontRequireReceiver);
            }
            if (CAVE2Manager.GetButtonDown(wandID, CAVE2Manager.Button.ButtonDown))
            {
                hit.collider.gameObject.SendMessage("OnWandButtonDown", CAVE2Manager.Button.ButtonDown, SendMessageOptions.DontRequireReceiver);
            }
            if (CAVE2Manager.GetButtonDown(wandID, CAVE2Manager.Button.ButtonLeft))
            {
                hit.collider.gameObject.SendMessage("OnWandButtonDown", CAVE2Manager.Button.ButtonLeft, SendMessageOptions.DontRequireReceiver);
            }
            if (CAVE2Manager.GetButtonDown(wandID, CAVE2Manager.Button.ButtonRight))
            {
                hit.collider.gameObject.SendMessage("OnWandButtonDown", CAVE2Manager.Button.ButtonRight, SendMessageOptions.DontRequireReceiver);
            }

            // DPad Hold
            if (CAVE2Manager.GetButton(wandID, CAVE2Manager.Button.ButtonUp))
            {
                hit.collider.gameObject.SendMessage("OnWandButtonHold", CAVE2Manager.Button.ButtonUp, SendMessageOptions.DontRequireReceiver);
            }
            if (CAVE2Manager.GetButton(wandID, CAVE2Manager.Button.ButtonDown))
            {
                hit.collider.gameObject.SendMessage("OnWandButtonHold", CAVE2Manager.Button.ButtonDown, SendMessageOptions.DontRequireReceiver);
            }
            if (CAVE2Manager.GetButton(wandID, CAVE2Manager.Button.ButtonLeft))
            {
                hit.collider.gameObject.SendMessage("OnWandButtonHold", CAVE2Manager.Button.ButtonLeft, SendMessageOptions.DontRequireReceiver);
            }
            if (CAVE2Manager.GetButton(wandID, CAVE2Manager.Button.ButtonRight))
            {
                hit.collider.gameObject.SendMessage("OnWandButtonHold", CAVE2Manager.Button.ButtonRight, SendMessageOptions.DontRequireReceiver);
            }

            // Laser button is held down
            if (laserActivated)
            {
                // Tell hit object laser button is held down
                hit.collider.gameObject.SendMessage("OnWandButtonHold", laserButton, SendMessageOptions.DontRequireReceiver);

                Debug.DrawLine(ray.origin, hit.point);

                // Set the laser distance at the collision point
                laserDistance = hit.distance;
                laserPosition = hit.point;
            }
            laserDistance = hit.distance;
            laserPosition = hit.point;
        }
        else if (laserActivated)
        {
            // The laser button is pressed, but not pointed at valid target
            // Set laser distance far away
            laserDistance = 1000;
        }

        // Do this on all nodes
        laser.enabled = laserActivated;
        if (laserActivated && drawLaser)
        {
            if (wandHit)
            {
                laserParticle.transform.position = laserPosition;
                laserParticle.Emit(1);
            }
            laser.SetPosition(1, new Vector3(0, 0, laserDistance));
        }
        else if (!drawLaser)
        {
            laser.SetPosition(1, new Vector3(0, 0, 0));
        }
        if (alwaysShowLaserParticle && !laserActivated)
        {
            laserParticle.transform.position = laserPosition;
            laserParticle.Emit(1);
        }
        GetComponent <SphereCollider>().enabled = true; // Enable sphere collider after raycast
    }