public void Spawn(Vector3 origin, Vector3 direction) { GameObject bulletObject = _pool.Spawn(origin, Quaternion.identity); BulletBase bullet = bulletObject.GetComponent <BulletBase>(); bullet.Fire(direction, _pool); }
public void FireBullet(GameStatics.BULLET_TYPE bulletType, Vector3 startWorldPos, float radius, float speed, float acceleration, Vector3 direction) { if (bulletPool == null) { return; } if (bulletPool.ContainsKey(bulletType)) { bool poolLimitOver = true; foreach (GameObject go in bulletPool[bulletType]) { if (go.activeSelf == false) { go.transform.position = startWorldPos; go.SetActive(true); BulletBase bullet = go.GetComponent <BulletBase>(); bullet.Fire(bulletType, radius, speed, acceleration, direction); poolLimitOver = false; break; } } if (poolLimitOver == true) { GameObject newGo = CreateNewBullet(bulletType); newGo.transform.parent = bulletRoot.transform; newGo.transform.position = startWorldPos; newGo.SetActive(true); BulletBase bullet = newGo.GetComponent <BulletBase>(); bullet.Fire(bulletType, radius, speed, acceleration, direction); bulletPool[bulletType].Add(newGo); } } }