/// <summary> /// Release a projectile to reuse other time /// </summary> /// <param name="projectile">The projectile</param> public void FreeProjectile(ProjectileController projectile) { if (this.BusyProjectiles.Remove(projectile)) { this.FreeProjectiles.Add(projectile); } }
/// <summary> /// Release a projectile to reuse other time /// </summary> /// <param name="projectile">The projectile</param> public void FreeProjectile(ProjectileController projectile) { if (this.BusyProjectiles.Remove(projectile)) { this.FreeProjectiles.Add(projectile); } }
/// <summary> /// Instantiate projectiles /// </summary> /// <param name="numProjectiles">The num projectiles</param> private void InstantiateProjectiles(int numProjectiles) { for (int i = 0; i < numProjectiles; i++) { ProjectileController projectile = new ProjectileController(); this.FreeProjectiles.Add(projectile); } this.Capacity += numProjectiles; }
/// <summary> /// Get a new free projectile /// </summary> /// <returns>The free projectile</returns> public ProjectileController GetFreeProjectile() { if (this.FreeProjectiles.Count == 0) { this.InstantiateProjectiles(ProjectileCountIncrement); } ProjectileController projectile = this.FreeProjectiles[0]; this.FreeProjectiles.RemoveAt(0); this.BusyProjectiles.Add(projectile); return projectile; }
/// <summary> /// Instantiate projectiles /// </summary> /// <param name="numProjectiles">The num projectiles</param> private void InstantiateProjectiles(int numProjectiles) { for (int i = 0; i < numProjectiles; i++) { ProjectileController projectile = new ProjectileController(); this.FreeProjectiles.Add(projectile); } this.Capacity += numProjectiles; }