private void setGameState(GameState i_GameState, SpaceInvadersSettings i_SpaceInvadersSettings) { if (i_GameState == null) { m_GameSettings.ResetLevel(); m_GameState = new GameState(i_SpaceInvadersSettings.NumberOfPlayers > 0, i_SpaceInvadersSettings.NumberOfPlayers > 1); m_GameState.ScoreManagers = new List <ScoreManager>(); if (m_GameState.Player1Active) { m_GameState.ScoreManagers.Add(new ScoreManager("Player 1", this.Game, this) { TintColor = Color.Blue }); } if (m_GameState.Player2Active) { m_GameState.ScoreManagers.Add(new ScoreManager("Player 2", this.Game, this) { TintColor = Color.Green }); } } else { m_GameState = i_GameState; m_GameState.AddItemsToScreen(this); } }
public PlayScreen(Game i_Game, GameState i_GameState = null) : base(i_Game) { Background background = new Background(this.Game, this); m_GameSettings = (this.Game.Services.GetService(typeof(IGameSettings)) as SpaceInvadersSettings); if (m_GameSettings == null) { m_GameSettings = new SpaceInvadersSettings(this.Game); } setGameState(i_GameState, m_GameSettings); createPlayersAndScoreManagers(); m_Enemies = new EnemiesGroup(this.Game, this); m_Barriers = new Barriers(this.Game, this); m_MotherSpaceship = new MotherShip(this.Game, this); m_MotherShipRandomNotifier = new RandomActionComponent(); m_MotherShipRandomNotifier.RandomTimeAchieved += motherShipRandomNotifier_GoMotherSpaceship; }