public GameObject GetSonar(float speed, float scale) { IPoolable s = AllocateEntity(sonarPrefab); if (s == null) { return(null); } s.GetGameObject().GetComponent <Sonar>().SetGrowth(speed, scale); return(s.GetGameObject()); }
/// <summary> Retrieve a bullet from a pool. </summary> /// <param name="type"> The type of bullet to get. </param> /// <returns> The gameObject of the bullet or null if there are none available. </returns> public GameObject GetProjectile(ProjectileTypes type) { IPoolable entity = AllocateEntity(this.projectilePools[(int)type]); if (entity == null) { return(null); } if (type == ProjectileTypes.Enemy) { SoundPool.instance.PlaySound(SoundClips.instance.Laser2, entity.GetGameObject().transform.position, false, false, 0.25f); } else if (type == ProjectileTypes.Player) { SoundPool.instance.PlaySound(SoundClips.instance.PlayerLaser, transform.position, false, false, 0.1f); } return(entity.GetGameObject()); }
private GameObject GetPart(IPoolable templet) { IPoolable entity = AllocateEntity(templet); if (entity == null) { return(null); } return(entity.GetGameObject()); }
public GameObject GetBullet(BulletTypes type) { IPoolable entity = AllocateEntity(bulletPools[(int)type]); if (entity == null) { return(null); } return(entity.GetGameObject()); }
public GameObject GetEnemy(Enums.EnemyTypes type) { IPoolable entity = AllocateEntity(enemyPools[(int)type]); if (entity == null) { return(null); } return(entity.GetGameObject()); }
public GameObject GetTrap(Enums.Traps type) { IPoolable entity = AllocateEntity(trapPools[(int)type]); if (entity == null) { return(null); } return(entity.GetGameObject()); }
public void ReleaseGameObject(IPoolable poolable) { var type = poolable.GetType(); _stacksByType.TryGetValue(type, out var poolStack); if (poolStack == null) { poolStack = new Stack <IPoolable>(); _stacksByType.Add(type, poolStack); } poolable.OnRelease(); var go = poolable.GetGameObject(); go.transform.SetParent(_poolTransform); go.SetActive(false); poolStack.Push(poolable); }