Esempio n. 1
0
        }                                          //Toggles the cursor that is under the current index selection.

        /// <summary>
        /// Draws the sprites contained in the GUI, if there is a selection grid, it will also be drawn.
        /// The index can be used to determine which selection is currently being pointed at.
        /// </summary>
        /// <param name="sb">Standard Sprite batch</param>
        /// <param name="scale">Used for scaleing, currently unused</param>
        public void draw(SpriteBatchPlus sb, float scale)
        {
            foreach (GSprite s in _sprites)
            {
                s.draw(sb, scale);
            }

            //If no menu options are present, this is skipped
            if (_menuOptions != null)
            {
                foreach (MenuOption mo in _menuOptions)
                {
                    mo.draw(sb, scale);
                }
            }

            //Draws a sector underneath the current index in the gui
            if (sel)
            {
                Rectangle line = new Rectangle(_menuOptions[_index].getRegion().X,
                                               _menuOptions[_index].getRegion().Y + _menuOptions[_index].getRegion().Height,
                                               _menuOptions[_index].getRegion().Width,
                                               5);
                sb.Draw(sb.defaultTexture(), line, _color);
            }
        }
Esempio n. 2
0
        public void draw(SpriteBatchPlus sb, float scale)
        {
            foreach (GSprite gs in _gs)
            {
                gs.draw(sb, scale);
            }

            foreach (GObject go in _go)
            {
                go.draw(sb, scale);
            }

            if (right != null)
            {
                _doors[0].draw(sb, scale);
            }
            if (up != null)
            {
                _doors[1].draw(sb, scale);
            }
            if (left != null)
            {
                _doors[2].draw(sb, scale);
            }
            if (down != null)
            {
                _doors[3].draw(sb, scale);
            }
        }
Esempio n. 3
0
        public void draw(SpriteBatchPlus sb, float scale)
        {
            _hudBG.draw(sb, scale);

            // Draws health bar
            _healthBorder.draw(sb, scale);
            sb.Draw(sb.defaultTexture(),
                    new Rectangle((int)_hudBG.getPosition().X + 80, (int)_hudBG.getPosition().Y + 16, (int)(CurrentHP * ((hpBarLength / MaxHP))), 11),
                    Color.LawnGreen);

            sb.DrawString(font, "Health: ",
                          new Vector2(_hudBG.getPosition().X + xOffset, _hudBG.getPosition().Y + yOffset),
                          Color.White);
            String health = CurrentHP + " / " + MaxHP;

            sb.DrawString(font, health,
                          new Vector2(_healthBorder.getPosition().X + _healthBorder.getRect().Width / 2 - font.MeasureString(health).X / 2,
                                      _healthBorder.getPosition().Y + _healthBorder.getRect().Height / 2 - font.MeasureString(health).Y / 2),
                          new Color(Color.Black, 0.4f));
            sb.DrawString(font, "Score: " + Score,
                          new Vector2(_hudBG.getPosition().X + xOffset, _hudBG.getPosition().Y + yOffset + _fheight),
                          Color.White);
            sb.DrawString(font, "Currency: " + Currency,
                          new Vector2(_hudBG.getPosition().X + xOffset, _hudBG.getPosition().Y + yOffset + _fheight * 2),
                          Color.White);
            sb.DrawString(font, "Level: " + Level,
                          new Vector2(_hudBG.getPosition().X + xOffset, _hudBG.getPosition().Y + yOffset + _fheight * 3),
                          Color.White);
        }
Esempio n. 4
0
        public void draw(SpriteBatchPlus sb, float scale)
        {
            _currRoom.draw(sb, scale);

            //This draws the map over top off the room
            //Used for testing purposes when checking the map generation
            //miniMap.draw(sb, scale);
        }
Esempio n. 5
0
        //private Texture2D _t;

        override public void draw(SpriteBatchPlus sb, float scale)
        {
            sb.Draw(sb.defaultTexture(), _r, _c);
        }
Esempio n. 6
0
 override public void draw(SpriteBatchPlus sb, float scale)
 {
     sb.DrawString(_f, _t, _p, _c);
 }
Esempio n. 7
0
 abstract public void draw(SpriteBatchPlus sb, float scale);
Esempio n. 8
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 SpriteBatchPlus(GraphicsDevice);
            Texture2D plainText = new Texture2D(GraphicsDevice, 1, 1);

            plainText.SetData(new[] { Color.White });
            spriteBatch.setDefaultTexture(plainText);
            //currentTime = 0;
            //goalTime = 35;
            Keys[] MenuControlList = { Keys.Escape, Keys.Enter, Keys.W, Keys.S, Keys.Up, Keys.Down };
            MenuControls = new MenuControls(MenuControlList);

            Keys[] playControlList = { Keys.Escape, Keys.W, Keys.A, Keys.S, Keys.D, Keys.Left, Keys.Right, Keys.Up, Keys.Down, Keys.Space };
            PlayControls = new PlayControls(playControlList);



            //Creates Test Room

            /*GSprite[] roomSprites = { new NSprite(new Rectangle(0, 0, WIDTH, HEIGHT), Color.Gray),
             *  new NSprite(new Rectangle(100, 100, WIDTH - 200, HEIGHT - 200), Color.LightGray)};
             * rm = new Room(roomSprites);
             *
             * //rm.addObject(new Entity(new Vector2(500, 500), new NSprite(new Rectangle(500, 500, 50, 50), Color.Wheat)));*/


            //Imports Font
            mfont   = Content.Load <SpriteFont>("main");
            sfont   = Content.Load <SpriteFont>("second");
            guiFont = Content.Load <SpriteFont>("guiFont");
            int mHeight = (int)mfont.MeasureString("M").Y;
            int sHeight = (int)sfont.MeasureString("M").Y;


            //Score tracking system setup
            highscoresSprites  = new SSprite[10];
            achievementSprites = new SSprite[3];

            loadedHighscores   = new int[10];
            loadedAchievements = new int[3];

            for (int i = 0; i < 10; i++)
            {
                loadedHighscores[i] = -1;
            }
            for (int i = 0; i < 3; i++)
            {
                loadedAchievements[i] = -2;
            }

            string input = "-1";

            try
            {
                StreamReader sr = new StreamReader("sts.txt");
                for (int i = 0; i < 10; i++)
                {
                    input = sr.ReadLine();
                    int.TryParse(input, out loadedHighscores[i]);
                }

                for (int i = 0; i < 3; i++)
                {
                    input = sr.ReadLine();
                    int.TryParse(input, out loadedAchievements[i]);
                }
                sr.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }

            for (int i = 0; i < 10; i++)
            {
                highscoresSprites[i] = new SSprite(i + 1 + ". " + loadedHighscores[i], sfont, new Vector2(50, mHeight * 2 + 10 + i * (sHeight + 10)), Color.Azure);
            }
            achievementSprites[0] = new SSprite("Levels Completed: " + loadedAchievements[0], sfont, new Vector2(400, mHeight * 2 + 10 + 0 * (sHeight + 10)), Color.Azure);
            achievementSprites[1] = new SSprite("Chargers Killed: " + loadedAchievements[1], sfont, new Vector2(400, mHeight * 2 + 10 + 1 * (sHeight + 10)), Color.Azure);
            achievementSprites[2] = new SSprite("Rangers Killed: " + loadedAchievements[2], sfont, new Vector2(400, mHeight * 2 + 10 + 2 * (sHeight + 10)), Color.Azure);



            //Creates Main Menu
            GSprite[] gs = { new NSprite(new Rectangle(0,     0, WIDTH,          HEIGHT),      Color.SandyBrown),
                             new NSprite(new Rectangle(0,     0, WIDTH,          mHeight * 2), Color.SaddleBrown),
                             new SSprite("Maze Crawler",  mfont, new Vector2(25, mHeight / 2), Color.Azure) };

            MenuOption[] mo = { new MenuOption(new SSprite("Start Game",                  sfont, new Vector2(50, mHeight * 2 + sHeight),     Color.Azure)),
                                new MenuOption(new SSprite("Highscores and Achievements", sfont, new Vector2(50, mHeight * 2 + sHeight * 3), Color.Azure)),
                                new MenuOption(new SSprite("Quit Game",                   sfont, new Vector2(50, mHeight * 2 + sHeight * 5), Color.Azure)) };

            mainMenu = new GGUI(gs, mo, Color.Azure);



            //Creates Pause Menu
            GSprite[] pgs = { new NSprite(new Rectangle(WIDTH / 4, HEIGHT / 8, WIDTH / 2,                                                       HEIGHT / 2),               Color.SandyBrown),
                              new NSprite(new Rectangle(WIDTH / 4, HEIGHT / 8, WIDTH / 2,                                                       mHeight * 2),              Color.SaddleBrown),
                              new SSprite("Pause Menu",            mfont,      new Vector2(WIDTH / 2 - mfont.MeasureString("Pause Menu").X / 2, HEIGHT / 8 + mHeight / 2), Color.Azure) };

            MenuOption[] pmo = { new MenuOption(new SSprite("Resume", sfont, new Vector2(WIDTH / 2 - mfont.MeasureString("Pause Menu").X / 4, HEIGHT / 8 + mHeight * 2 + sHeight / 2), Color.Azure)),
                                 new MenuOption(new SSprite("Quit",   sfont, new Vector2(WIDTH / 2 - mfont.MeasureString("Pause Menu").X / 4, HEIGHT / 8 + mHeight * 2 + sHeight * 2), Color.Azure)) };

            pauseMenu = new GGUI(pgs, pmo, Color.Azure);

            //Creates Shop Menu
            GSprite[] sgs = { new NSprite(new Rectangle(WIDTH / 4, HEIGHT / 8, WIDTH / 2,                                                          HEIGHT * 2 / 3),           Color.SandyBrown),
                              new NSprite(new Rectangle(WIDTH / 4, HEIGHT / 8, WIDTH / 2,                                                          mHeight * 2),              Color.SaddleBrown),
                              new SSprite("Ye Old Shope",          mfont,      new Vector2(WIDTH / 2 - mfont.MeasureString("Ye Old Shoppe").X / 2, HEIGHT / 8 + mHeight / 2), Color.Azure) };

            MenuOption[] smo = { new MenuOption(new SSprite("Weapon Damage (10C)", sfont, new Vector2(WIDTH / 2 - mfont.MeasureString("Ye Old Shope").X / 4, HEIGHT / 8 + mHeight * 2 + sHeight / 2),    Color.Azure)),
                                 new MenuOption(new SSprite("Max Health (10C)",    sfont, new Vector2(WIDTH / 2 - mfont.MeasureString("Ye Old Shope").X / 4, HEIGHT / 8 + mHeight * 2 + sHeight * 2),    Color.Azure)),
                                 new MenuOption(new SSprite("Quit",                sfont, new Vector2(WIDTH / 2 - mfont.MeasureString("Ye Old Shope").X / 4, HEIGHT / 8 + mHeight * 2 + sHeight * 3.5f), Color.Azure)) };


            shopMenu = new GGUI(sgs, smo, Color.Azure);

            //Creates Death Menu

            deathMenuScore = new SSprite("Your Score: ", sfont, new Vector2(WIDTH / 2 - mfont.MeasureString("You Died").X / 4, HEIGHT / 8 + mHeight * 2 + sHeight * 3.5f), Color.Azure);

            GSprite[] dgs = { new NSprite(new Rectangle(WIDTH / 4, HEIGHT / 8, WIDTH / 2,                                                     HEIGHT / 2),               Color.SandyBrown),
                              new NSprite(new Rectangle(WIDTH / 4, HEIGHT / 8, WIDTH / 2,                                                     mHeight * 2),              Color.SaddleBrown),
                              new SSprite("You Died",              mfont,      new Vector2(WIDTH / 2 - mfont.MeasureString("You Died").X / 2, HEIGHT / 8 + mHeight / 2), Color.Azure),
                              deathMenuScore };

            MenuOption[] dmo = { new MenuOption(new SSprite("Main Menu", sfont, new Vector2(WIDTH / 2 - mfont.MeasureString("You Died").X / 4, HEIGHT / 8 + mHeight * 2 + sHeight / 2), Color.Azure)),
                                 new MenuOption(new SSprite("Quit",      sfont, new Vector2(WIDTH / 2 - mfont.MeasureString("You Died").X / 4, HEIGHT / 8 + mHeight * 2 + sHeight * 2), Color.Azure)) };

            deathMenu = new GGUI(dgs, dmo, Color.Azure);

            //Creates Leaderboard plus AH system

            GSprite[] scoregs = new GSprite[16];
            scoregs[0] = new NSprite(new Rectangle(0, 0, WIDTH, HEIGHT), Color.SandyBrown);
            scoregs[1] = new NSprite(new Rectangle(0, 0, WIDTH, mHeight * 2), Color.SaddleBrown);
            scoregs[2] = new SSprite("Highscores and Acheivements", mfont, new Vector2(25, mHeight / 2), Color.Azure);
            for (int i = 0; i < 10; i++)
            {
                scoregs[3 + i] = highscoresSprites[i];
            }
            for (int i = 0; i < 3; i++)
            {
                scoregs[13 + i] = achievementSprites[i];
            }

            MenuOption[] scoremo = { new MenuOption(new SSprite("Return", sfont, new Vector2(50, HEIGHT - sHeight * 2), Color.Azure)) };

            scoreMenu = new GGUI(scoregs, scoremo, Color.Azure);


            // TODO: use this.Content to load your game content here
        }
Esempio n. 9
0
 public void draw(SpriteBatchPlus sb, float scale)
 {
     _sprite.draw(sb, scale);
 }
Esempio n. 10
0
 override public void draw(SpriteBatchPlus sb, float scale)
 {
     sb.Draw(_t, _r, _c);
 }
Esempio n. 11
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 SpriteBatchPlus(GraphicsDevice);
            Texture2D plainText = new Texture2D(GraphicsDevice, 1, 1);

            plainText.SetData(new[] { Color.White });
            spriteBatch.setDefaultTexture(plainText);
            //currentTime = 0;
            //goalTime = 35;
            Keys[] MenuControlList = { Keys.Escape, Keys.Enter, Keys.W, Keys.S, Keys.Up, Keys.Down };
            MenuControls = new MenuControls(MenuControlList);

            Keys[] playControlList = { Keys.Escape, Keys.W, Keys.A, Keys.S, Keys.D, Keys.Left, Keys.Right, Keys.Up, Keys.Down, Keys.Space };
            PlayControls = new PlayControls(playControlList);



            //Creates Test Room

            /*GSprite[] roomSprites = { new NSprite(new Rectangle(0, 0, WIDTH, HEIGHT), Color.Gray),
             *  new NSprite(new Rectangle(100, 100, WIDTH - 200, HEIGHT - 200), Color.LightGray)};
             * rm = new Room(roomSprites);
             *
             * //rm.addObject(new Entity(new Vector2(500, 500), new NSprite(new Rectangle(500, 500, 50, 50), Color.Wheat)));*/


            //Imports Font
            mfont = Content.Load <SpriteFont>("main");
            sfont = Content.Load <SpriteFont>("second");
            int mHeight = (int)mfont.MeasureString("M").Y;
            int sHeight = (int)sfont.MeasureString("M").Y;


            //Creates Main Menu
            GSprite[] gs = { new NSprite(new Rectangle(0,     0, WIDTH,          HEIGHT),      Color.SandyBrown),
                             new NSprite(new Rectangle(0,     0, WIDTH,          mHeight * 2), Color.SaddleBrown),
                             new SSprite("Maze Crawler",  mfont, new Vector2(25, mHeight / 2), Color.Azure) };

            MenuOption[] mo = { new MenuOption(new SSprite("Start Game", sfont, new Vector2(50, mHeight * 2 + sHeight),     Color.Azure)),
                                new MenuOption(new SSprite("Settings",   sfont, new Vector2(50, mHeight * 2 + sHeight * 3), Color.Azure)),
                                new MenuOption(new SSprite("Quit Game",  sfont, new Vector2(50, mHeight * 2 + sHeight * 5), Color.Azure)) };

            mainMenu = new GGUI(gs, mo, Color.Azure);



            //Creates Pause Menu
            GSprite[] pgs = { new NSprite(new Rectangle(WIDTH / 4, HEIGHT / 8, WIDTH / 2,                                                       HEIGHT / 2),               Color.SandyBrown),
                              new NSprite(new Rectangle(WIDTH / 4, HEIGHT / 8, WIDTH / 2,                                                       mHeight * 2),              Color.SaddleBrown),
                              new SSprite("Pause Menu",            mfont,      new Vector2(WIDTH / 2 - mfont.MeasureString("Pause Menu").X / 2, HEIGHT / 8 + mHeight / 2), Color.Azure) };

            MenuOption[] pmo = { new MenuOption(new SSprite("Resume",  sfont, new Vector2(WIDTH / 2 - mfont.MeasureString("Pause Menu").X / 4, HEIGHT / 8 + mHeight * 2 + sHeight / 2),    Color.Azure)),
                                 new MenuOption(new SSprite("Setting", sfont, new Vector2(WIDTH / 2 - mfont.MeasureString("Pause Menu").X / 4, HEIGHT / 8 + mHeight * 2 + sHeight * 2),    Color.Azure)),
                                 new MenuOption(new SSprite("Quit",    sfont, new Vector2(WIDTH / 2 - mfont.MeasureString("Pause Menu").X / 4, HEIGHT / 8 + mHeight * 2 + sHeight * 3.5f), Color.Azure)) };

            pauseMenu = new GGUI(pgs, pmo, Color.Azure);


            // TODO: use this.Content to load your game content here
        }