Ejemplo n.º 1
0
        public void CreateRoomBlocks(int width, int height)
        {
            this.Controls.Clear();
            roomBlocks = new RoomBlocks();

            rows = height;
            cols = width;

            for (int i = 0; i < height; i++)
            {
                List <RoomBlock> blockList = new List <RoomBlock>();
                for (int j = 0; j < width; j++)
                {
                    RoomBlock roomBlock = new RoomBlock();
                    roomBlock.Location = new Point(j * 55, i * 55);
                    this.Controls.Add(roomBlock);
                    blockList.Add(roomBlock);
                }
                roomBlocks.Add(blockList);
            }
        }
        public void RoomBlocks_ReduceLayout_ShouldHaveMinimumBlocks(int testNumber)
        {
            var mazeBlocks = new RoomBlocks(GetBlockLayout(testNumber));

            var before = mazeBlocks.ToString();

            _output.WriteLine("Before");
            _output.WriteLine(before);
            _output.WriteLine('='.ToPaddedString(10));

            mazeBlocks = mazeBlocks.ReduceLayout();

            var actual = mazeBlocks.ToString();

            var expected = GetReducedLayout(testNumber);

            _output.WriteLine("Expected");
            _output.WriteLine(expected);
            _output.WriteLine('='.ToPaddedString(10));
            _output.WriteLine("Actual");
            _output.WriteLine(actual);

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 3
0
        public GameState(IStateManager stateManager)
            : base(stateManager)
        {
            var blocks     = StateManager.Game.ContentManager.LoadTexture("blocks.png");
            var sun        = StateManager.Game.ContentManager.LoadTexture("sun.png");
            var background = StateManager.Game.ContentManager.LoadTexture("background.png");
            var sixteen    = StateManager.Game.ContentManager.LoadTexture("16x16.png");
            var airMeter   = new Texture2D(stateManager.Game.GraphicsDevice, 256, 4);

            airMeter.Fill(Color.White);

            _pickUpKey = StateManager.Game.ContentManager.LoadSfx("pick.wav");
            _die       = StateManager.Game.ContentManager.LoadSfx("die.wav");
            _jump      = StateManager.Game.ContentManager.LoadSfx("jump.wav");

            _font           = new SpectrumFont(StateManager.Game.ContentManager.LoadTexture("font.png"));
            _roomRenderer   = new RoomBlocks(blocks, background, sun);
            _air            = StateManager.Game.ContentManager.LoadImage("titleair.bmp");
            _lives          = new LivesIndicator(sixteen);
            _baddieRenderer = new BaddieRenderer(sixteen);
            _willy          = new MinerWillyRenderer(sixteen, background);
            _exit           = new ExitRenderer(sixteen);
            _airMeter       = new AirRenderer(airMeter);
            _scoreRenderer  = new ScoreRenderer(StateManager.Game.ContentManager.LoadTexture("font.png"));

            _pauseables.Add(_willy);
            _pauseables.Add(_baddieRenderer);
            _pauseables.Add(_roomRenderer);
            _pauseables.Add(_exit);

            var blackBackground = new Texture2D(StateManager.Game.GraphicsDevice, 128, 24);

            blackBackground.Fill(Color.Black);
            _quitGameRenderer        = new QuitGame(StateManager.Game.ContentManager.LoadTexture("font.png"), blackBackground);
            _quitGameRenderer.Hidden = true;

            _willy.IncrementScore += Score_Update;
            _willy.Jumping        += Willy_Jumping;

            _willy.OnDeath += Willy_Death;

            _pauseKey = new KeyUp(Keys.P, () =>
            {
                StateManager.ChangeState("paused", _roomId);
            });

            _quitKey = new KeyUp(Keys.Escape, () =>
            {
                ToggleQuit(!_quitShowing);
            });

            _yesKey = new KeyUp(Keys.Y, () =>
            {
                ToggleQuit(false);
                StateManager.ChangeState("title");
            });

            _noKey = new KeyUp(Keys.N, () =>
            {
                ToggleQuit(false);
            });
        }