コード例 #1
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            // Onderstaande 4 textures worden gebruikt voor collision bepalingen.
            _tileTexture   = Content.Load <Texture2D>("Tiles/L2/BlockA1");
            _playerTexture = Content.Load <Texture2D>("Tiles/L2/BlockA1");
            _enemyTexture  = Content.Load <Texture2D>("Tiles/L2/BlockA1");
            _bossTexture   = Content.Load <Texture2D>("Tiles/L2/BlockA1");

            _player     = new Player(_playerTexture, new Vector2(50, 50), _spriteBatch);
            _vortex     = new Vortex(null, new Vector2(0, 0), _spriteBatch);
            _demonHorde = new List <Enemy>();

            _geryon = new Boss(_bossTexture, new Vector2(250, 250), _spriteBatch, _mobDistance, GeryonHealth);
            _geryon.Load(Content);
            _healthTexture = Content.Load <Texture2D>("18");

            _player.Load(Content);
            _vortex.Load(Content);
            _board = new Board(_spriteBatch, _tileTexture, 59, 25);
            _board.CreateNewRandomBoard();

            // Hier worden de ingestelde hoeveelheid (gc.MaxScoreCount) Coins in de speelwereld op een willekeurige plaats gezet, met controle dat deze niet
            // per ongeluk worden ingebouwd door random geplaatste blocked tiles.
            _coins = new List <Coin>();
            for (int i = 0; i < gc.MaxScoreCount; i++)
            {
                Vector2   randPos  = new Vector2((_rand.Next(0, Konquer.ScreenWidth / TileWidth) * TileWidth) + 24, _rand.Next(0, Konquer.ScreenHeight / TileHeight) * TileHeight);
                Rectangle coinRect = new Rectangle((int)randPos.X, (int)randPos.Y - TileHeight, TileWidth, TileHeight);

                if (!_board.HasRoomForRectangle(coinRect))
                {
                    randPos  = new Vector2(_rand.Next(TileWidth, (ScreenWidth - (TileWidth * 2))), _rand.Next(0, Konquer.ScreenHeight / TileHeight) * TileHeight);
                    coinRect = new Rectangle((int)randPos.X, (int)randPos.Y, TileWidth, TileHeight);
                }

                _coins.Add(new Coin(null, randPos, _spriteBatch));
                _coins[i].Load(Content);
            }

            //Animated background
            List <Texture2D> _BG = new List <Texture2D>();

            for (int i = 0; i < 8; i++)
            {
                _BG.Add(Content.Load <Texture2D>("BG/BG" + i));
            }
            background1 = new Background();
            background1.SetBG(_BG);

            //Font
            _myFont = Content.Load <SpriteFont>("DebugFont");

            //Pause menu
            _pauseMenuTexture = new Texture2D(GraphicsDevice, 1, 1);
            _pauseMenuTexture.SetData(new[] { Color.DarkSlateBlue });
            TriggerPauseGame();
        }