/// <summary> /// Update all of the bullets held in the list. /// Add the ones that are still alive to a new list. /// </summary> /// <param name="ms">Milliseconds passed since last update</param> public void Update(float ms) { int i = pistolBulletPool.GetFirst(); while (i != -1) { PistolBullet b = pistolBulletPool.GetByIndex(i); b.Update(ms); if (b.MustBeDeleted()) { pistolBulletPool.Dispose(b); } i = pistolBulletPool.NextIndex(b); } i = shotgunBulletPool.GetFirst(); while (i != -1) { ShotgunBullet b = shotgunBulletPool.GetByIndex(i); b.Update(ms); if (b.MustBeDeleted()) { shotgunBulletPool.Dispose(b); } i = shotgunBulletPool.NextIndex(b); } i = assaultBulletPool.GetFirst(); while (i != -1) { AssaultBullet b = assaultBulletPool.GetByIndex(i); b.Update(ms); if (b.MustBeDeleted()) { assaultBulletPool.Dispose(b); } i = assaultBulletPool.NextIndex(b); } i = sniperBulletPool.GetFirst(); while (i != -1) { SniperBullet b = sniperBulletPool.GetByIndex(i); b.Update(ms); if (b.MustBeDeleted()) { sniperBulletPool.Dispose(b); } i = sniperBulletPool.NextIndex(b); } }
public IProjectile CheckHit(BaseAlien alien) { int i = pistolBulletPool.GetFirst(); while (i != -1) { PistolBullet b = pistolBulletPool.GetByIndex(i); if (Collider.Collide(alien.GetBoundRect(), b.GetCenter())) { return(b); } i = pistolBulletPool.NextIndex(b); } i = shotgunBulletPool.GetFirst(); while (i != -1) { ShotgunBullet b = shotgunBulletPool.GetByIndex(i); if (Collider.Collide(alien.GetBoundRect(), b.GetCenter())) { return(b); } i = shotgunBulletPool.NextIndex(b); } i = assaultBulletPool.GetFirst(); while (i != -1) { AssaultBullet b = assaultBulletPool.GetByIndex(i); if (Collider.Collide(alien.GetBoundRect(), b.GetCenter())) { return(b); } i = assaultBulletPool.NextIndex(b); } i = sniperBulletPool.GetFirst(); while (i != -1) { SniperBullet b = sniperBulletPool.GetByIndex(i); if (Collider.Collide(alien.GetBoundRect(), b.GetCenter())) { return(b); } i = sniperBulletPool.NextIndex(b); } return(null); }