コード例 #1
0
    private void Update()
    {
        if (Input.GetButtonDown("Jump"))
        {
            jump = true;
            animator.SetBool("Jumping", true);
        }

        if (Input.GetButtonDown("Crouch"))
        {
            crouching = true;
        }
        else if (Input.GetButtonUp("Crouch"))
        {
            crouching = false;
        }

        if (Input.GetButtonDown("Shoot") && isGrounded)
        {
            animator.SetBool("Shooting", true);
            shootingController.Shoot();
            Invoke("Wait", 0.5f);
        }

        if (Input.GetButtonDown("BurstShoot") && isGrounded)
        {
            animator.SetBool("Shooting", true);
            shootingController.BurstShoot();
            Invoke("Wait", 1f);
        }
    }
コード例 #2
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;
        }
    }