Exemplo n.º 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 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
        }
Exemplo n.º 2
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
        }