Inheritance: UIElement
Example #1
0
        /// <summary>
        /// A text displayed if the player died
        /// </summary>
        /// <param name="message"></param>
        /// <param name="title"></param>
        private void _ShowEndGame(string message = "You have failed in your mission. Better luck next time.", string title = "Game over!")
        {
            if (_focus is Window)
            {
                _focus.Dispose();
                _interfaceElements.Remove(_focus);
                _toolbar.HandleEvent(true, Backend.Events.ContinueGame, 13);
                _status = Backend.GameStatus.Running;
            }
            _status = Backend.GameStatus.GameOver;
            //            _logic.map.Save("savedroom" + _logic.map.id + ".xml");
            Rectangle rect = center(GraphicsDevice.Viewport.Bounds, 500, 150);
            Window _gameOver = new Window(this, _spriteBatch, Content, rect);
            Statusbox stat;
            rect = inner(rect);
            if (_logic is PureLogic)
            {
                _gameOver.AddChild(new Button(_gameOver, _spriteBatch, Content, new Rectangle(rect.Left, rect.Bottom - 40, 80, 32), "New Maps", (int)Backend.Buttons.NewMap));

                if (_logic.map.actors[_playerID].lives > 0)
                {
                    _gameOver.AddChild(new Button(_gameOver, _spriteBatch, Content, new Rectangle(rect.Left + 90, rect.Bottom - 40, 150, 32), "Respawn (" + _logic.map.actors[_playerID].lives.ToString() + " left)", (int)Backend.Buttons.Load));
                }
                bool hasSave = false;
                foreach (string dir in Directory.GetDirectories(".\\save"))
                {
                    string tmp = dir.ToLower().Trim();
                    if (tmp.Substring(tmp.LastIndexOf('\\') + 1) != "auto")
                    {
                        hasSave = true;
                        break;
                    }
                }
                if (hasSave)
                    _gameOver.AddChild(new Button(_gameOver, _spriteBatch, Content, new Rectangle(rect.Right - 215, rect.Bottom - 40, 65, 32), "Restore", (int)Backend.Buttons.Restore));
                _gameOver.AddChild(new Button(_gameOver, _spriteBatch, Content, new Rectangle(rect.Right - 140, rect.Bottom - 40, 65, 32), "Restart", (int)Backend.Buttons.Restart));
                _gameOver.AddChild(new Button(_gameOver, _spriteBatch, Content, new Rectangle(rect.Right - 65, rect.Bottom - 40, 65, 32), "Quit", (int)Backend.Buttons.Quit));
            }
            else
            {
                _gameOver.AddChild(new Button(_gameOver, _spriteBatch, Content, new Rectangle(rect.Left, rect.Bottom - 40, 80, 32), "Resurrect", (int)Backend.Buttons.Load));
                _gameOver.AddChild(new Button(_gameOver, _spriteBatch, Content, new Rectangle(rect.Right - 170, rect.Bottom - 40, 80, 32), "Disconnect", (int)Backend.Buttons.Connect));
                _gameOver.AddChild(new Button(_gameOver, _spriteBatch, Content, new Rectangle(rect.Right - 80, rect.Bottom - 40, 80, 32), "Quit", (int)Backend.Buttons.Quit));
            }
            _gameOver.AddChild(stat = new Statusbox(_gameOver, _spriteBatch, Content, center(rect, 450, 200, 0), false, true));
            stat.AddLine(title + "\n \n" + message);

            _interfaceElements.Add(_gameOver);
            _focus = _interfaceElements[_interfaceElements.Count - 1];
        }
Example #2
0
        /// <summary>
        /// Setup and display a window containing credits
        /// </summary>
        private void _ShowAbout()
        {
            if (_focus is Window)
            {
                _focus.Dispose();
                _interfaceElements.Remove(_focus);
                _toolbar.HandleEvent(true, Backend.Events.ContinueGame, 13);
                _status = Backend.GameStatus.Running;
            }
            _status = Backend.GameStatus.Paused;
            Rectangle rect = center(GraphicsDevice.Viewport.Bounds, 600, 300);
            Window _about = new Window(this, _spriteBatch, Content, rect);
            rect = inner(rect);
            _about.AddChild(new Button(_about, _spriteBatch, Content, new Rectangle(rect.Left + 45, rect.Bottom - 42, rect.Width - 90, 32), "Ok", (int)Backend.Buttons.Close));

            //  _mainMenu.AddChild(new ProgressBar(this, _spriteBatch, Content, new Rectangle((int)((GraphicsDevice.Viewport.Width - 160) / 2.0f), (int)(GraphicsDevice.Viewport.Height / 2.0f) + 80, 300, 30), ProgressStyle.Block,100,2));
            Statusbox stat;
            _about.AddChild(stat = new Statusbox(_about, _spriteBatch, Content, new Rectangle(rect.Left, rect.Top, rect.Width, rect.Height - 50), false, true));
            stat.AddLine("Dungeon Crawler 2013\n\n Developed by Group 22\n\n" +
                "*********************************\n\n" +
                "Music: Video Dungeon Crawl by Kevin MacLeod is licensed under a CC Attribution 3.0\n\n" +
                "http://incompetech.com/music/royalty-free/index.html?collection=029\n\n" +
                "Graphics: Tile Graphics by Reiner Prokein\n\n" +
                "http://www.reinerstilesets.de/de/lizenz/ ");
            _interfaceElements.Add(_about);
            _focus = _interfaceElements[_interfaceElements.Count - 1];

        }
Example #3
0
        /// <summary>
        /// Display Main Menu
        /// </summary>
        private void _ShowMenu()
        {
            _status = Backend.GameStatus.Paused;
            Rectangle rect = center(GraphicsDevice.Viewport.Bounds, 300, 300);
            Window _mainMenu = new Window(this, _spriteBatch, Content, rect);
            rect = inner(rect);
            if (!(_logic is NetLogic))
            {
                _mainMenu.AddChild(new Button(_mainMenu, _spriteBatch, Content, center(rect, 280, 32, 0), "Continue", (int)Backend.Buttons.Close));
                _mainMenu.AddChild(new Button(_mainMenu, _spriteBatch, Content, center(rect, 280, 32, 50), "Restart", (int)Backend.Buttons.Restart));

                _mainMenu.AddChild(new Button(_mainMenu, _spriteBatch, Content, center(rect, 280, 32, 90), "New Maps", (int)Backend.Buttons.NewMap));

                _mainMenu.AddChild(new Button(_mainMenu, _spriteBatch, Content, new Rectangle(rect.Left, rect.Top + 130, 135, 32), "Save", (int)Backend.Buttons.Save));
                bool hasSave = false;
                foreach (string dir in Directory.GetDirectories(".\\save"))
                {
                    string tmp = dir.ToLower().Trim();
                    if (tmp.Substring(tmp.LastIndexOf('\\') + 1) != "auto")
                    {
                        hasSave = true;
                        break;
                    }
                }
                if (hasSave)
                    _mainMenu.AddChild(new Button(_mainMenu, _spriteBatch, Content, new Rectangle(rect.Right - 135, rect.Top + 130, 135, 32), "Restore", (int)Backend.Buttons.Restore));
                /*
                            _mainMenu.AddChild(new Button(_mainMenu, _spriteBatch, Content, new Rectangle((int)((GraphicsDevice.Viewport.Width - 160) / 2.0f), (int)(GraphicsDevice.Viewport.Height / 2.0f) - 30, 140, 60), "Local", (int)Buttons.Local, !_lan));
                            */
            }
            _mainMenu.AddChild(new Button(_mainMenu, _spriteBatch, Content, center(rect, 280, 146, 170), "Multiplayer " + ((_logic is NetLogic) ? "(online)" : "(offline)"), (int)Backend.Buttons.LAN, _lan));
            /*
            _mainMenu.AddChild(new Button(_mainMenu, _spriteBatch, Content, new Rectangle((int)((GraphicsDevice.Viewport.Width - 160) / 2.0f), (int)(GraphicsDevice.Viewport.Height / 2.0f) + 40, 300, 60), "Settings", (int)Buttons.Settings));
*/

            _mainMenu.AddChild(new Button(_mainMenu, _spriteBatch, Content, center(rect, 280, 186, 210), "Credits", (int)Backend.Buttons.Credits));
            _mainMenu.AddChild(new Button(_mainMenu, _spriteBatch, Content, center(rect, 280, 226, 250), "Quit", (int)Backend.Buttons.Quit));

            //  _mainMenu.AddChild(new ProgressBar(this, _spriteBatch, Content, new Rectangle((int)((GraphicsDevice.Viewport.Width - 160) / 2.0f), (int)(GraphicsDevice.Viewport.Height / 2.0f) + 80, 300, 30), ProgressStyle.Block,100,2));



            _interfaceElements.Add(_mainMenu);
            _focus = _interfaceElements[_interfaceElements.Count - 1];
        }