Beispiel #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            //Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            mainCamera = new Camera();



            //Load all the textures and fonts
            gameOverText         = Content.Load <SpriteFont>("MedievalFont");
            directions           = Content.Load <SpriteFont>("Gold");
            font                 = Content.Load <SpriteFont>("MedievalFont");
            difficultySelectText = Content.Load <SpriteFont>("MedievalFont");

            startText      = Content.Load <SpriteFont>("Gold");
            texStartBanner = Util.texFromFile(GraphicsDevice, dir + "startBanner.png");
            texGoldBanner  = Util.texFromFile(GraphicsDevice, dir + "goldBanner.png");
            texBook        = Util.texFromFile(GraphicsDevice, dir + "openBookWithText.png");
            texHorseRun    = Util.texFromFile(GraphicsDevice, dir + "horseRun.png");
            texEnemy       = Util.texFromFile(GraphicsDevice, dir + "Enemy.png");
            texBlood       = Util.texFromFile(GraphicsDevice, dir + "bloodSide.png");
            texArrow       = Util.texFromFile(GraphicsDevice, dir + "Arrow.png");
            texWorldMap    = Util.texFromFile(GraphicsDevice, dir + "FantasyWorldMap_2.png");

            //Define playarea
            playArea = new Rectangle(lhs, top, rhs - lhs, bot - top); // width and height

            //Load sprites and change size if necessary
            worldMap = new Sprite3(true, texWorldMap, -2000, -1000);
            worldMap.setWidthHeight(6400, 4800);
            book = new Sprite3(true, texBook, 50, 50);
            book.setWidthHeight(700, 500);
            startBanner = new Sprite3(true, texStartBanner, 0, 0);
            startBanner.setWidthHeight(800, 600);
            goldBanner = new Sprite3(true, texGoldBanner, 15, 15);
            goldBanner.setWidthHeight(130, 40);
            horse = new Sprite3(true, texHorseRun, xx, yy);



            //Load some empty spritelists
            enemies    = new SpriteList();
            bloodSplat = new SpriteList();
            horseRun   = new SpriteList();
            quiver     = new SpriteList();

            for (int a = 0; a < 5; a++)
            {
                arrow = new Sprite3(false, texArrow, 0, 0);
                arrow.setWidthHeight(arrow.getWidth() * 0.09f, arrow.getHeight() * 0.09f);
                quiver.addSpriteReuse(arrow);
            }

            //Used to change size of sprites
            float scale = 0.5f;


            //Player animation setup
            horse.setXframes(8);
            horse.setWidthHeight(1568 / 8 * scale, texHorseRun.Height * scale);
            horse.setBB(30, 10, (horse.getWidth() / scale) - 60, horse.getHeight() / scale - 20);
            for (int h = 0; h < anim.Length; h++)
            {
                anim[h].X = h;
            }
            horseRun.addSpriteReuse(horse);

            //enemy.setBBToTexture();

            //Enemy animation setup
            for (int k = 0; k < 100; k++)
            {
                enemy = new Sprite3(false, texEnemy, 850, 400);
                enemy.setXframes(10);
                enemy.setYframes(5);
                enemy.setWidthHeight(320 / 10, 160 / 5);
                enemy.setBB(0, 0, enemy.getWidth(), enemy.getHeight());
                int count = 0;
                for (int i = 0; i < 5; i++)
                {
                    for (int j = 0; j < 10; j++)
                    {
                        animEnemy[count].X = j;
                        animEnemy[count].Y = i;
                        count++;
                    }
                }
                enemy.setAnimationSequence(animEnemy, 20, 29, 15);
                enemy.setAnimFinished(0);
                enemy.animationStart();
                enemy.setVisible(false);
                enemies.addSpriteReuse(enemy);
            }
            //Load scrolling background images
            scrolling1 = new Scrolling(Util.texFromFile(GraphicsDevice, dir + "GPT Background 800x600.png"), new Rectangle(0, 0, 800, 600), scrollingSpeed);
            scrolling2 = new Scrolling(Util.texFromFile(GraphicsDevice, dir + "GPT Background2 800x600.png"), new Rectangle(800, 0, 800, 600), scrollingSpeed);
        }