示例#1
0
        private void SpawnBadBullet()
        {
            if (cooldownShoot > 0)
            {
                return;                                                                                // still on cooldown
            }
            BadBullet p1 = Instantiate(prefabBadBullet, barrel1.transform.position, barrel1.rotation); // instantiates a bullet on each barrel
            BadBullet p2 = Instantiate(prefabBadBullet, barrel2.transform.position, barrel2.rotation);
            BadBullet p3 = Instantiate(prefabBadBullet, barrel3.transform.position, barrel3.rotation);
            BadBullet p4 = Instantiate(prefabBadBullet, barrel4.transform.position, barrel4.rotation);

            p1.InitBullet(barrel1.transform.forward * 10); // launches the bullet on each barrel forward
            p2.InitBullet(barrel2.transform.forward * 10);
            p3.InitBullet(barrel3.transform.forward * 10);
            p4.InitBullet(barrel4.transform.forward * 10);

            cooldownShoot = 1 / roundsPerSecond; // resets the cooldown timer
        }
示例#2
0
        private void ShootPlayer() // Method called when the boss fires its' guns
        {
            if (cooldownShoot > 0)
            {
                return;                          // If weapon on cooldown, return
            }
            if (roundsInClip <= 0)               // If no ammo in clip, reload
            {
                cooldownShoot = 3;               // sets cooldown timer to simulate reloading
                roundsInClip  = roundsInClipMax; // sets roundsInClip back to max
                return;                          // returns to beginning of loop
            }

            #region Bullet Instantiation and Launch Logic
            BadBullet p1 = Instantiate(prefabBadBullet, barrel1.transform.position, barrel1.rotation);
            BadBullet p2 = Instantiate(prefabBadBullet, barrel2.transform.position, barrel2.rotation);
            BadBullet p3 = Instantiate(prefabBadBullet, barrel3.transform.position, barrel3.rotation);
            BadBullet p4 = Instantiate(prefabBadBullet, barrel4.transform.position, barrel4.rotation);
            BadBullet p5 = Instantiate(prefabBadBullet, barrel5.transform.position, barrel5.rotation);
            BadBullet p6 = Instantiate(prefabBadBullet, barrel6.transform.position, barrel6.rotation);
            BadBullet p7 = Instantiate(prefabBadBullet, barrel7.transform.position, barrel7.rotation);
            BadBullet p8 = Instantiate(prefabBadBullet, barrel8.transform.position, barrel8.rotation);

            p1.InitBullet(barrel1.transform.forward * 10);
            p2.InitBullet(barrel2.transform.forward * 10);
            p3.InitBullet(barrel3.transform.forward * 10);
            p4.InitBullet(barrel4.transform.forward * 10);
            p5.InitBullet(barrel5.transform.forward * 10);
            p6.InitBullet(barrel6.transform.forward * 10);
            p7.InitBullet(barrel7.transform.forward * 10);
            p8.InitBullet(barrel8.transform.forward * 10);
            #endregion

            roundsInClip--;                      // Subtracts one bullet from clip after firing
            cooldownShoot = 1 / roundsPerSecond; // restarts weapon cooldown
        }