예제 #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            map        = new Map();
            pathfinder = new Pathfinder();
            camera     = new Camera(graphics.GraphicsDevice.Viewport);
            debugMode  = false;

            //för UI
            UIList           = new List <UI>();
            selectorPosition = new Vector2(730, 550);
            settingsMenu     = new SettingsMenu(Content);

            //laddar in textures / text
            fadeIn           = Content.Load <Texture2D>("blackspace");
            battle           = Content.Load <Texture2D>("backroundForBattle");
            menuBattle       = Content.Load <Texture2D>("battleMenu");
            healthMenuBattle = Content.Load <Texture2D>("healthMenu");
            nameInBattle     = Content.Load <SpriteFont>("textForName");
            developerFont    = Content.Load <SpriteFont>("Ffont");
            vitblock         = Content.Load <Texture2D>("vitblock");

            //battle animationer
            battleAnimation     = new animationForBattle(battle, new Vector2(0, 0), new Vector2(0, 0));
            battleMenuAnimation = new animationForBattle(menuBattle, new Vector2(1200, 1200), new Vector2(-1, -1));
            battleHealthbars    = new animationForBattle(healthMenuBattle, new Vector2(1200, 0), new Vector2(-1, 60));

            // creature loading and some testing pathfinding
            creatures    = new XMLReader();
            errorMessage = creatures.ParseCreaturesFile(Content);
            creatures.creatures[0].MoveTo(pathfinder.Pathfind(creatures.creatures[0].position, new Vector2(128, 832), 0));
            creatures.creatures[1].MoveTo(pathfinder.Pathfind(creatures.creatures[1].position, new Vector2(2496, 256), 0));
            creatures.creatures[2].MoveTo(pathfinder.Pathfind(creatures.creatures[2].position, new Vector2(2432, 256), 0));
            creatures.creatures[3].MoveTo(pathfinder.Pathfind(creatures.creatures[3].position, new Vector2(2368, 256), 0));

            errorMessage           += pathfinder.errorMessage;
            pathfinder.errorMessage = string.Empty;

            player = new Player("bob", new Vector2(896, 896), 10, Content.Load <Texture2D>("knuc"), creatures.creatures, 20f);

            //battle UI Main
            UIList.Add(new UI(new Vector2(170, 90), nameInBattle, player.Name));
            UIList.Add(new UI(new Vector2(750, 550), nameInBattle, "Attack"));
            UIList.Add(new UI(new Vector2(750, 600), nameInBattle, "Stats"));
            UIList.Add(new UI(new Vector2(850, 550), nameInBattle, "Inventory"));
            UIList.Add(new UI(new Vector2(850, 600), nameInBattle, "Run"));

            mainBattleMenu = new controlForUI(nameInBattle, new Vector2(740, 550), 2, 2);

            gamestate = Gamestate.meny;


            base.Initialize();
        }
예제 #2
0
        public Battle(Texture2D background, Texture2D inventoryMenu, Texture2D healthMenu, controlForUI menyn, List <UI> listOfUI, Player player, SpriteBatch spriteBatch, SpriteFont spriteFont)
        {
            //texture load
            battleTexture    = background;
            menuBattle       = inventoryMenu;
            healthMenuBattle = healthMenu;

            //laddar in player
            this.player = player;

            //laddar in sprites.
            this.spriteBatch = spriteBatch;
            this.spriteFont  = spriteFont;

            //laddar in andra klasser samt lisor
            UIList         = listOfUI;
            mainBattleMenu = menyn;

            //battle animationer
            battleAnimation     = new animationForBattle(battleTexture, new Vector2(0, 0), new Vector2(0, 0));
            battleMenuAnimation = new animationForBattle(menuBattle, new Vector2(1200, 1200), new Vector2(-1, -1));
            battleHealthbars    = new animationForBattle(healthMenuBattle, new Vector2(1200, 0), new Vector2(-1, 60));
        }