コード例 #1
0
    private void Update()
    {
        // Read the inputs
        h = Input.GetAxis("Horizontal");
        v = Input.GetAxis("Vertical");
        bool  ability1    = Input.GetButtonDown("Fire1");
        bool  ability1Rel = Input.GetButtonUp("Fire1");
        bool  ability2    = Input.GetButtonDown("Fire2");
        bool  ability2Rel = Input.GetButtonUp("Fire2");
        bool  unstun      = Input.GetButtonDown("Jump");
        float a3          = Input.GetAxis("Fire3");

        Vector3 mousePosition = Input.mousePosition;

        mousePosition = Camera.main.ScreenToWorldPoint(mousePosition);

        // disable movement and abilities if we're dead
        if (!basePlayer.IsDead)
        {
            // Pass all parameters to the character control script
            m_Character.FaceMouse(mousePosition);

            if (unstun)
            {
                m_Character.m_Rigidbody2D.velocity = new Vector2();
                m_Character.Unstun();
                m_Character.isEnabled = true;
            }

            // use abilities
            if (ability1)
            {
                m_Character.AbilityPressed("Fire1");
            }
            if (ability2)
            {
                m_Character.AbilityPressed("Fire2");
            }

            if (ability1Rel)
            {
                m_Character.AbilityReleased("Fire1");
            }
        }
    }