GetButtonDown() public method

public GetButtonDown ( string buttonName ) : bool
buttonName string
return bool
示例#1
0
    void OnTriggerStay2D(Collider2D col)
    {
        if (col.gameObject.tag == "Door" && gameObject.GetComponent <Player>().team == 1)
        {
            if (m_hftInput.GetButtonDown("fire1") || Input.GetKeyDown("space"))
            {
                Debug.Log("Trying open the door");
                if (isKey)
                {
                    col.gameObject.GetComponent <DoorScript>().OpenDoor();
                    isKey = false;
                }
            }
        }

        if (col.gameObject.tag == "Door" && gameObject.GetComponent <Player>().team == 0)
        {
            if (m_hftInput.GetButtonDown("fire1") || Input.GetKeyDown("space"))
            {
                Debug.Log("Trying close the door");
                if (isKey)
                {
                    col.gameObject.GetComponent <DoorScript>().CloseDoor();
                    isKey = false;
                }
            }
        }
    }
示例#2
0
 void PostMeme()
 {
     if (amIBanned != true)
     {
         if (myHFTInput.GetButtonDown("Fire1"))
         {
             playerScore++;
             managerScriptReference.ScrollMessages();
             GameObject        memeMessage   = Instantiate(memeMessagePrefab) as GameObject;
             MemeMessageScript messageScript = memeMessage.GetComponent <MemeMessageScript>();
             messageScript.MemeConstructor(playerName, playerProfilePicture, managerScriptReference.memePictures[Random.Range(0, managerScriptReference.memePictures.Length)], this, playerColor);
             m_soundPlayer.PlaySound("Post Sound");
             CheckIfIShouldBeBanned();
         }
     }
 }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        // 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;
        }
        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;
    }
    void Update()
    {
        bool jumpJustPressed = m_hftInput.GetButtonDown("fire1") || Input.GetKeyDown("space");

        // If we're on the ground AND we just pressed jump (or space)
        if (m_grounded && jumpJustPressed)
        {
            m_grounded = false;
            m_animator.SetBool("Ground", m_grounded);
            // m_rigidbody2d.AddForce(new Vector2(0, jumpForce));
        }
    }
示例#5
0
    // Update is called once per frame
    void Update()
    {
        // rotation
        if (m_hftInput.GetButtonDown("fire1"))
        {
            // adjust sword

            float baseY = m_hftInput.gyro.attitude.eulerAngles.y;
            //baseRotation = Quaternion.Euler(0, baseY, 0);

            //inverseBaseRotation = Quaternion.Euler(0, -baseY, 0);
            inverseBaseRotation = Quaternion.Inverse(m_hftInput.gyro.attitude);


            //lastRotation = Quaternion.Euler(0, baseY, 0);
            lastRotation       = m_hftInput.gyro.attitude;
            transform.rotation = Quaternion.identity;
            //transform.rotation = m_hftInput.gyro.attitude;
            //Debug.Log("set swrod base position from EulerY=" + baseY);
        }
        else
        {
            //Quaternion q = Quaternion.Slerp(transform.rotation, m_hftInput.gyro.attitude, rotationSpeed * Time.deltaTime);
            //transform.rotation = q;


            //Quaternion q = Quaternion.Slerp(lastRotation, m_hftInput.gyro.attitude, rotationSpeed * Time.deltaTime);
            Quaternion q = m_hftInput.gyro.attitude;
            lastRotation = m_hftInput.gyro.attitude;
            //transform.rotation = q * inverseBaseRotation;
            transform.rotation = inverseBaseRotation * q;
        }



        // translate

        //if ( m_hftInput.gyro.userAcceleration.x > moveThreshold )

        //if ( m_hftInput.acceleration.x > moveThreshold )
        //{
        //    transform.Translate( new Vector3(m_hftInput.acceleration.x * 0.01f, 0f, 0f) );
        //}


        //m_hftInput.gyro.userAcceleration.z

        //transform.Translate(Vector3.up * Time.deltaTime * speed);
    }
示例#6
0
    // Update is called once per frame
    void Update()
    {
        // can move
        if (canMove)
        {
            RotatePlayer();
        }

        // no hold fire
        // if (!canHoldFire && Input.GetKeyDown(KeyCode.Space) && canMove)
        if (!canHoldFire && hInput.GetButtonDown("fire1") && canMove)
        {
            if (attackTimer > attackRate)
            {
                attackTimer = 0.0f;
                Shoot();
            }
        }

        // can hold fire

        attackTimer += Time.deltaTime;
    }
示例#7
0
    // Update is called once per frame
    void Update()
    {
        // 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);

            hand.localRotation = Quaternion.identity;
            sword.rotation     = Quaternion.identity;
        }
        else
        {
            Quaternion q = m_hftInput.gyro.attitude;
            //sword.rotation = inverseBaseRotation * q;
            Quaternion r = Camera.main.transform.rotation * Quaternion.Euler(0f, -180f, 0f)
                           * inverseBaseRotation * q;

            sword.rotation = r;

            ikHandler.rotation = r;

            sword.position = handSwordPlaceHolder.position;
            //hand.rotation = swordPreQ * r;


            //hand.rotation = handBaseRotation * r;
            //hand.rotation = r;

            //handJoint.rotation = r;
            //handJoint.localRotation = Quaternion.Euler(-90f, 180f, 0f) * r;


            //GetComponent<Animator>().settar



            // set hand joint position
            // rotations are all in world space

            //handJoint.rotation = handJoint.rotation
            //   * Quaternion.FromToRotation(handJointUp.position - handSwordPlaceHolder.position, swordEnd.position - sword.position);

            //handJoint.rotation = handJoint.rotation
            //   * Quaternion.FromToRotation(handSwordPlaceHolder.forward, sword.up);

            //handJoint.rotation = handJoint.rotation
            //   * Quaternion.FromToRotation(debugController.up, sword.up);
            //hand.rotation = debugController.rotation;
            //hand.localRotation = Quaternion.Inverse( handJoint.parent.rotation ) * Quaternion.FromToRotation(handSwordPlaceHolder.forward, sword.up);

            //hand.localRotation = Quaternion.Euler(0f, 0f, 0f);
            //hand.localRotation = debugController.rotation;
            hand.localRotation = debugController.rotation * r;

            //hand.rotation = Quaternion.identity;

            //handJoint.localRotation = Quaternion.identity;
        }
    }