private void SpawnLaserPickup(int numLasers, string definitionName) { for (var i = 0; i < numLasers; ++i) { PickupFactory.CreateLaserPickup(definitionName); Thread.Sleep(100); } }
public override GameModeStatus Update(GameTime gameTime) { var disposed = GameWorld.GetAll(x => x.PendingDispose); foreach (var d in disposed) { GameWorld.RemoveGameObject(d); } var remainingAliens = GameWorld.GetGameObjects <Alien>(); if (remainingAliens.Count <= 0) { return(GameModeStatus.Success); } if (Player.Hp <= 0) { return(GameModeStatus.Failed); } var remainingWeapons = GameWorld.GetGameObjects <Laser>(); if (remainingWeapons.Count < MaxLasers) { if (FirstFrame) { FirstFrame = false; TimeOfLastWeaponSpawn = gameTime.TotalGameTime; } if (gameTime.TotalGameTime - TimeOfLastWeaponSpawn > WeaponSpawnFrequency) { var rand = new Random((int)gameTime.TotalGameTime.TotalMilliseconds); TimeOfLastWeaponSpawn = gameTime.TotalGameTime; for (var i = 0; i < MaxLasers - remainingWeapons.Count; ++i) { var laserIndex = rand.Next(0, LaserNames.Length); PickupFactory.CreateLaserPickup(LaserNames[laserIndex]); } } } else { TimeOfLastWeaponSpawn = gameTime.TotalGameTime; } Player.Update(gameTime); GameWorld.Update(gameTime); return(GameModeStatus.Continue); }