private void GameWorkFlow() { GameStatusTimer--; if (GameStatusTimer > 0) { return; } GameStatusTimer = 0; switch (GameStatus) { case GameEnum.Stop: break; case GameEnum.Prepare: Player.Visible = true; GameStatus = GameEnum.Play; break; case GameEnum.Play: if (Enemies.EnemiesAlive() == 0) { GameStatus = GameEnum.Next; GameStatusTimer = Constants.PlayerNextTime; } break; case GameEnum.Next: var initScore = Score + (Lives * Constants.RemainingLifeBonus); Initialise(initScore, Lives); break; case GameEnum.Dying: if (Lives > 0) { Player = new Models.Player(Constants.GameAreaWidth / 2, Constants.InitialPlayerYpos); GameStatus = GameEnum.Prepare; GameStatusTimer = Constants.PlayerPrepareTime; } else { GameStatus = GameEnum.Dead; LastKeyPress = default; } break; case GameEnum.Dead: if (LastKeyPress != default) { Initialise(); } break; default: break; } }
private void InitialiseGame(int score = 0, int lives = Constants.InitialPlayerLives) { var random = new Random(); Player = new Models.Player(Constants.GameAreaWidth / 2, Constants.InitialPlayerYpos); Enemies = new Models.Enemies(Constants.EnemiesWide, Constants.EnemiesHigh, Constants.EnemiesXgap, Constants.EnemiesYgap, Constants.GameAreaWidth / 2, Constants.EnemiesBottomYpos, random.Next(50, 100)); Mother = new Models.Mother(Constants.InitialMotherYpos, Lives); //Bunker = new Models.Bunker(Constants.BunkerWidth, Constants.BunkerHeight, Constants.GameAreaWidth/2, 70); Bunkers = new Models.Bunkers(Constants.BunkerCount); Score = score; Lives = lives; GameStatus = GameEnum.Prepare; GameStatusTimer = Constants.PlayerPrepareTime; GameCounter = 0; }