Example #1
0
 /// <summary>
 /// Method called in order to spawn a bullet.
 /// Spawns the bullet using the BulletManager pool and rotates and positions it in order to face the corect direction.
 /// Does all the settings needed for the bullet to work using the BulletController's interfaces.
 /// </summary>
 private void SpawnBullet()
 {
     //Debug.Log("Bullet spawned.");
     BulletSpawnManager.BulletTemplate bulletTemp = _bulletSpawnManager.SpawnBullet(out bool couldFire);
     if (couldFire)
     {
         bulletTemp.bulletController.gameObject.SetActive(true);
         GameObject bulletSpawned = bulletTemp.bulletController._bulletGameObject;
         bulletSpawned.transform.position = _spawnPoint.position;
         bulletSpawned.transform.rotation = Quaternion.LookRotation(_spawnPoint.forward, _spawnPoint.up);
         bulletTemp.bulletController.SetBulletSettings(_bullet);
         bulletTemp.bulletController.Launch();
         _audioSrcShooting.Play();
         ++_bulletsFired;
     }
     else
     {
         Debug.Log("COULD NOT FIRE");
     }
 }
Example #2
0
 /// <summary>
 /// Method used by the BulletSpawnManager upon instantiating each bullet.
 /// Used so that each bullet is able to be referenced back to each list in the object pooling without the need to do a manual search.
 /// </summary>
 /// <param name="bulletTemp"></param>
 public void SetBulletTemplate(BulletSpawnManager.BulletTemplate bulletTemp)
 {
     _bulletManagerReference = bulletTemp;
 }