public bool DecreaseShips() { this._pausedClock = PausedTimeLong; //any ship left? if (--this.Context.ShipsLeft > 0) { //resume game this._pauseStage = PauseStage.ShipsLeft; return(true); } else { //no more ships: the game is over this._pauseStage = PauseStage.GameOver; return(false); } }
private void RestartLevel() { //init barriers for (int i = 0; i < BarriersCount; i++) { this.Barriers[i].BricksAlive = Barrier.AllBricks; } //init aliens this._aliveAliensCount = AliensPerRow + AliensPerRow; for (int i = 0; i < AliensPerRow; i++) { AlienBase alien = this.LargeAliens[i]; alien.IsAlive = true; alien.Status = AlienStatus.Walk1; alien.XCenter = 4 + i * 5; alien.YCenter = 5; alien = this.SmallAliens[i]; alien.IsAlive = true; alien.Status = AlienStatus.Walk1; alien.XCenter = 4 + i * 5; alien.YCenter = 2; } //reset aliens' speed to the slowest this._clockMask = 0x0F; //do init the remaining parameters this.ResumeLevel(); //shows the current level this._pausedClock = PausedTimeLong; this._pauseStage = PauseStage.ShowLevel; }
public void StateChanged(PauseStage state, Int32 inSpeed, Int32 outSpeed) { }
public void ShowSaucerWorth() { this._pausedClock = PausedTimeShort; this._pauseStage = PauseStage.SaucerHit; }
public override GameStageBase OnCompose(CompositionTargetBase target) { GameStageBase result = null; if (this._pausedClock == 0) { //here is the normal flow during the playable game this.ShiftAliens = (this.Context.Clock & this._clockMask) == 0; //update objects this.Ship.Update(this); this.Missile.Update(this); this.Saucer.Update(this); for (int i = 0; i < AliensPerRow; i++) { this.SmallAliens[i].Update(this); this.LargeAliens[i].Update(this); } for (int i = 0; i < BombsCount; i++) { this.Bombs[i].Update(this); } //check collisions if (this.Ship.DetectCollision(this)) { } if (this.Saucer.DetectCollision(this)) { } for (int i = 0; i < AliensPerRow; i++) { if (this.SmallAliens[i].DetectCollision(this)) { break; } if (this.LargeAliens[i].DetectCollision(this)) { break; } } for (int i = 0; i < BarriersCount; i++) { if (this.Barriers[i].DetectCollision(this)) { break; } } //update context for next frame this.CurrentAlienDir = this.NextAlienDir; if (this.CurrentAlienDir == AlienDirection.GroundReached) { //aliens grounded: the game is over! this._pausedClock = PausedTimeLong; this._pauseStage = PauseStage.GameOver; } } //this happens when some event has paused the game else if (--this._pausedClock == 0) { //finalize the paused stage switch (this._pauseStage) { case PauseStage.ShipsLeft: //resume the game where was broken this.ResumeLevel(); break; case PauseStage.GameOver: //back to the intro stage result = new GameStageIntro(this.Context); this.Context.Status = GameStatus.Registering; break; } this._pauseStage = PauseStage.None; } //render the renderables for (int i = 0; i < RenderableCount; i++) { this._renderables[i].OnRender(target); } //when paused, compose the required stage if (this._pauseStage != PauseStage.None) { this._pauseStageHandlers[(int)this._pauseStage](target); } return(result); }