示例#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();
        }
示例#2
0
 public MapChooser(Golf game, Rectangle bounds, string name, ILevelSelector levelSelector, PlayerSelectArena playerSelectArena) : base(game, bounds, name)
 {
     LevelSelector     = levelSelector;
     PlayerSelectArena = playerSelectArena;
     SetBounds();
 }