コード例 #1
0
    private void Shoot()
    {
        if (Input.GetKeyDown(KeyCode.Space) && currentShootCooldown <= 0)
        {
            if (numOfBulletShot < numOfBulletChained)
            {
                //NB Added Following Codes Delete or edit if wrong
                audioSrc.Play();

                _animator.SetBool("shooting", true);
                switch (shootType)
                {
                case 0:
                    shoot.BasicShoot(direction);
                    break;

                case 1:
                    shoot.SpreadShoot(direction);
                    break;

                case 2:
                    shoot.BurstShoot(direction);
                    break;
                }

                numOfBulletShot++;
                currentBufferPeriod = maxBufferPeriod;
            }

            if (numOfBulletShot == numOfBulletChained)
            {
                currentShootCooldown = maxShootCooldown;
                currentBufferPeriod  = maxBufferPeriod;
                numOfBulletShot      = 0;
                _animator.SetBool("shooting", false);
            }
        }
        else
        {
            currentShootCooldown -= Time.deltaTime;
        }

        if (numOfBulletShot < numOfBulletChained && currentBufferPeriod <= 0)
        {
            currentBufferPeriod = maxBufferPeriod;
            numOfBulletShot     = 0;
            _animator.SetBool("shooting", false);
        }
        else
        {
            currentBufferPeriod -= Time.deltaTime;
        }
    }