GetButton() 공개 메소드

public GetButton ( string buttonName ) : bool
buttonName string
리턴 bool
예제 #1
0
    public void ProcessAction(CurrentControls action)
    {
        bool state = _htfInput.GetButton(action.inputName);

        Debug.Log(action.action.ToString() + " :" + _htfInput.GetButton(action.inputName));
        action.state = state;
        if ((int)action.action < 4 && carController != null)
        {
            if (action.action == PlayerActions.Accelerator)
            {
                carController.inputReceiveAccel(state);
            }
            else if (action.action == PlayerActions.Brake)
            {
                carController.inputReceiveBrak(state);
            }
            else if (action.action == PlayerActions.Right)
            {
                carController.inputReceiveRight(state);
            }
            else if (action.action == PlayerActions.Left)
            {
                carController.inputReceiveLeft(state);
            }
        }
        else if (action.action == PlayerActions.Start && state)
        {
            SeedManager.instance.StartGame();
        }
        else if (action.action == PlayerActions.Scream)
        {
            isScreaming = state;
        }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (!recentered)
        {
            // at the start preparing menu
            // (hft controller the first click doesn't respond? why?

            if (m_hftInput.GetButton("fire1"))
            {
                // adjust sword
                //inverseBaseRotation = Camera.main.transform.rotation * Quaternion.Euler(0f, -180f, 0f)
                //    * Quaternion.Inverse(m_hftInput.gyro.attitude);
                inverseBaseRotation = Quaternion.Inverse(m_hftInput.gyro.attitude);

                //baseEulerAngles = m_hftInput.gyro.attitude.eulerAngles;
                sword.rotation = Quaternion.identity;

                //recentered = true;
            }
            else if (m_hftInput.GetButton("fire2"))
            {
                recentered = true;
                parentPlayer.GetComponent <MovablePlayer>().enabled = true;
                EventDelegateManager.instance.restartLevelDelegate();
            }



            // Debug Purpose: start the game without mobile phone

            if (Input.GetKeyUp(KeyCode.Space))
            {
                recentered = true;
                parentPlayer.GetComponent <MovablePlayer>().enabled = true;
                EventDelegateManager.instance.restartLevelDelegate();
            }
        }
        else if (!dead)
        {
            // during the game

            if (m_hftInput.GetButton("fire2"))
            {
                // steering the horse

                if (!steering)
                {
                    // first press
                    // capture current rotation

                    steering             = true;
                    steeringBaseRotation = m_hftInput.gyro.attitude;


                    //rope.SetActive(true);
                }
                else
                {
                    float steer = Mathf.DeltaAngle(steeringBaseRotation.eulerAngles.z, m_hftInput.gyro.attitude.eulerAngles.z);

                    // rotate
                    // movablePlayer.Steer( Mathf.Clamp( steer / 45f, -1f, 1f  ) );

                    // translate
                    movablePlayer.Translate(Mathf.Clamp(steer / 30f, -1f, 1f));
                }



                // movablePlayer.Steer(1.0f);
            }
            else
            {
                steering = false;
                //rope.SetActive(false);
            }
        }
        else
        {
            // at the game over menu

            if (m_hftInput.GetButton("fire1"))
            {
                // restart level
                EventDelegateManager.instance.restartLevelDelegate();

                //dead = false;

                //// reset parent player location
                //parentPlayer.transform.position = startingPosition;

                //parentPlayer.GetComponent<MovablePlayer>().enabled = true;

                //parentPlayer.BroadcastMessage("RestartLevel");

                //GameObject levelManager = GameObject.Find("LevelManager");
                //levelManager.SendMessage("UpdatePosition");
                //levelManager.SendMessage("RestartLevel");
            }
        }

        Quaternion q = m_hftInput.gyro.attitude;

        //sword.rotation = inverseBaseRotation * q;
        sword.rotation = Camera.main.transform.rotation * Quaternion.Euler(0f, -180f, 0f)
                         * inverseBaseRotation * q;


        ikHandler.rotation = sword.rotation;
        sword.position     = hand.position;

        //// rotation
        //if (m_hftInput.GetButtonDown("fire1"))
        //{
        //    // adjust sword
        //    //inverseBaseRotation = Camera.main.transform.rotation * Quaternion.Euler(0f, -180f, 0f)
        //    //    * Quaternion.Inverse(m_hftInput.gyro.attitude);
        //    inverseBaseRotation = Quaternion.Inverse(m_hftInput.gyro.attitude);

        //    //baseEulerAngles = m_hftInput.gyro.attitude.eulerAngles;
        //    sword.rotation = Quaternion.identity;

        //    recentered = true;
        //}
        //else
        //{

        //    Quaternion q = m_hftInput.gyro.attitude;
        //    //sword.rotation = inverseBaseRotation * q;
        //    sword.rotation = Camera.main.transform.rotation * Quaternion.Euler(0f, -180f, 0f)
        //                    * inverseBaseRotation * q;



        //    //Vector3 deltaEulerAngles = q.eulerAngles - baseEulerAngles;

        //    //ikHandler.eulerAngles = q.eulerAngles - baseEulerAngles;

        //    //ikHandler.rotation = inverseBaseRotation * q;
        //    ikHandler.rotation = sword.rotation;
        //}

        //sword.position = hand.position;



        ////float steering = m_hftInput.GetAxis("Horizontal");
        ////if (steering > 0f)
        ////{
        ////    steering = 1.0f;
        ////    movablePlayer.Steer(steering);
        ////}
        ////else if (steering < 0f)
        ////{
        ////    steering = -1.0f;
        ////    movablePlayer.Steer(steering);
        ////}
    }