public void Initialise() { Instance = this; for (int i = 0; i < _poolCount; i++) { SimpleBullet bullet = Instantiate <SimpleBullet>(_bulletsSO.SimpleBulletPrefab); bullet.gameObject.SetActive(false); _simpleBullets.Push(bullet); } for (int i = 0; i < _poolCount; i++) { RoketBullet bullet = Instantiate <RoketBullet>(_bulletsSO.RoketBulletPrefab); bullet.gameObject.SetActive(false); _roketBullets.Push(bullet); } }
public void Fire() { if (_attackTimer > 0f) { return; } Vector3 direction = transform.forward; // direction = transform.TransformPoint(direction); _attackTimer = _attackDelay; _lastBullet = BulletPool.Instance.GetSimpleBulletOrReturnNullIfPoolEmpty(); // direction = Vector3.ProjectOnPlane(direction - transform.position, Vector3.up); _lastBullet.transform.position = _spawnTransform.position; _lastBullet.Shot(direction); }
public void BackToPool(SimpleBullet bullet) { _simpleBullets.Push(bullet); }