// Update is called once per frame
    void Update()
    {
//		Debug.Log("trigger state : " + m_leftWandController.m_triggerState);

        if (m_leftWandController.isReady)
        {
//			Debug.Log ("trigger state : " + m_leftWandController.m_triggerState + " target : " + m_reticlePoser.hitTarget.name);

            if (m_leftWandController.m_triggerState == (int)wandController.m_pressStates.PRESSED && m_reticlePoser.hitTarget.name == "Game Zone Plane")
            {
//				Debug.Log ("teleport");
                transform.position = g_reticleSphere.transform.position;
            }
        }

        m_leftWandController.setContinuousMode();
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        getToolPos();

//		if (m_rightWandController.m_triggerState == (int)wandController.m_pressStates.PRESSED) {
//			Debug.Log ("builder controller : trigger pressed");
//		}

        if (m_rightWandController.isReady)
        {
            switch (g_currentMode)
            {
            //WALL MODE
            case (int)g_modes.WALL:
                if (m_rightWandController.m_padPressState == (int)wandController.m_pressStates.PRESSED)
                {
                    g_isDrawingWall = true;
                    m_wallController.createWall(m_toolPos);
                }

                if (m_rightWandController.m_padPressState == (int)wandController.m_pressStates.PRESSING)
                {
                    m_wallController.drawWall(m_toolPos);
                }


                if (m_rightWandController.m_padPressState == (int)wandController.m_pressStates.UNPRESSED)
                {
                    g_isDrawingWall = false;
                    m_wallController.placeWall();
                }

                if (!g_isDrawingWall)
                {
                    m_wallController.moveWallTool(m_toolPos);
                }
                break;

            //REMOVE MODE
            case (int)g_modes.REMOVE:
                if (m_rightWandController.m_padPressState == (int)wandController.m_pressStates.PRESSING)
                {
                    m_toolController.setIsRemoving(true);
                }

                if (m_rightWandController.m_padPressState == (int)wandController.m_pressStates.UNPRESSED)
                {
                    m_toolController.setIsRemoving(false);
                }
                break;

            //GRAB MODE
            case (int)g_modes.GRAB:
                if (m_rightWandController.m_padPressState == (int)wandController.m_pressStates.PRESSING)
                {
                    m_toolController.setIsGrabbing(true);
                }
                if (m_rightWandController.m_padPressState == (int)wandController.m_pressStates.UNPRESSED)
                {
                    m_toolController.setIsGrabbing(false);

                    if (m_toolController.g_grabbedCube)
                    {
                        m_toolController.dropCube();
                    }
                }

                if (m_toolController.g_grabbedCube)
                {
                    m_toolController.moveGrabbedCube(m_toolPos);
                }
                break;

            //COLOR MODE
            case (int)g_modes.COLOR:
                if (m_rightWandController.m_padPressState == (int)wandController.m_pressStates.PRESSING)
                {
                    m_colorController.setColor(m_rightWandController.m_padAxis.x, m_rightWandController.m_padAxis.y);
                    //Debug.Log ("m_angle : " + Mathf.Rad2Deg * (Mathf.Atan2 (m_rightWandController.m_padAxis.y, m_rightWandController.m_padAxis.x)) + " - " + m_rightWandController.m_padAxis.x + " : " + m_rightWandController.m_padAxis.y);
                    m_colorController.setIsPainting(true);
                }
                if (m_rightWandController.m_padPressState == (int)wandController.m_pressStates.UNPRESSED)
                {
                    m_colorController.setIsPainting(false);
                }
                break;
            }

            if (m_rightWandController.m_gripState == (int)wandController.m_pressStates.PRESSING && gameController.g_currentMode != (int)gameController.modes.PLAY && !startGameCanvasOpen)
            {
                m_zoomController.zoom(1);
            }

            if (m_rightWandController.m_menuState == (int)wandController.m_pressStates.PRESSED)
            {
                //m_gameController.SwitchGameMode ();
                g_rightController.GetComponent <SteamVR_LaserPointer>().enabled     = startGameCanvas.activeSelf;
                g_rightController.GetComponent <Wacki.ViveUILaserPointer>().enabled = !startGameCanvas.activeSelf;
                startGameCanvasOpen = !startGameCanvas.activeSelf;
                startGameCanvas.SetActive(!startGameCanvas.activeSelf);
                setIdleMode();
            }

            if (m_rightWandController.m_padTouchState == (int)wandController.m_touchStates.TOUCHING && m_rightWandController.m_padAxis.y != 0.0f /* && gameController.g_currentMode != (int)gameController.modes.PLAY && !startGameCanvasOpen*/)
            {
                g_currentCubeDistance = ((m_rightWandController.m_padAxis.y + 1.0f) * g_currentCubeDistanceMax - g_currentCubeDistanceMin) / 2.0f + g_currentCubeDistanceMin;
                //			Debug.Log ("distance : " + g_currentCubeDistance + " distanceMax : " + g_currentCubeDistanceMax + " distanceMin : " + g_currentCubeDistanceMin);
            }

            m_rightWandController.setContinuousMode();
        }

        if (m_leftWandController.isReady && !startGameCanvasOpen)
        {
            touchPadAxisY = m_leftWandController.m_padAxis.y;
            touchPadAxisX = m_leftWandController.m_padAxis.x;

            if (m_leftWandController.m_padPressState == (int)wandController.m_pressStates.PRESSED && gameController.g_currentMode != (int)gameController.modes.PLAY)
            {
                if (touchPadAxisY > 0.7f)
                {
                    m_activeToolText.text = "BUILD";
                    setWallMode(true);
                }

                else if (touchPadAxisY < -0.7f)
                {
                    m_activeToolText.text = "REMOVE";
                    setRemoveMode(true);
                }

                if (touchPadAxisX > 0.7f)
                {
                    m_activeToolText.text = "SELECT";
                    setGrabMode(true);
                }

                else if (touchPadAxisX < -0.7f)
                {
                    m_activeToolText.text = "COLOR";
                    setColorMode(true);
                }
            }

            if (m_leftWandController.m_gripState == (int)wandController.m_pressStates.PRESSING && gameController.g_currentMode != (int)gameController.modes.PLAY)
            {
                m_zoomController.zoom(-1);
            }

            if (m_leftWandController.m_menuState == (int)wandController.m_pressStates.PRESSED && gameController.g_currentMode != (int)gameController.modes.PLAY)
            {
                rightCanvas.SetActive(!rightCanvas.activeSelf);
                leftCanvas.SetActive(rightCanvas.activeSelf);
            }

            m_leftWandController.setContinuousMode();
        }
    }