public ScoreScene(
            Game game,
            SpriteFont font,
            IDictionary<int, string> highScores,
            Texture2D background,
            params Tuple<int, IController>[] playerScores)
            : base(game)
        {
            var backgroundComponent = new ImageComponent(game, background, ImageComponent.DrawMode.Center);
            Components.Add(backgroundComponent);

            if (highScores.Count < 10 || playerScores.Any(ps => highScores.Keys.Any(k => k < ps.Item1)))
            {
                AcceptingInput = true;
                var highCount = playerScores.Count(ps => highScores.Keys.Any(k => k < ps.Item1));

                var remove = _highScores.Keys.OrderBy(k => k).Take(highCount);
                foreach (var r in remove)
                {
                    _highScores.Remove(r);
                }

                _playerEntries =
                    playerScores.OrderByDescending(ps => ps.Item1)
                                .Take(highCount)
                                .Select(ps => Tuple.Create(ps.Item1, ps.Item2, string.Empty))
                                .ToList();
                foreach (var pe in _playerEntries)
                {
                    highScores.Add(pe.Item1, pe.Item3);
                }
            }

            var y = 100;
            foreach (var hs in highScores.OrderByDescending(x => x.Key))
            {
                var component = new TextComponent(game, font, new Vector2(100, y), Color.White)
                                    {
                                        Visible = true,
                                        Enabled = true,
                                        Text = hs.Value + "   " + hs.Key
                                    };

                var playerScore = playerScores.LastOrDefault(ps => hs.Key == ps.Item1);
                var controller = playerScore != null ? playerScore.Item2 : null;
                Components.Add(component);
                _highScores.Add(hs.Key, Tuple.Create(string.Empty, component, controller));
                y += 100;
            }
        }
        public JoinScene(Game game, SpriteFont font, IEnumerable<IController> controllers)
            : base(game)
        {
            _controllers = controllers;
            _playerOneStatus = new TextComponent(game, font, new Vector2(x: Game.Window.ClientBounds.Width / 2, y: 330), Color.Blue)
                                   {
                                       Enabled = true,
                                       Visible = true,
                                       Text = "Press Start"
                                   };

            _playerTwoStatus = new Core.TextComponent(game, font, new Vector2(x: Game.Window.ClientBounds.Width / 2, y: 360), Color.Red)
                                   {
                                       Text = this._playerOneStatus.Text,
                                       Enabled = true,
                                       Visible = true
                                   };

            this.Components.Add(_playerOneStatus);
            this.Components.Add(_playerTwoStatus);
        }
        ActionScene(
            Game game, Texture2D theTexture, Texture2D backgroundTexture, SpriteFont font, Vector2 gameoverPosition)
            : base(game)
        {
            this._audio = (AudioLibrary)Game.Services.GetService(typeof(AudioLibrary));
            this._background = new ImageComponent(game, backgroundTexture, ImageComponent.DrawMode.Stretch);
            Components.Add(this._background);
            this._actionTexture = theTexture;
            this._spriteBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch));
            this._meteors = new MeteorsManager(Game, ref this._actionTexture);
            Components.Add(this._meteors);
            this._scoreFont = font;
            this._gameoverPosition = gameoverPosition;
            this._scorePlayer1 = new Score(game, font, Color.Blue) { Position = new Vector2(10, 10) };
            Components.Add(this._scorePlayer1);

            this._rumblePad = new SimpleRumblePad(game);
            Components.Add(this._rumblePad);
            this._powerSource = new PowerSource(game, ref this._actionTexture);
            Components.Add(this._powerSource);
            #if DEBUG
            this._positionDebugText = new TextComponent(game, this._scoreFont, new Vector2(), Color.Red);
            Components.Add(this._positionDebugText);
            #endif
        }
Beispiel #4
0
        ActionScene(Game game, Texture2D theTexture, Texture2D backgroundTexture, SpriteFont font)
            : base(game)
        {
            _audio = (AudioLibrary)Game.Services.GetService(typeof(AudioLibrary));
            _background = new ImageComponent(game, backgroundTexture, ImageComponent.DrawMode.Stretch);
            Components.Add(_background);

            _actionTexture = theTexture;

            _spriteBatch = (SpriteBatch) Game.Services.GetService(typeof (SpriteBatch));
            _meteors = new MeteorsManager(Game, ref _actionTexture);
            Components.Add(_meteors);

            _scoreFont = font;

            _scorePlayer1 = new Score(game, font, _player1FontColor) {Position = new Vector2(10, 10)};
            Components.Add(_scorePlayer1);

            _rumblePad = new SimpleRumblePad(game);
            Components.Add(_rumblePad);

            _powerSource = new PowerSource(game, ref _actionTexture);
            _powerSource.Initialize();
            Components.Add(_powerSource);

            _wrench = new Wrench(game, game.Content.Load<Texture2D>("wrench"));
            _wrench.Initialize();
            Components.Add(_wrench);

            #if DEBUG
            _positionDebugText=new TextComponent(game,_scoreFont,new Vector2(),Color.Red);
            Components.Add(_positionDebugText);
            #endif
        }