public OptionsState() { Button changeScreenSize = new Button("Max Particles: " + ParticleEngine.MaxParticles, 300, 200, 250, 50, Keys.S); changeScreenSize.SetOnClickFunction(() => { ParticleEngine.MaxParticles += 128; if (ParticleEngine.MaxParticles > 2512) ParticleEngine.MaxParticles = 256; changeScreenSize.setText("Max Particles: " + ParticleEngine.MaxParticles); }); components.Add(changeScreenSize); Button difficulityButton = new Button("Difficulity: " + difficulity.ToString(), 300, 270, 250, 50, Keys.S); difficulityButton.SetOnClickFunction(() => { switch (difficulity) { case Difficulity.IRONMAN: difficulity = Difficulity.SISSY; break; case Difficulity.SISSY: difficulity = Difficulity.REGULAR; break; case Difficulity.REGULAR: difficulity = Difficulity.IRONMAN; break; } difficulityButton.setText("Difficulity: " + difficulity.ToString()); }); components.Add(difficulityButton); Button exitButtion = new Button("Exit", 300, 340, 250, 50, Keys.Escape); exitButtion.SetOnClickFunction(() => NextGameState = null); components.Add(exitButtion); Label stateLabel = new Label("==OPTIONS==", 360, 100); components.Add(stateLabel); }
public MainMenuState() { Button newGameButton = new Button("Start Game", 300, 200, 150, 50, Keys.N); newGameButton.SetOnClickFunction(() => NextGameState = new SelectGameModeScreen()); Button optionsButton = new Button("Options", 300, 270, 150, 50, Keys.O); optionsButton.SetOnClickFunction(() => NextGameState = new OptionsState()); Button exitButton = new Button("Exit Game", 300, 340, 150, 50, Keys.Escape); exitButton.SetOnClickFunction(() => NextGameState = null); Label stateLabel = new Label("==MAIN MENU==", 300, 100); components.Add(newGameButton); components.Add(optionsButton); components.Add(exitButton); components.Add(stateLabel); }
public PlayingState(List<Player> playerList, bool versusMode) { //Initialize level _entities = new List<Entity>(64); _tileMap = new TileMap(24, 24); _versusMode = versusMode; //Initialize players _entities.AddRange(playerList); _playerList = playerList; //Place players somewher safe foreach (Player player in playerList) { player.Position = GetRandomSpawnPosition(); } //Reset particles ParticleEngine.Clear(); Camera.WorldRectangle = new Rectangle(0, 0, _tileMap.RealWidth, _tileMap.RealHeight); //Player 1 GUI Label player1Name = new Label(_playerList[0].Name, 200, 5); components.Add(player1Name); _player1Score = new Label("SCORE: 0", 200, 32); components.Add(_player1Score); //Player 2 GUI if (_playerList.Count > 1) { Label player2Name = new Label(_playerList[1].Name, 500, 5); components.Add(player2Name); _player2Score = new Label("SCORE: 0", 500, 32); components.Add(_player2Score); } }
public SelectPlayerState(int numberOfplayers, bool versus, List<Player> playerList = null) { //First player? if (playerList == null) playerList = new List<Player>(); //Load all playable tanks _playableUnits.AddRange(ResourceManager.GetAllUnitTypes().Where(unit => unit.GetValue<bool>(UnitValues.IsPlayable))); _unitType = _playableUnits[0]; int x = 50; int y = 50; Label player1Label = new Label("=PLAYER " + (playerList.Count + 1) + "=", x, y); components.Add(player1Label); x = 400; y += 32; components.Add(new Label("Name: ", x, y)); //Player name InputField player1Name = new InputField("Player " + (playerList.Count + 1), x + 100, y, 150, 32); components.Add(player1Name); y += 100; //Unit Type Label unitType = new Label("Unit Type", x, y); components.Add(unitType); y += 150; x += 50; Button previousType = new Button("<-", x, y, 32, 32); previousType.SetOnClickFunction(() => { int index = _playableUnits.IndexOf(_unitType) - 1; if (index < 0) index = _playableUnits.Count-1; _unitType = _playableUnits[index]; }); components.Add(previousType); Button nextType = new Button("->", x + 50, y, 32, 32); nextType.SetOnClickFunction(() => { int index = _playableUnits.IndexOf(_unitType) + 1; if (index >= _playableUnits.Count) index = 0; _unitType = _playableUnits[index]; }); components.Add(nextType); //Load default controls x = 50; y = 82; if (playerList.Count == 0) { _playerInput[Keys.RightShift] = Player.Controllers.Secondary; _playerInput[Keys.RightControl] = Player.Controllers.Primary; _playerInput[Keys.Right] = Player.Controllers.Right; _playerInput[Keys.Up] = Player.Controllers.Forward; _playerInput[Keys.Down] = Player.Controllers.Back; _playerInput[Keys.Left] = Player.Controllers.Left; } else { _playerInput[Keys.LeftShift] = Player.Controllers.Secondary; _playerInput[Keys.LeftControl] = Player.Controllers.Primary; _playerInput[Keys.D] = Player.Controllers.Right; _playerInput[Keys.W] = Player.Controllers.Forward; _playerInput[Keys.S] = Player.Controllers.Back; _playerInput[Keys.A] = Player.Controllers.Left; } foreach (var input in _playerInput) { Keys key = input.Key; Player.Controllers controller = input.Value; y += 32; Label inputMap = new Label(controller.ToString() + ":", x, y); components.Add(inputMap); Button keyMap = new Button(key.ToString(), x + 150, y, 150, 32); keyMap.SetOnClickFunction(() => { keyMap.setText("..."); _getControlKey = controller; _getInputKey = keyMap; _playerInput.Remove(key); }); components.Add(keyMap); } //Buttons to start game or go back to main menu Button newGameButton = new Button("Start!", 550, 400); newGameButton.SetOnClickFunction(() => { playerList.Add(new Player(player1Name.Text, _unitType, _playerInput)); if(versus) playerList.Last().Team += (char)playerList.Count; if (playerList.Count < numberOfplayers) { NextGameState = new SelectPlayerState(numberOfplayers, versus, playerList); } else { NextGameState = new PlayingState(playerList, versus); DestroyCurrentState(); } }); components.Add(newGameButton); Button backButton = new Button("Back", 50, 400, 150, 50, Keys.Escape); backButton.SetOnClickFunction(() => { NextGameState = null; }); components.Add(backButton); }