public void Update(GameTime time)
        {
            // We just need to render once
            if (mDeleteScreen)
            {
                var hudScreen = new HudScreen(mLevelPath);
                ScreenManager.Add(hudScreen);
                ScreenManager.Remove(this);

                if (mLoadSaveGame)
                {
                    LoadSaveGame(ref hudScreen);
                }
            }
            else
            {
                var menus = mMenuList.ToArray();

                // Iterate over all Menu elements
                foreach (var menu in menus)
                {
                    if (!menu.mIsVisible)
                    {
                        continue;
                    }
                    menu.CheckRegisteredEvents();
                }

                mDeleteScreen = true;
            }
        }
Exemple #2
0
        public void LoadContent(GraphicsDeviceManager deviceManager, ContentManager contentManager, int windowWidth, int windowHeight)
        {
            mScreenWidth  = windowWidth;
            mScreenHeight = windowHeight;

            //Load SoundEffects
            mClickSound = contentManager.Load <SoundEffect>("Audio/click2");

            Device       = deviceManager.GraphicsDevice;
            mSpriteBatch = new SpriteBatch(deviceManager.GraphicsDevice);

            // Unlock the framerate. Later we want to remove this piece of code
            mGraphicsDevice = deviceManager.GraphicsDevice;
            mSpriteBatch    = new SpriteBatch(deviceManager.GraphicsDevice);

            // Load font
            var font       = contentManager.Load <SpriteFont>("Font");
            var headerFont = contentManager.Load <SpriteFont>("Heading");

            IsVisible = true;

            // Load background image
            mBackgroundImage = contentManager.Load <Texture2D>("Forest");

            mMenuList = new List <UIv2.Menu>();
            var menu = new UIv2.Menu(mGraphicsDevice, 5, 5, 90, 90);

            menu.WithBackground(UIv2.Menu.CreateTexture2D(deviceManager.GraphicsDevice, 50, 30, pixel => new Color(0.0f, 0.0f, 0.0f, 0.2f)), 5, 5, 90, 90);
            mMenuList.Add(menu);

            Texture2D texture2D            = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.Black);
            Texture2D texture2DSliderPoint = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.White);

            // GAME OVER Text
            var heading = new UIv2.Components.Label(mGraphicsDevice, 10, 20, 80, 30, "GAME OVER", headerFont, Color.DarkSlateGray);

            heading.FontType = FontManager.FontType.Heading;
            heading.AddTo(menu);

            var loseString = "The lumberjacks won... Now go bury yourself!";
            var loseLabel  = new UIv2.Components.Label(mGraphicsDevice, 20, 60, 60, 10, loseString, font, Color.White);

            loseLabel.AddTo(menu);

            var repeatButton = new UIv2.Components.Button(mGraphicsDevice, 40, 70, 20, 7, texture2D, "Try again", font, Color.White);

            repeatButton.AddTo(menu);
            repeatButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
            {
                var levelString = mHudScreen.mGameScreen.mLevel.mLevelFilename;
                SoundManager.AddSound(mClickSound);
                ScreenManager.Remove(this);
                IsVisible         = false;
                var loadingScreen = new LoadingScreen(levelString);
                ScreenManager.Add(loadingScreen);
            });

            // Create Main Menu Button (Back Button)
            var backButton = new UIv2.Components.Button(mGraphicsDevice, 40, 80, 20, 7, texture2D, "Main menu", font, Color.White);

            backButton.AddTo(menu);
            backButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
            {
                SoundManager.AddSound(mClickSound);
                ScreenManager.Remove(this);
                IsVisible = false;
            });
        }
        public void LoadContent(GraphicsDeviceManager deviceManager, ContentManager contentManager, int windowWidth, int windowHeight)
        {
            mScreenWidth  = windowWidth;
            mScreenHeight = windowHeight;

            //Load SoundEffects
            mClickSound    = contentManager.Load <SoundEffect>("Audio/click2");
            mMainMenuMusic = contentManager.Load <SoundEffect>("Audio/slowmo");

            SoundManager.AddMusic(mMainMenuMusic);

            // We should remove this for a more stable framerate later
            deviceManager.SynchronizeWithVerticalRetrace = false;
            deviceManager.ApplyChanges();

            mMenuList = new List <UIv2.Menu>();

            IsVisible = true;

            mGraphicsDevice = deviceManager.GraphicsDevice;

            mSpriteBatch = new SpriteBatch(deviceManager.GraphicsDevice);

            // Load font
            var font          = contentManager.Load <SpriteFont>("Font");
            var headerFont    = contentManager.Load <SpriteFont>("Heading");
            var buttonTexture = contentManager.Load <Texture2D>("button");

            IsVisible = true;

            // Load background image
            mBackgroundImage = contentManager.Load <Texture2D>("Forest");

            IsVisible = true;

            mOptionsScreen      = new OptionsMenu(false);
            mStatisticsScreen   = new StatisticsScreen();
            mCreditsScreen      = new CreditsScreen();
            mEditorHudScreen    = new EditorHudScreen();
            mAchievementsScreen = new AchievementsScreen();
            mScreamScreen       = new ScreamScreen();

            var menu = new UIv2.Menu(mGraphicsDevice, 0, 0, 100, 100);

            mMenuList.Add(menu);

            var texture2D = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.Black);

            var heading = new UIv2.Components.Label(mGraphicsDevice, 10, 0, 80, 30, "Silverback", headerFont, Color.DarkSlateGray);

            heading.FontType = FontManager.FontType.Heading;
            heading.AddTo(menu);

            var newGameButton = new UIv2.Components.Button(mGraphicsDevice, 35, 24, 30, 7, texture2D, "New Game", font, Color.White);

            newGameButton.AddTo(menu);
            newGameButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
            {
                SoundManager.AddSound(mClickSound);
                Statistic.CurrentSaveTime = 0;
                var loadingScreen         = new LoadingScreen("..\\..\\..\\..\\Content\\tutorial.lvl");
                ScreenManager.Add(loadingScreen);
                IsVisible = false;
            });

            var loadGameButton = new UIv2.Components.Button(mGraphicsDevice, 35, 32, 30, 7, texture2D, "Load Game", font, Color.White);

            loadGameButton.AddTo(menu);
            // Add an event listener to the button
            loadGameButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
            {
                SoundManager.AddSound(mClickSound);

                if (!File.Exists(PauseScreen.GetSavedGamesPath() + "\\Camera.xml") ||
                    !File.Exists(PauseScreen.GetSavedGamesPath() + "\\CapuchinPositions.xml") ||
                    !File.Exists(PauseScreen.GetSavedGamesPath() + "\\ChimpPositions.xml") ||
                    !File.Exists(PauseScreen.GetSavedGamesPath() + "\\GibbonPositions.xml") ||
                    !File.Exists(PauseScreen.GetSavedGamesPath() + "\\HudScreen.xml") ||
                    !File.Exists(PauseScreen.GetSavedGamesPath() + "\\Huts.xml") ||
                    !File.Exists(PauseScreen.GetSavedGamesPath() + "\\Level.xml") ||
                    !File.Exists(PauseScreen.GetSavedGamesPath() + "\\OrangPositions.xml") ||
                    !File.Exists(PauseScreen.GetSavedGamesPath() + "\\Silverback.xml"))
                {
                    return;
                }

                // Get the level file

                using (var fs = File.OpenRead(PauseScreen.GetSavedGamesPath() + "\\HudScreen.xml"))
                {
                    var serializer      = new XmlSerializer(typeof(HudScreen));
                    HudScreen hudScreen = null;
                    try
                    {
                        hudScreen = (HudScreen)serializer.Deserialize(fs);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.GetBaseException());
                    }

                    if (hudScreen != null)
                    {
                        var loadingScreen = new LoadingScreen(hudScreen.mLevelPath);
                        loadingScreen.LoadSaveGame();
                        ScreenManager.Add(loadingScreen);
                    }

                    IsVisible = false;
                }
            });

            // Create Statistic button
            var statisticsButton = new UIv2.Components.Button(mGraphicsDevice, 35, 40, 30, 7, texture2D, "Statistics", font, Color.White);

            statisticsButton.AddTo(menu);
            // Add an event listener to the button
            statisticsButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
            {
                SoundManager.AddSound(mClickSound);
                ScreenManager.Add(mStatisticsScreen);
                IsVisible = false;
            });

            // Create Achievements button
            var achievementsButton = new UIv2.Components.Button(mGraphicsDevice, 35, 48, 30, 7, texture2D, "Achievements", font, Color.White);

            achievementsButton.AddTo(menu);
            // Add an event listener to the button
            achievementsButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
            {
                SoundManager.AddSound(mClickSound);
                ScreenManager.Add(mAchievementsScreen);
                IsVisible = false;
            });

            // Create Credits button
            var creditsButton = new UIv2.Components.Button(mGraphicsDevice, 35, 56, 30, 7, texture2D, "Credits", font, Color.White);

            creditsButton.AddTo(menu);
            // Add an event listener to the button
            creditsButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
            {
                SoundManager.AddSound(mClickSound);
                // ScreenManager.Add(mScreamScreen);
                ScreenManager.Add(mCreditsScreen);
                IsVisible = false;
            });

            // Create Option button
            var optionsButton = new UIv2.Components.Button(mGraphicsDevice, 35, 64, 30, 7, texture2D, "Options", font, Color.White);

            optionsButton.AddTo(menu);
            // Add an event listener to the button
            optionsButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
            {
                SoundManager.AddSound(mClickSound);
                ScreenManager.Add(mOptionsScreen);
                IsVisible = false;
            });

            var editorButton = new UIv2.Components.Button(mGraphicsDevice, 35, 72, 30, 7, texture2D, "Editor", font, Color.White);

            editorButton.AddTo(menu);
            editorButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
            {
                SoundManager.AddSound(mClickSound);
                ScreenManager.Add(mEditorHudScreen);
                IsVisible = false;
            });

            var exitButton = new UIv2.Components.Button(mGraphicsDevice, 35, 80, 30, 7, texture2D, "Exit", font, Color.White);

            exitButton.AddTo(menu);
            exitButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
            {
                SoundManager.AddSound(mClickSound);
                ScreenManager.Remove(this);
            });
        }
        public void LoadContent(GraphicsDeviceManager deviceManager, ContentManager contentManager, int windowWidth, int windowHeight)
        {
            mScreenWidth  = windowWidth;
            mScreenHeight = windowHeight;

            //Load SoundEffects
            mClickSound = contentManager.Load <SoundEffect>("Audio/click2");

            Device       = deviceManager.GraphicsDevice;
            mSpriteBatch = new SpriteBatch(deviceManager.GraphicsDevice);

            mOptionsScreen = new OptionsMenu(true);

            // Unlock the framerate. Later we want to remove this piece of code
            mGraphicsDevice = deviceManager.GraphicsDevice;
            mSpriteBatch    = new SpriteBatch(deviceManager.GraphicsDevice);

            // Load font
            var font          = contentManager.Load <SpriteFont>("Font");
            var subHeaderFont = contentManager.Load <SpriteFont>("SubHeaderFont");

            IsVisible = true;

            // Load background image
            mBackgroundImageOptions = contentManager.Load <Texture2D>("forest");

            mMenuList = new List <UIv2.Menu>();

            var menu = new UIv2.Menu(mGraphicsDevice, 5, 5, 90, 90);

            menu.WithBackground(UIv2.Menu.CreateTexture2D(deviceManager.GraphicsDevice, 50, 30, pixel => new Color(0.0f, 0.0f, 0.0f, 0.2f)), 5, 5, 90, 90);
            mMenuList.Add(menu);

            Texture2D texture2D            = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.Black);
            Texture2D texture2DSliderPoint = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.White);

            var heading = new UIv2.Components.Label(mGraphicsDevice, 35, 5, 30, 15, "Pause", subHeaderFont, Color.White);

            heading.FontType = FontManager.FontType.Subheading;
            heading.AddTo(menu);

            // Create new Resume Button

            var resumeButton = new UIv2.Components.Button(mGraphicsDevice, 40, 20, 20, 7, texture2D, "Resume", font, Color.White);

            resumeButton.AddTo(menu);
            resumeButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
            {
                SoundManager.AddSound(mClickSound);
                mHudScreen.IsVisible = true;
                ScreenManager.Remove(this);
                IsVisible = false;
            });

            // Create new Save Button
            var saveButton = new UIv2.Components.Button(mGraphicsDevice, 40, 30, 20, 7, texture2D, "Save Game", font, Color.White);

            saveButton.AddTo(menu);
            saveButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
            {
                SoundManager.AddSound(mClickSound);

                var serializer = new XmlSerializer(typeof(Camera));

                Console.WriteLine("########################################################");
                Console.WriteLine("Saving Camera to " + GetSavedGamesPath() + "\\Camera.xml");
                Console.WriteLine("########################################################");


                using (Stream stream = new FileStream(GetSavedGamesPath() + "\\Camera.xml", FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    serializer.Serialize(stream, mHudScreen.mGameScreen.mCamera);
                    stream.Close();
                }

                serializer = new XmlSerializer(typeof(Level));

                Console.WriteLine("########################################################");
                Console.WriteLine("Saving Level to " + GetSavedGamesPath() + "\\Level.xml");
                Console.WriteLine("########################################################");



                using (Stream stream = new FileStream(GetSavedGamesPath() + "\\Level.xml", FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    serializer.Serialize(stream, mHudScreen.mGameScreen.mLevel);
                    stream.Close();
                }

                serializer = new XmlSerializer(typeof(HudScreen));

                Console.WriteLine("########################################################");
                Console.WriteLine("Saving Level to " + GetSavedGamesPath() + "\\HudScreen.xml");
                Console.WriteLine("########################################################");



                using (Stream stream = new FileStream(GetSavedGamesPath() + "\\HudScreen.xml", FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    serializer.Serialize(stream, mHudScreen);
                    stream.Close();
                }

                serializer = new XmlSerializer(typeof(Silverback));

                Console.WriteLine("########################################################");
                Console.WriteLine("Saving Level to " + GetSavedGamesPath() + "\\Silverback.xml");
                Console.WriteLine("########################################################");

                using (Stream stream = new FileStream(GetSavedGamesPath() + "\\Silverback.xml", FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    serializer.Serialize(stream, mHudScreen.mGameScreen.mLevel.mSilverback);
                    stream.Close();
                }


                serializer = new XmlSerializer(typeof(List <Matrix>));

                Console.WriteLine("########################################################");
                Console.WriteLine("Saving Level to " + GetSavedGamesPath() + "\\CapuchinPositions.xml");
                Console.WriteLine("########################################################");

                using (Stream stream = new FileStream(GetSavedGamesPath() + "\\CapuchinPositions.xml", FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    var toSerialize = new List <Matrix>();
                    mHudScreen.mGameScreen.mLevel.mCapuchinBatch.mActors.ForEach(actor => toSerialize.Add(actor.mModelMatrix));
                    serializer.Serialize(stream, toSerialize);
                    stream.Close();
                }

                Console.WriteLine("########################################################");
                Console.WriteLine("Saving Level to " + GetSavedGamesPath() + "\\GibbonPositions.xml");
                Console.WriteLine("########################################################");

                using (Stream stream = new FileStream(GetSavedGamesPath() + "\\GibbonPositions.xml", FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    var toSerialize = new List <Matrix>();
                    mHudScreen.mGameScreen.mLevel.mGibbonBatch.mActors.ForEach(actor => toSerialize.Add(actor.mModelMatrix));
                    serializer.Serialize(stream, toSerialize);
                    stream.Close();
                }

                Console.WriteLine("########################################################");
                Console.WriteLine("Saving Level to " + GetSavedGamesPath() + "\\OrangPositions.xml");
                Console.WriteLine("########################################################");

                using (Stream stream = new FileStream(GetSavedGamesPath() + "\\OrangPositions.xml", FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    var toSerialize = new List <Matrix>();
                    mHudScreen.mGameScreen.mLevel.mOrangutanBatch.mActors.ForEach(actor => toSerialize.Add(actor.mModelMatrix));
                    serializer.Serialize(stream, toSerialize);
                    stream.Close();
                }

                Console.WriteLine("########################################################");
                Console.WriteLine("Saving Level to " + GetSavedGamesPath() + "\\ChimpPositions.xml");
                Console.WriteLine("########################################################");

                using (Stream stream = new FileStream(GetSavedGamesPath() + "\\ChimpPositions.xml", FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    var toSerialize = new List <Matrix>();
                    mHudScreen.mGameScreen.mLevel.mChimpanezzeBatch.mActors.ForEach(actor => toSerialize.Add(actor.mModelMatrix));
                    serializer.Serialize(stream, toSerialize);
                    stream.Close();
                }

                Console.WriteLine("########################################################");
                Console.WriteLine("Saving Level to " + GetSavedGamesPath() + "\\Huts.xml");
                Console.WriteLine("########################################################");

                serializer = new XmlSerializer(typeof(List <Hut>));

                using (Stream stream = new FileStream(GetSavedGamesPath() + "\\Huts.xml", FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    var toSerialize   = new List <Hut>();
                    var hutActorBatch = mHudScreen.mGameScreen.mLevel.mActorBatches.Find(ele =>
                                                                                         ele.mMesh == mHudScreen.mGameScreen.mLevel.mHutMesh);
                    mHudScreen.mGameScreen.mLevel.mHuts.ForEach(hut => toSerialize.Add(hut));
                    serializer.Serialize(stream, toSerialize);
                    stream.Close();
                }
            });

            // Error label | Savegame
            var errLabel = new UIv2.Components.Label(mGraphicsDevice, 10, 90, 80, 4, "Could not load the savegame", font, Color.White);

            errLabel.FontType = FontManager.FontType.Default;
            errLabel.SetVisibility(false);
            errLabel.AddTo(menu);

            // Create new Load Game Button
            var loadButton = new UIv2.Components.Button(mGraphicsDevice, 40, 40, 20, 7, texture2D, "Load Checkpoint", font, Color.White);

            loadButton.AddTo(menu);
            loadButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
            {
                if (!File.Exists(PauseScreen.GetSavedGamesPath() + "\\Camera.xml") ||
                    !File.Exists(PauseScreen.GetSavedGamesPath() + "\\CapuchinPositions.xml") ||
                    !File.Exists(PauseScreen.GetSavedGamesPath() + "\\ChimpPositions.xml") ||
                    !File.Exists(PauseScreen.GetSavedGamesPath() + "\\GibbonPositions.xml") ||
                    !File.Exists(PauseScreen.GetSavedGamesPath() + "\\HudScreen.xml") ||
                    !File.Exists(PauseScreen.GetSavedGamesPath() + "\\Huts.xml") ||
                    !File.Exists(PauseScreen.GetSavedGamesPath() + "\\Level.xml") ||
                    !File.Exists(PauseScreen.GetSavedGamesPath() + "\\OrangPositions.xml") ||
                    !File.Exists(PauseScreen.GetSavedGamesPath() + "\\Silverback.xml"))
                {
                    errLabel.SetVisibility(true);
                    return;
                }
                errLabel.SetVisibility(false);
                ScreenManager.Remove(this);
                ScreenManager.Remove(mHudScreen.mGameScreen);
                ScreenManager.Remove(mHudScreen);

                var loadingScreen = new LoadingScreen(mHudScreen.mLevelPath);
                loadingScreen.LoadSaveGame();
                ScreenManager.Add(loadingScreen);
            });

            // Create new Options Button
            var optionsButton = new UIv2.Components.Button(mGraphicsDevice, 40, 50, 20, 7, texture2D, "Options", font, Color.White);

            optionsButton.AddTo(menu);
            optionsButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
            {
                SoundManager.AddSound(mClickSound);
                ScreenManager.Add(mOptionsScreen);
                IsVisible = false;
            });

            // Create new Back Button
            var backButton = new UIv2.Components.Button(mGraphicsDevice, 40, 60, 20, 7, texture2D, "Main Menu", font, Color.White);

            backButton.AddTo(menu);
            backButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
            {
                SoundManager.AddSound(mClickSound);
                ScreenManager.Remove(mHudScreen);
                ScreenManager.Remove(this);
                IsVisible = false;
            });
        }
        public void LoadContent(GraphicsDeviceManager deviceManager,
                                ContentManager contentManager,
                                int windowWidth,
                                int windowHeight)
        {
            mScreenWidth  = windowWidth;
            mScreenHeight = windowHeight;

            //Load SoundEffects
            mClickSound = contentManager.Load <SoundEffect>("Audio/click2");

            mGraphicsDevice = deviceManager.GraphicsDevice;

            mPauseScreen = new PauseScreen(this);

            mWinScreen  = new WinScreen(this);
            mLoseScreen = new LoseScreen(this);

            mGameScreen = new GameScreen(mLevelPath);
            ScreenManager.Add(mGameScreen);
            mTotalCunter = mGameScreen.mLevel.mSpawnablePrimatesCount;

            mSpriteBatch = new SpriteBatch(mGraphicsDevice);

            // Load font
            var font          = contentManager.Load <SpriteFont>("Font");
            var subHeaderFont = contentManager.Load <SpriteFont>("SubHeaderFont");

            IsVisible = true;

            // Instantiate a new menu
            mMenuList = new List <UIv2.Menu>();

            mButtonTexture = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.Black);
            var textureTransparent = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 10, 10, pixel => Color.Transparent);

            //Highlighted Button
            mHighlightedButtonTexture = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.Orange);

            var menu = new UIv2.Menu(mGraphicsDevice, 0, 95, 100, 5);

            menu.WithBackground(UIv2.Menu.CreateTexture2D(deviceManager.GraphicsDevice,
                                                          windowWidth,
                                                          200,
                                                          pixel => new Color(0.0f, 0.0f, 0.0f, 0.15f)),
                                0,
                                0,
                                100,
                                100);
            mMenuList.Add(menu);

            mCounterMenu = new UIv2.Menu(mGraphicsDevice, 40, 15, 20, 4);
            mCounterMenu.WithBackground(UIv2.Menu.CreateTexture2D(deviceManager.GraphicsDevice,
                                                                  windowWidth,
                                                                  200,
                                                                  pixel => new Color(0.0f, 0.0f, 0.0f, 0.15f)),
                                        0,
                                        0,
                                        100,
                                        100);
            mCounterMenu.NonSolid();
            mMenuList.Add(mCounterMenu);

            var counterLabel = new UIv2.Components.Label(mGraphicsDevice, 0, 0, 100, 100, "Available apes to spawn: " + mGameScreen.mLevel.mSpawnablePrimatesCount, font, Color.White);

            counterLabel.AddTo(mCounterMenu);

            var pauseButton =
                new UIv2.Components.Button(mGraphicsDevice, 90, 0, 7, 100, mButtonTexture, "Pause", font, Color.White);

            pauseButton.AddTo(menu);
            pauseButton.AddListener(MouseButtons.Left,
                                    InputState.Pressed,
                                    () =>
            {
                SoundManager.AddSound(mClickSound);
                ScreenManager.Add(mPauseScreen);
                mGameScreen.mCameraHandler.Lock();
                IsVisible             = false;
                mWasVisible           = false;
                mGameScreen.IsVisible = false;
            });

            mHPLabel = new UIv2.Components.Label(mGraphicsDevice,
                                                 0,
                                                 0,
                                                 45,
                                                 100,
                                                 "HP: ",
                                                 font,
                                                 Color.White);
            mHPLabel.AddTo(menu);

            mTimeLabel = new UIv2.Components.Label(mGraphicsDevice,
                                                   0,
                                                   0,
                                                   10,
                                                   100,
                                                   "",
                                                   font,
                                                   Color.White);
            mTimeLabel.AddTo(menu);

            var levelLabel = new UIv2.Components.Label(mGraphicsDevice,
                                                       10,
                                                       0,
                                                       7,
                                                       100,
                                                       "Level: Tutorial",
                                                       font,
                                                       Color.White);

            levelLabel.AddTo(menu);
            for (var i = 0; i < 0; i++)
            {
                var morang = new OrangUtan(mGameScreen.mLevel.mOrangUtanMesh,
                                           mGameScreen.mLevel.mTerrain,
                                           mGameScreen.mLevel.mSilverback,
                                           mGameScreen.mLevel,
                                           ref mRandom);
                //morang.mScene = mGameScreen.mLevel;
                mGameScreen.mLevel.Add(morang);
            }

            // Create selection button for Baboon
            mApe1Button =
                new UIv2.Components.Button(mGraphicsDevice, 30, 0, 7, 100, mButtonTexture, "Orang", font, Color.White);
            mApe1Button.AddTo(menu);
            mApe1Button.AddListener(MouseButtons.Left,
                                    InputState.Pressed,
                                    () =>
            {
                SoundManager.AddSound(mClickSound);

                if (mGameScreen.mLevel.mSpawnablePrimatesCount == 0)
                {
                    if (mGameScreen.mLevel.mOrangutanBatch.mActors.Count > 0)
                    {
                        UnHiglightSelectedActorBatch();
                        mActorBatch      = mGameScreen.mLevel.mOrangutanBatch;
                        mHighlitedButton = mApe1Button;
                        HighlightSelectedActorBatch();
                    }
                }
                else if (mGameScreen.mLevel.mSpawnablePrimatesCount > 0)
                {
                    mGameScreen.mLevel.mSpawnablePrimatesCount--;
                    mOrangCounter++;
                    counterLabel.Text = "Available apes to spawn: " + mGameScreen.mLevel.mSpawnablePrimatesCount;

                    var morang = new OrangUtan(mGameScreen.mLevel.mOrangUtanMesh,
                                               mGameScreen.mLevel.mTerrain,
                                               mGameScreen.mLevel.mSilverback,
                                               mGameScreen.mLevel,
                                               ref mRandom);
                    //morang.mScene = mGameScreen.mLevel;
                    mGameScreen.mLevel.Add(morang);
                    LumberChoice.AddApe(2);
                }

                if (mGameScreen.mLevel.mSpawnablePrimatesCount == 0)
                {
                    mCounterMenu.mIsVisible = false;
                    DisableUnusedApeSelectorButtons();
                }
            });

            // Create selection button for Capuchin
            mApe2Button = new UIv2.Components.Button(mGraphicsDevice,
                                                     41,
                                                     0,
                                                     7,
                                                     100,
                                                     mButtonTexture,
                                                     "Capuchin",
                                                     font,
                                                     Color.White);
            mApe2Button.AddTo(menu);
            mApe2Button.AddListener(MouseButtons.Left,
                                    InputState.Pressed,
                                    () =>
            {
                SoundManager.AddSound(mClickSound);

                if (mGameScreen.mLevel.mSpawnablePrimatesCount == 0)
                {
                    if (mGameScreen.mLevel.mCapuchinBatch.mActors.Count > 0)
                    {
                        UnHiglightSelectedActorBatch();
                        mActorBatch      = mGameScreen.mLevel.mCapuchinBatch;
                        mHighlitedButton = mApe2Button;
                        HighlightSelectedActorBatch();
                    }
                }
                else if (mGameScreen.mLevel.mSpawnablePrimatesCount > 0)
                {
                    mCapuchinCounter++;
                    counterLabel.Text = "Available apes to spawn: " + mGameScreen.mLevel.mSpawnablePrimatesCount;
                    mGameScreen.mLevel.mSpawnablePrimatesCount--;
                    var mcapuchin = new Capuchin(mGameScreen.mLevel.mCapuchinMesh,
                                                 mGameScreen.mLevel.mTerrain,
                                                 mGameScreen.mLevel.mSilverback,
                                                 mGameScreen.mLevel,
                                                 ref mRandom);
                    mGameScreen.mLevel.Add(mcapuchin);
                    LumberChoice.AddApe(3);
                }

                if (mGameScreen.mLevel.mSpawnablePrimatesCount == 0)
                {
                    mCounterMenu.mIsVisible = false;
                    DisableUnusedApeSelectorButtons();
                }
            });

            // Create selection button for Chimpaneeze
            mApe3Button =
                new UIv2.Components.Button(mGraphicsDevice, 52, 0, 7, 100, mButtonTexture, "Chimp", font, Color.White);
            mApe3Button.AddTo(menu);

            mApe3Button.AddListener(MouseButtons.Left,
                                    InputState.Pressed,
                                    () =>
            {
                SoundManager.AddSound(mClickSound);

                if (mGameScreen.mLevel.mSpawnablePrimatesCount == 0)
                {
                    if (mGameScreen.mLevel.mChimpanezzeBatch.mActors.Count > 0)
                    {
                        UnHiglightSelectedActorBatch();
                        mActorBatch      = mGameScreen.mLevel.mChimpanezzeBatch;
                        mHighlitedButton = mApe3Button;
                        HighlightSelectedActorBatch();
                    }
                }
                else if (mGameScreen.mLevel.mSpawnablePrimatesCount > 0)
                {
                    mChimpCounter++;
                    mGameScreen.mLevel.mSpawnablePrimatesCount--;
                    counterLabel.Text = "Available apes to spawn: " + mGameScreen.mLevel.mSpawnablePrimatesCount;
                    var mchimpanezee  = new Chimpanezee(mGameScreen.mLevel.mChimpanezzeMesh,
                                                        mGameScreen.mLevel.mTerrain,
                                                        mGameScreen.mLevel.mSilverback,
                                                        mGameScreen.mLevel,
                                                        ref mRandom);
                    mGameScreen.mLevel.Add(mchimpanezee);
                    LumberChoice.AddApe(1);
                }

                if (mGameScreen.mLevel.mSpawnablePrimatesCount == 0)
                {
                    mCounterMenu.mIsVisible = false;
                    DisableUnusedApeSelectorButtons();
                }
            }
                                    );

            // Create selection button for Gibbon
            mApe4Button =
                new UIv2.Components.Button(mGraphicsDevice, 63, 0, 7, 100, mButtonTexture, "Gibbon", font, Color.White);
            mApe4Button.AddTo(menu);
            mApe4Button.AddListener(MouseButtons.Left,
                                    InputState.Pressed,
                                    () =>
            {
                SoundManager.AddSound(mClickSound);

                if (mGameScreen.mLevel.mSpawnablePrimatesCount == 0)
                {
                    if (mGameScreen.mLevel.mGibbonBatch.mActors.Count > 0)
                    {
                        UnHiglightSelectedActorBatch();
                        mActorBatch      = mGameScreen.mLevel.mGibbonBatch;
                        mHighlitedButton = mApe4Button;
                        HighlightSelectedActorBatch();
                    }
                }
                else if (mGameScreen.mLevel.mSpawnablePrimatesCount > 0)
                {
                    mGibbonCounter++;
                    mGameScreen.mLevel.mSpawnablePrimatesCount--;
                    counterLabel.Text = "Available apes to spawn: " + mGameScreen.mLevel.mSpawnablePrimatesCount;

                    var mgibbon = new Gibbon(mGameScreen.mLevel.mGibbonMesh,
                                             mGameScreen.mLevel.mTerrain,
                                             mGameScreen.mLevel.mSilverback,
                                             mGameScreen.mLevel,
                                             ref mRandom);
                    mGameScreen.mLevel.Add(mgibbon);
                    LumberChoice.AddApe(4);
                }

                if (mGameScreen.mLevel.mSpawnablePrimatesCount == 0)
                {
                    mCounterMenu.mIsVisible = false;
                    DisableUnusedApeSelectorButtons();
                }
            });

            // Display the level text before the level starts
            if (mGameScreen.mLevel.mLevelStory != null)
            {
                mGameScreen.mCameraHandler.Lock();
                var textMenu = new UIv2.Menu(mGraphicsDevice, 5, 5, 90, 90);
                textMenu.WithBackground(UIv2.Menu.CreateTexture2D(deviceManager.GraphicsDevice, 50, 30, pixel => new Color(0.0f, 0.0f, 0.0f, 0.15f)), 5, 5, 90, 90);
                var heading = new UIv2.Components.Label(mGraphicsDevice, 5, 5, 90, 15, mGameScreen.mLevel.mLevelTitle, subHeaderFont, Color.DarkSlateGray);
                heading.FontType = FontManager.FontType.Subheading;
                heading.AddTo(textMenu);
                var textLabel = new UIv2.Components.Label(mGraphicsDevice, 25, 28, 50, 35, mGameScreen.mLevel.mLevelStory, font, Color.White);
                textLabel.DisableAutobreak();
                textLabel.AddTo(textMenu);
                mContinueLabel = new UIv2.Components.Label(mGraphicsDevice, 25, 80, 50, 10, "Press the left mouse button to continue", font, Color.White);
                mContinueLabel.AddTo(textMenu);
                var textButton = new UIv2.Components.Button(mGraphicsDevice, 0, 0, 100, 100, textureTransparent, "", font, Color.White);
                textButton.AddTo(textMenu);
                textButton.AddListener(MouseButtons.Left,
                                       InputState.Pressed,
                                       () =>
                {
                    menu.mIsVisible         = true;
                    mCounterMenu.mIsVisible = true;
                    textMenu.mIsVisible     = false;
                    mGameScreen.mCameraHandler.Unlock();
                });
                mMenuList.Add(textMenu);
                menu.mIsVisible         = false;
                mCounterMenu.mIsVisible = false;
            }

            mMenuList.Add(menu);
        }
        public void Update(GameTime time)
        {
            if (IsVisible && !mWasVisible)
            {
                mWasVisible = true;
                mGameScreen.mCameraHandler.Unlock();
            }

            if (mGameScreen.IsVisible)
            {
                IsVisible = true;
            }

            if (mHudStartTime == 0)
            {
                mHudStartTime = time.TotalGameTime.TotalMilliseconds;
            }

            var hudTime  = time.TotalGameTime.TotalMilliseconds - mHudStartTime;
            var timeSpan = TimeSpan.FromMilliseconds(hudTime);

            mTimeLabel.Text = "Time: " + timeSpan.Minutes + ":" + timeSpan.Seconds;

            if (mGameScreen.mLevel.mLevelStory != null)
            {
                mContinueLabel.mTextColor = Color.White *
                                            (float)(Math.Sin(time.TotalGameTime.TotalMilliseconds / 200.0f) * 0.5f +
                                                    0.5f);
            }

            if (mGameScreen.mLevel.mSilverback != null)
            {
                mHPLabel.Text = "HP: " + mGameScreen.mLevel.mSilverback.HP.ToString() + " / " + mGameScreen.mLevel.mSilverback.mMaxHP.ToString();
            }

            DisableUnusedApeSelectorButtons();

            // Iterate over all Menu elements
            foreach (var menu in mMenuList)
            {
                if (!menu.mIsVisible)
                {
                    continue;
                }
                menu.CheckRegisteredEvents();
            }

            if (mActorBatch != null && InputManager.MouseRightButtonPressed())
            {
                var raycast = RayCasting.CalculateMouseRayTerrainIntersection(mGameScreen.mViewport, mGameScreen.mCamera, mGameScreen.mLevel.mTerrain);

                if (!raycast.mIntersected)
                {
                    return;
                }

                foreach (var actor in mActorBatch.mActors)
                {
                    var movable = (IMoveable)actor.IActor;
                    movable.SetTarget(raycast.mLocation);
                }
            }

            if (mGameScreen.mLevel.mSilverback.HP <= 0)
            {
                ScreenManager.Remove(this);
                ScreenManager.Add(mLoseScreen);
                Statistic.Lost++;
            }

            if (mGameScreen.mLevel.mHuts.Count == 0)
            {
                ScreenManager.Remove(this);
                ScreenManager.Add(mWinScreen);
                Statistic.Win++;
            }
        }
Exemple #7
0
        public void LoadContent(GraphicsDeviceManager deviceManager, ContentManager contentManager, int windowWidth, int windowHeight)
        {
            mScreenWidth  = windowWidth;
            mScreenHeight = windowHeight;

            //Load SoundEffects
            mClickSound = contentManager.Load <SoundEffect>("Audio/click2");

            Device       = deviceManager.GraphicsDevice;
            mSpriteBatch = new SpriteBatch(deviceManager.GraphicsDevice);

            // Unlock the framerate. Later we want to remove this piece of code
            mGraphicsDevice = deviceManager.GraphicsDevice;
            mSpriteBatch    = new SpriteBatch(deviceManager.GraphicsDevice);

            // Load font
            var font       = contentManager.Load <SpriteFont>("Font");
            var headerFont = contentManager.Load <SpriteFont>("Heading");

            IsVisible = true;

            // Load background image
            mBackgroundImage = contentManager.Load <Texture2D>("Forest");

            mMenuList = new List <UIv2.Menu>();
            var menu = new UIv2.Menu(mGraphicsDevice, 5, 5, 90, 90);

            menu.WithBackground(UIv2.Menu.CreateTexture2D(deviceManager.GraphicsDevice, 50, 30, pixel => new Color(0.0f, 0.0f, 0.0f, 0.2f)), 5, 5, 90, 90);
            mMenuList.Add(menu);

            Texture2D texture2D            = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.Black);
            Texture2D texture2DSliderPoint = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.White);

            // Congratulations!
            var congratz = new UIv2.Components.Label(mGraphicsDevice, 10, 0, 80, 30, "Congratulations!", headerFont, Color.DarkSlateGray);

            congratz.FontType = FontManager.FontType.Heading;
            congratz.AddTo(menu);

            // You've won
            var win = new UIv2.Components.Label(mGraphicsDevice, 10, 30, 80, 30, "You've won", headerFont, Color.DarkSlateGray);

            win.FontType = FontManager.FontType.Heading;
            win.AddTo(menu);

            var winString = "Nice work dude!";
            var winLabel  = new UIv2.Components.Label(mGraphicsDevice, 20, 60, 60, 10, winString, font, Color.White);

            winLabel.AddTo(menu);

            if (mHudScreen.mGameScreen.mLevel.mNextLevelFilename != "null")
            {
                var nextLevelButton = new UIv2.Components.Button(mGraphicsDevice, 40, 70, 20, 7, texture2D, "Next level", font, Color.White);
                nextLevelButton.AddTo(menu);
                nextLevelButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
                {
                    var nextLevelFilename = mHudScreen.mGameScreen.mLevel.mNextLevelFilename;
                    // Check if path is relative
                    if (!Path.IsPathRooted(nextLevelFilename))
                    {
                        var levelFilename = mHudScreen.mGameScreen.mLevel.mLevelFilename;
                        var directoryPath = Path.GetDirectoryName(levelFilename);
                        nextLevelFilename = directoryPath + "/" + nextLevelFilename;
                    }
                    SoundManager.AddSound(mClickSound);
                    ScreenManager.Remove(this);
                    IsVisible         = false;
                    var loadingScreen = new LoadingScreen(nextLevelFilename);
                    ScreenManager.Add(loadingScreen);
                });
            }
            else
            {
                winLabel.Text += " You've finished the game.";
                if (Statistic.CurrentSaveTime < Statistic.MinimalTime || Statistic.MinimalTime == 0)
                {
                    Statistic.MinimalTime   = Statistic.CurrentSaveTime;
                    Achievements.Gamemaster = true;
                    if (Statistic.MinimalTime < 3600000)
                    {
                        Achievements.Speedrunner = true;
                    }
                }
            }

            // Create Main Menu Button (Back Button)
            var backButton = new UIv2.Components.Button(mGraphicsDevice, 40, 80, 20, 7, texture2D, "Main menu", font, Color.White);

            backButton.AddTo(menu);
            backButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
            {
                SoundManager.AddSound(mClickSound);
                ScreenManager.Remove(this);
                IsVisible = false;
            });
        }
        public void LoadContent(GraphicsDeviceManager deviceManager, ContentManager contentManager, int windowWidth, int windowHeight)
        {
            mScreenWidth  = windowWidth;
            mScreenHeight = windowHeight;

            //Load SoundEffects
            mClickSound = contentManager.Load <SoundEffect>("Audio/click2");

            // Unlock the framerate. Later we want to remove this piece of code
            mGraphicsDevice = deviceManager.GraphicsDevice;
            mSpriteBatch    = new SpriteBatch(deviceManager.GraphicsDevice);

            // Load font
            var font          = contentManager.Load <SpriteFont>("Font");
            var subHeaderFont = contentManager.Load <SpriteFont>("SubHeaderFont");

            IsVisible = true;

            // Load backround Image
            mBackgroundImageOptions = contentManager.Load <Texture2D>("forest");

            mMenuList = new List <UIv2.Menu>();

            var menu = new UIv2.Menu(mGraphicsDevice, 5, 5, 90, 90);

            menu.WithBackground(UIv2.Menu.CreateTexture2D(deviceManager.GraphicsDevice, 50, 30, pixel => new Color(0.0f, 0.0f, 0.0f, 0.2f)), 5, 5, 90, 90);
            mMenuList.Add(menu);

            Texture2D Checked              = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.DarkOliveGreen);
            Texture2D texture2D            = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.Black);
            Texture2D texture2DSliderPoint = UIv2.Menu.CreateTexture2D(mGraphicsDevice, 200, 30, pixel => Color.White);

            var heading = new Label(mGraphicsDevice, 35, 5, 30, 15, "Options", subHeaderFont, Color.White);

            heading.FontType = FontManager.FontType.Subheading;
            heading.AddTo(menu);


            var resolutionLabel = new Label(mGraphicsDevice, 10, 20, 30, 3, "Resolution", font, Color.White);

            resolutionLabel.AddTo(menu);
            var resolutionValueBox = new Label(mGraphicsDevice, 60, 20, 20, 3, "", font, Color.White);

            resolutionValueBox.AddTo(menu);
            var resolutionSlider = new UIv2.Components.Slider(mGraphicsDevice, menu, 40, 20, 20, 3, texture2D, texture2DSliderPoint, 25, 200, Options.Resolution);


            // We want to allow the user to set the resolution to 25%.
            // Lets assume the user has a 4K monitor then we would allow
            // a resolution range of [1024x540-8192x4320]. The higher resolution
            // is for PCs which have a lot of hardware power and will be used for super sampling
            // which gives us really clean edges (no FXAA needed anymore)

            // You can manually set the slider value
            // The ui will be updated accordingly

            // Add one or more callbacks as arguments
            // The function(s) will be called, after the value changed
            resolutionSlider.AddOnChangeListeners((val) => {
                var value  = (int)Math.Round(val);
                var width  = (int)(mScreenWidth * (value / 100.0f));
                var height = (int)(mScreenHeight * (value / 100.0f));
                resolutionValueBox.Text = width + "x" + height + " pixel";
                ScreenManager.ChangeRenderingResolution(width, height);
                Options.Resolution = value;
            });

            var musicLabel = new Label(mGraphicsDevice, 10, 28, 30, 3, "Music Volume", font, Color.White);

            musicLabel.AddTo(menu);
            var musicValueBox = new Label(mGraphicsDevice, 60, 28, 20, 3, "", font, Color.White);

            musicValueBox.AddTo(menu);

            var musicSlider = new UIv2.Components.Slider(mGraphicsDevice, menu, 40, 28, 20, 3, texture2D, texture2DSliderPoint, 0, 100, Options.MusicVolume);

            musicSlider.AddOnChangeListeners((val) => {
                var value           = (int)Math.Round(val);
                Options.MusicVolume = value;
                musicValueBox.Text  = value + "%";
                //Soundmanager has to be set
                //SoundManager.ChangeVolume("Music", value / 100.0f);
            });


            var effectLabel = new Label(mGraphicsDevice, 10, 36, 30, 3, "Sound Effects Volume", font, Color.White);

            effectLabel.AddTo(menu);
            var effectValueBox = new Label(mGraphicsDevice, 60, 36, 20, 3, "", font, Color.White);

            effectValueBox.AddTo(menu);

            var effectSlider = new UIv2.Components.Slider(mGraphicsDevice, menu, 40, 36, 20, 3, texture2D, texture2DSliderPoint, 0, 100, Options.SoundEffectVolume);

            effectSlider.AddOnChangeListeners((val) => {
                var value = (int)Math.Round(val);
                Options.SoundEffectVolume = value;
                effectValueBox.Text       = value + "%";
            });

            /*
             * // TODO adding function of brightness
             * var brightnessLabel = new Label(mGraphicsDevice, 10, 44, 30, 3, "Brightness", font, Color.White);
             * brightnessLabel.AddTo(menu);
             * var brightnessValueBox = new Label(mGraphicsDevice, 60, 44, 20, 3, "", font, Color.White);
             * brightnessValueBox.AddTo(menu);
             *
             * var brightnessSlider = new UIv2.Components.Slider(mGraphicsDevice, menu, 40, 44, 20, 3, texture2D, texture2DSliderPoint, 0, 1, Options.Brightness);
             *
             * brightnessSlider.AddOnChangeListeners((val) => {
             *  var value = (int)Math.Round(val * 100); // here I'm unsure
             *  Options.Brightness = val;
             *  brightnessValueBox.Text = value + "%";
             * });
             */


            var fxaaLabel = new Label(mGraphicsDevice, 10, 44, 30, 3, "Antialiasing", font, Color.White);

            fxaaLabel.AddTo(menu);
            var fxaaButtonOn = new UIv2.Components.CheckedButton(mGraphicsDevice, 40, 44, 5, 5, texture2D, Checked, "On", font, Color.White, Options.Fxaa);

            fxaaButtonOn.AddTo(menu);
            var fxaaButtonOff = new UIv2.Components.CheckedButton(mGraphicsDevice, 46, 44, 5, 5, texture2D, Checked, "Off", font, Color.White, !Options.Fxaa);

            fxaaButtonOff.AddTo(menu);

            if (!mPauseScreen)
            {
                fxaaButtonOn.AddListener(MouseButtons.Left,
                                         InputState.Pressed,
                                         () =>
                {
                    SoundManager.AddSound(mClickSound);
                    fxaaButtonOn.Check();
                    fxaaButtonOff.Uncheck();
                    Options.Fxaa = true;
                });
                fxaaButtonOff.AddListener(MouseButtons.Left,
                                          InputState.Pressed,
                                          () =>
                {
                    SoundManager.AddSound(mClickSound);
                    fxaaButtonOff.Check();
                    fxaaButtonOn.Uncheck();
                    Options.Fxaa = false;
                });
            }

            var graphicsLabel = new Label(mGraphicsDevice, 10, 52, 30, 3, "Graphics Quality", font, Color.White);

            graphicsLabel.AddTo(menu);


            var graphicsVeryLowButton = new UIv2.Components.CheckedButton(mGraphicsDevice, 40, 52, 8, 5, texture2D, Checked, "Very low", font, Color.White, Options.GraphicsQuality == 0);

            graphicsVeryLowButton.AddTo(menu);
            var graphicsLowButton = new UIv2.Components.CheckedButton(mGraphicsDevice, 49, 52, 8, 5, texture2D, Checked, "Low", font, Color.White, Options.GraphicsQuality == 1);

            graphicsLowButton.AddTo(menu);
            var graphicsMediumButton = new UIv2.Components.CheckedButton(mGraphicsDevice, 58, 52, 8, 5, texture2D, Checked, "Medium", font, Color.White, Options.GraphicsQuality == 2);

            graphicsMediumButton.AddTo(menu);
            var graphicsHighButton = new UIv2.Components.CheckedButton(mGraphicsDevice, 67, 52, 8, 5, texture2D, Checked, "High", font, Color.White, Options.GraphicsQuality == 3);

            graphicsHighButton.AddTo(menu);
            var graphicsVeryHighButton = new UIv2.Components.CheckedButton(mGraphicsDevice, 76, 52, 8, 5, texture2D, Checked, "Very high", font, Color.White, Options.GraphicsQuality == 4);

            graphicsVeryHighButton.AddTo(menu);

            // We just want to use the handlers if this screen isn't initialized by the PauseScreen
            if (!mPauseScreen)
            {
                graphicsVeryLowButton.AddListener(MouseButtons.Left,
                                                  InputState.Pressed,
                                                  () =>
                {
                    SoundManager.AddSound(mClickSound);
                    graphicsVeryLowButton.Check();
                    graphicsLowButton.Uncheck();
                    graphicsMediumButton.Uncheck();
                    graphicsHighButton.Uncheck();
                    graphicsVeryHighButton.Uncheck();
                    Options.GraphicsQuality = 0;
                });

                graphicsLowButton.AddListener(MouseButtons.Left,
                                              InputState.Pressed,
                                              () =>
                {
                    SoundManager.AddSound(mClickSound);
                    graphicsVeryLowButton.Uncheck();
                    graphicsLowButton.Check();
                    graphicsMediumButton.Uncheck();
                    graphicsHighButton.Uncheck();
                    graphicsVeryHighButton.Uncheck();
                    Options.GraphicsQuality = 1;
                });

                graphicsMediumButton.AddListener(MouseButtons.Left,
                                                 InputState.Pressed,
                                                 () =>
                {
                    SoundManager.AddSound(mClickSound);
                    graphicsVeryLowButton.Uncheck();
                    graphicsLowButton.Uncheck();
                    graphicsMediumButton.Check();
                    graphicsHighButton.Uncheck();
                    graphicsVeryHighButton.Uncheck();
                    Options.GraphicsQuality = 2;
                });

                graphicsHighButton.AddListener(MouseButtons.Left,
                                               InputState.Pressed,
                                               () =>
                {
                    SoundManager.AddSound(mClickSound);
                    graphicsVeryLowButton.Uncheck();
                    graphicsLowButton.Uncheck();
                    graphicsMediumButton.Uncheck();
                    graphicsHighButton.Check();
                    graphicsVeryHighButton.Uncheck();
                    Options.GraphicsQuality = 3;
                });

                graphicsVeryHighButton.AddListener(MouseButtons.Left,
                                                   InputState.Pressed,
                                                   () =>
                {
                    SoundManager.AddSound(mClickSound);
                    graphicsVeryLowButton.Uncheck();
                    graphicsLowButton.Uncheck();
                    graphicsMediumButton.Uncheck();
                    graphicsHighButton.Uncheck();
                    graphicsVeryHighButton.Check();
                    Options.GraphicsQuality = 4;
                });
            }
            else
            {
                var graphicsInformationLabel = new Label(mGraphicsDevice,
                                                         20,
                                                         65,
                                                         60,
                                                         10,
                                                         "Graphics quality and Antialiasing can only be changed from the main menu",
                                                         font,
                                                         Color.Orange);
                graphicsInformationLabel.AddTo(menu);
            }


            var backButton = new UIv2.Components.Button(mGraphicsDevice, 40, 80, 20, 7, texture2D, "Back", font, Color.White);

            backButton.AddTo(menu);
            backButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
            {
                SoundManager.AddSound(mClickSound);
                ScreenManager.Remove(this);
                IsVisible = false;
            });
            var techDemoButton = new UIv2.Components.Button(mGraphicsDevice, 70, 80, 20, 7, texture2D, "Techdemo", font, Color.White);

            techDemoButton.AddTo(menu);
            techDemoButton.AddListener(MouseButtons.Left, InputState.Pressed, () =>
            {
                var techDemoScreen = new TechDemoScreen();
                ScreenManager.Add(techDemoScreen);
                IsVisible = false;
            });
        }