コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            if (!shooting && !shielding)
            {
                attacking = true;
            }
        }

        if (Input.GetButtonDown("Fire2"))
        {
            if (!attacking && !shielding)
            {
                shooting = true;
            }
        }

        if (Input.GetButtonDown("Fire3"))
        {
            if (!shooting && !attacking)
            {
                shielding = true;
            }
        }

        if (Input.GetButtonUp("Fire1"))
        {
            attacking = false;
        }

        if (Input.GetButtonUp("Fire2"))
        {
            shooting = false;
        }

        if (Input.GetButtonUp("Fire3"))
        {
            shielding = false;
        }

        horizontalMovement = Input.GetAxisRaw("Horizontal");
        verticalMovement   = Input.GetAxisRaw("Vertical");

        int nextLock = 0;

        do
        {
            LockControls(controlLock.GetNextLocks(ref nextLock));
        } while (nextLock != 0);
        LockControls(controlLock.GetDefaultLocks());

        if (verticalMovement != 0)
        {
            direction = new Vector2(0, verticalMovement).normalized;
        }
        else if (horizontalMovement != 0)
        {
            direction = new Vector2(horizontalMovement, 0).normalized;
        }
        dsc.SetDirection(direction);

        Attack();

        Shield();

        Shoot();
    }