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);
        }
        // Set isOverlay to true
        public MainMenuState()
            : base(true)
        {
            rand = new Random ();

            components.Add(new Button("New Game", 200, 200));
            components.Add(new Button("Options", 200, 270));

            Button exitButton = new Button("Exit Game", 200, 340);
            exitButton.SetOnClickFunction(() => Environment.Exit(0));
            components.Add(exitButton);

            components.Add(new Button("Secret Button", 200, 410));
        }
        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 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);
        }
        public override GameState UpdateAll(GameTime delta, KeyboardState keyboard, MouseState mouse, RenderEngine renderEngine)
        {
            if (_getInputKey == null)
            {
                return base.UpdateAll(delta, keyboard, mouse, renderEngine);
            }

            foreach (var key in keyboard.GetPressedKeys())
            {
                _playerInput[key] = _getControlKey;
                _getInputKey.setText(key.ToString());
                _getInputKey = null;
                break;
            }

            return this;
        }