示例#1
0
    void Shoot()
    {
        if (canShoot && Input.GetButtonDown("Fire1") && numberOfBullets[activeBlocks] > 0)
        {
            numberOfBullets[activeBlocks]--;
            Vector2 cursorPos = cursorManager.GetCursorPosition() - new Vector2(transform.position.x, transform.position.y);
            cursorPos.Normalize();

            GameObject projectile = Instantiate(blocks[activeBlocks], shootPoint.transform.position, new Quaternion(0, 0, 0, 0));

            if (!canShoot)
            {
                projectile.GetComponent <Block>().stickAtStart = true;
            }

            projectile.GetComponent <Rigidbody2D>().velocity = cursorPos * blockVelocity;
        }
    }