public override void Update() { //Check if the wave is destroyed: if (_current.IsEmpty()) { //Spawn new wave DestroyObject(_current); _current = (Wave)CreateAndReturnObject(typeof(Wave), _mainPosition); //Reset barrier blocks foreach (var obj in ObjectManager.Objects.Where(obj => obj.GetType() == typeof(Block))) //Destroy old ones { DestroyObject(obj); } BlockMaker.MakeANewSetOfBlocks(); //Level up the invasion for (int i = 0; i < _waveCounter; i++) { _current.LevelUp(); } } //Check for a game over: if (_current.GetInvadersRectangle().Bottom >= _gameOverLine) { //If game is indeed over than destroy everything and make a game over sign at the middle of the screen ObjectManager.Clear(); int screenWidth = SpaceInvaders.Device.Viewport.Width; int screenHeight = SpaceInvaders.Device.Viewport.Height; CreateObject(typeof(GameOverSign), new Vector2(screenWidth / 2, screenHeight / 2)); } }
public override void Create(GameObject createdObject) { if (createdObject == this) { _mainPosition = Sprite.Position; _current = (Wave)CreateAndReturnObject(typeof(Wave), _mainPosition); } }