Esempio n. 1
0
        public PlayerState(Golf game, PlayerSelectArena startState, List <Player> players, List <int> colors)
            : base(game, startState)
        {
            //game.KeyboardInput.IsOSKVisable = true;
            PlayerSelectArena = startState;
            _players          = players;
            _colors           = colors;
            if (_players.Count == 0)
            {
                AddNewPlayer();
            }

            _startNextItem = new MenuItem(game,
                                          Fonts.GameFont.MeasureString(new Vector2(10, 100),
                                                                       ((players.Count == Game.GameSettings.Players)
                                     ? Strings.Start : Strings.Next)),
                                          ((players.Count == Game.GameSettings.Players)
                                     ? Strings.Start : Strings.Next));
            _nameItem = new NameMenuItem(game, Fonts.GameFont.MeasureString(
                                             new Vector2(10, 10 + _startNextItem.Bounds.Y + _startNextItem.Bounds.Height),
                                             _player.Name),
                                         () => _player.Name,
                                         p => { _player.Name = p; }, () => _player.ColorIndex, Strings.Name);
            int       max    = 0;
            int       mindex = 0;
            Rectangle m      = new Rectangle();

            for (var index = 0; index < colors.Count; index++)
            {
                var color = colors[index];
                m = Fonts.GameFont.MeasureString(
                    new Vector2(10, _nameItem.Bounds.Y + _nameItem.Bounds.Height),
                    GameColors.Colors[color].Name.ToUpperInvariant());
                if (m.Width > max)
                {
                    max    = m.Width;
                    mindex = index;
                }
            }
            _colorItem = new ColorMenuItem(game,
                                           new Rectangle(10, _nameItem.Bounds.Y + _nameItem.Bounds.Height + 10,
                                                         m.Width, m.Height), () => _player.ColorIndex,
                                           delegate(int p) { _player.ColorIndex = p; }, Strings.Color, colors);
            _backItem = new MenuItem(game,
                                     Fonts.GameFont.MeasureString(
                                         new Vector2(10, 10 + _colorItem.Bounds.Y + _colorItem.Bounds.Height),
                                         Strings.Back), Strings.Back);
            _menu = new Menu(game, HandleMenuSelect,
                             _startNextItem,
                             _nameItem,
                             _colorItem,
                             _backItem
                             );
            _invalidName = new Tween(new TimeSpan(0, 0, 0, 1), 1, 0);
            _invalidName.Finish();
        }
Esempio n. 2
0
        public PlayerState(BaseGame game, StartState startState, List <Player> players, List <int> colors)
            : base(game, startState)
        {
            //game.KeyboardInput.IsOSKVisable = true;
            _startState = startState;
            _players    = players;
            _colors     = colors;
            _player     = new Player
            {
                Color = colors[0],
                Name  = game.GameData.Data.PlayerNames[players.Count],
                Score = 0,
                Type  = players.Count == 0 ? PlayerType.Human : PlayerType.Computer
            };
            _startNextItem = new MenuItem(game,
                                          game.Font.MeasureString(new Vector2(10, 100),
                                                                  ((players.Count == startState.GameType.Players - 1)
                                     ? Strings.Start : Strings.Next)),
                                          ((players.Count == startState.GameType.Players - 1)
                                     ? Strings.Start : Strings.Next));
            _nameItem = new NameMenuItem(game, game.Font.MeasureString(
                                             new Vector2(10, _startNextItem.Bounds.Y + _startNextItem.Bounds.Height),
                                             _player.Name),
                                         () => _player.Name,
                                         p => { _player.Name = p; }, () => _player.Color, Strings.Name);
            int max    = 0;
            int mindex = 0;

            for (var index = 0; index < colors.Count; index++)
            {
                var color = colors[index];
                var m     = game.Font.MeasureString(
                    new Vector2(10, _nameItem.Bounds.Y + _nameItem.Bounds.Height),
                    GameColors.Colors[color].Name.ToUpperInvariant());
                if (m.Width > max)
                {
                    max    = m.Width;
                    mindex = index;
                }
            }
            _colorItem = new ColorMenuItem(game,
                                           game.Font.MeasureString(
                                               new Vector2(10, _nameItem.Bounds.Y + _nameItem.Bounds.Height),
                                               GameColors.Colors[colors[mindex]].Name.ToUpperInvariant()), () => _player.Color,
                                           delegate(int p) { _player.Color = p; }, Strings.Color, colors);
            _typeItem = new PlayerTypeMenuItem(game,
                                               game.Font.MeasureString(
                                                   new Vector2(10, _colorItem.Bounds.Y + _colorItem.Bounds.Height),
                                                   Strings.Computer), () => _player.Type, p =>
            {
                _player.Type = p;
            }, Strings.Type);
            _backItem = new MenuItem(game,
                                     game.Font.MeasureString(
                                         new Vector2(10, _typeItem.Bounds.Y + _typeItem.Bounds.Height),
                                         Strings.Back), Strings.Back);
            _menu = new Menu(game, HandleMenuSelect,
                             _startNextItem,
                             _nameItem,
                             _colorItem,
                             _typeItem,
                             _backItem
                             );
            _invalidName = new Tween(new TimeSpan(0, 0, 0, 1), 1, 0);
            _invalidName.Finish();
        }