Ejemplo n.º 1
0
        private void UpdateEvolve(KeyboardState keyboardState)
        {
            //if any players are alive then update them
            _population.UpdateActive();

            var newState = Level.Update(keyboardState, _previousKeyboardState);

            if (newState == GameState.Title)
            {
                if (Level.IsDone())
                {
                    //game over for this player..
                    var activePlayer = _population.ActivePlayer();
                    activePlayer.Score = _score.CurrentScore;

                    //select the next in line to try
                    if (!_population.SelectNextPlayer())
                    {
                        //all the players have played their last upon the stage of life,
                        // score each and perform a selection of the fitest players to pass
                        // their genetic material to the next gen.
                        _population.NaturalSelection();
                        //reset the score and let this next gen play
                        _score.Reset();
                        Level.StartGame();
                    }
                    else
                    {
                        //reset the score and let this next gen play
                        _score.Reset();
                        Level.ReStartGame();
                    }
                }
                else
                {
                    //game evolution exited
                    _gameState = GameState.Title;
                    //transition to title
                    _score.CancelGame();
                    _currTitle.Reset();
                }
            }
        }