public MenuState(Game1 game) : base(game) { _startButttonTexture = Globals.ContentLoader.Load <Texture2D>("Buttons/Start_BTN"); _endButttonTexture = Globals.ContentLoader.Load <Texture2D>("Buttons/Exit_BTN"); #region StartGameButton _newGameButton = new RegularButton(_startButttonTexture, new Vector2(Globals.WindowWidth / 2 - _startButttonTexture.Width / 2, Globals.WindowHeight / 2 - _startButttonTexture.Height)) { }; _newGameButton.Click += NewGameButton_Click; #endregion #region ExitButton _exitButton = new RegularButton(_endButttonTexture, new Vector2(Globals.WindowWidth / 2 - _endButttonTexture.Width / 2, Globals.WindowHeight / 2 + _endButttonTexture.Height / 2)) { }; _exitButton.Click += ExitButton_Click; #endregion #region SoundButton _soundButton = new SoundButton() { }; _soundButton.Click += _soundButton_Click; #endregion Components = new List <IComponent>() { _newGameButton, _exitButton, _soundButton }; Globals.MusicPlayer.PlaySong(Globals.MainTheme); }
public EndState(Game1 _game) : base(_game) { #region Load Content Texture2D _restartBtnTexture = Globals.ContentLoader.Load <Texture2D>("Buttons/Replay_BTN"); Texture2D _exitBtnTexture = Globals.ContentLoader.Load <Texture2D>("Buttons/Close_BTN"); Texture2D _headerTexture = Globals.ContentLoader.Load <Texture2D>("Headers/WonHeader"); #endregion #region Create buttons & header button _reStartBtn = new RegularButton(_restartBtnTexture, new Vector2(Globals.WindowWidth / 3 - _restartBtnTexture.Width / 2, Globals.WindowHeight / 3 + _restartBtnTexture.Height / 2)) { }; _reStartBtn.Click += _reStartBtn_Click; button _exitBtn = new RegularButton(_exitBtnTexture, new Vector2(Globals.WindowWidth / 3 * 2 - _exitBtnTexture.Width / 2, Globals.WindowHeight / 3 + _exitBtnTexture.Height / 2)) { }; _exitBtn.Click += _exitBtn_Click; Header _deathHeader = new Header(_headerTexture) { Position = new Vector2(Globals.WindowWidth / 2 - _headerTexture.Width / 2, Globals.WindowHeight / 6 + _headerTexture.Height / 2), }; #endregion #region Add buttons to the list Components = new List <IComponent>() { _reStartBtn, _exitBtn, _deathHeader, }; #endregion }
public VictoryState(Game1 _game, int _CollectedItems) : base(_game) { #region Load Content Texture2D _nextLevelBtnTexture = Globals.ContentLoader.Load <Texture2D>("Buttons/Play_BTN"); Texture2D _exitBtnTexture = Globals.ContentLoader.Load <Texture2D>("Buttons/Close_BTN"); Texture2D _replayBtnTexture = Globals.ContentLoader.Load <Texture2D>("Buttons/Replay_BTN"); Texture2D _headerTexture = Globals.ContentLoader.Load <Texture2D>("Headers/WonHeader"); Texture2D _emptyStarTexture = Globals.ContentLoader.Load <Texture2D>("Score/Star_empty"); Texture2D _goldStarTexture = Globals.ContentLoader.Load <Texture2D>("Score/Star_filled"); #endregion #region Assing value to the fields _positionStars = (int)(Globals.WindowHeight * (1.0 / 4)) - _emptyStarTexture.Height / 2 + 10; _positionBtns = (int)(Globals.WindowHeight * (3.0 / 4)) - _nextLevelBtnTexture.Height / 2 + 50; #endregion #region Create Compontents #region Buttons #region Replay button button _replayLevelBtn = new RegularButton(_replayBtnTexture, new Vector2((int)(Globals.WindowWidth * (1.5 / 6)) - _replayBtnTexture.Width / 2, _positionBtns)) { }; _replayLevelBtn.Click += _replayLevelBtn_Click; #endregion #region Next level button button _nextLevelBtn = new RegularButton(_nextLevelBtnTexture, new Vector2((int)(Globals.WindowWidth * (3.0 / 6)) - _nextLevelBtnTexture.Width / 2, _positionBtns)) { }; _nextLevelBtn.Click += _nextLevelBtn_Click; #endregion #region Exit button button _exitBtn = new RegularButton(_exitBtnTexture, new Vector2((int)(Globals.WindowWidth * (4.5 / 6)) - _nextLevelBtnTexture.Width / 2, _positionBtns)) { }; _exitBtn.Click += _exitBtn_Click; #endregion #region Sound button button _soundBtn = new SoundButton(new Vector2(25, 25)); _soundBtn.Click += _soundBtn_Click; #endregion #endregion #region Header Header _victoryHeader = new Header(_headerTexture) { Position = new Vector2(Globals.WindowWidth / 2 - _headerTexture.Width / 2, Globals.WindowHeight / 2 - _headerTexture.Height / 2 + 50), }; #endregion #region Score Star _firstStar = new Star(_emptyStarTexture) { Position = new Vector2((int)(Globals.WindowWidth / 1.2 - _emptyStarTexture.Width / 2 - 50), _positionStars), }; Star _secondStar = new Star(_emptyStarTexture) { Position = new Vector2(Globals.WindowWidth / 2 - _emptyStarTexture.Width / 2, _positionStars - 50), }; Star _thirdStar = new Star(_emptyStarTexture) { Position = new Vector2(Globals.WindowWidth / 6 - _emptyStarTexture.Width / 2 + 50, _positionStars), }; #endregion #endregion #region Add components to the list Components = new List <IComponent>() { _replayLevelBtn, _nextLevelBtn, _exitBtn, _victoryHeader, _secondStar, _thirdStar, _firstStar, _soundBtn, }; int i = 1; //Show number of collected stars foreach (IComponent _component in Components) { if (_component is Star && i <= _CollectedItems) { Star _star = _component as Star; _star.StarTexture = _goldStarTexture; i++; } } #endregion }