Exemplo n.º 1
0
        /// <summary>
        /// Set up main menu
        /// </summary>
        private void SetupMenu()
        {
            uint screenSizeX = WinInstance.Size.X, screenSizeY = WinInstance.Size.Y;
            var  fillColor  = new Color(128, 128, 128);
            var  font       = AssetManager.LoadFont("OrangeJuice");
            var  resumeGame = new RectangleShape(new Vector2f(ButtonX, ButtonY))
            {
                FillColor = fillColor, Position = new Vector2f((screenSizeX / 2) - ButtonX / 2, screenSizeY - (ButtonY * 6))
            };
            var resumeGameText = new Text()
            {
                Position = new Vector2f(resumeGame.Position.X + 50, resumeGame.Position.Y + 10), DisplayedString = AssetManager.GetMessage("ResumeGame"), Color = Color.Black, Font = font, CharacterSize = 60
            };
            var saveGame = new RectangleShape(new Vector2f(ButtonX, ButtonY))
            {
                FillColor = fillColor, Position = new Vector2f((screenSizeX / 2) - ButtonX / 2, screenSizeY - (ButtonY * 4) - 40)
            };
            var saveGameText = new Text()
            {
                Position = new Vector2f(saveGame.Position.X + 14, saveGame.Position.Y + 10), DisplayedString = AssetManager.GetMessage("SaveGame"), Color = Color.Black, Font = font, CharacterSize = 60
            };
            var exit = new RectangleShape(new Vector2f(ButtonX, ButtonY))
            {
                FillColor = fillColor, Position = new Vector2f((screenSizeX / 2) - ButtonX / 2, screenSizeY - (ButtonY * 2) - 80)
            };
            var exitText = new Text()
            {
                Position = new Vector2f(exit.Position.X + 100, exit.Position.Y + 10), DisplayedString = AssetManager.GetMessage("Exit"), Color = Color.Black, Font = font, CharacterSize = 60
            };
            var pointerSpite = AssetManager.LoadSprite("OldTimeyPointer");
            var renderWindow = WinInstance;

            Pointer = new MenuPointer(ref renderWindow, pointerSpite);
            MenuItems.Add(new MenuItem(ref renderWindow, resumeGameText, resumeGame, ResumeGameFunc));
            MenuItems.Add(new MenuItem(ref renderWindow, saveGameText, saveGame, SaveGameFunc));
            MenuItems.Add(new MenuItem(ref renderWindow, exitText, exit, ExitGameFunc));
            Pointer.SetPosition(new Vector2f((resumeGame.Position.X - Pointer.Size.X / 2f), resumeGame.Position.Y));
            Pointer.SetScale(new Vector2f(0.5f, 0.5f));
            var vector2F = Pointer.GetPosition();

            if (vector2F != null)
            {
                _pointerPositions = new LinkedList <Vector2f>(new[]
                {
                    vector2F.Value,
                    new Vector2f((saveGame.Position.X - Pointer.Size.X / 2f), saveGame.Position.Y),
                    new Vector2f((exit.Position.X - Pointer.Size.X / 2f), exit.Position.Y)
                });
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Set up main menu
        /// </summary>
        private void SetupMenu()
        {
            uint screenSizeX = WinInstance.Size.X, screenSizeY = WinInstance.Size.Y;
            var  fillColor = new Color(128, 128, 128);
            var  font      = AssetManager.LoadFont("OrangeJuice");
            var  newGame   = new RectangleShape(new Vector2f(ButtonX, ButtonY))
            {
                FillColor = fillColor, Position = new Vector2f((screenSizeX / 2) - ButtonX / 2, screenSizeY - (ButtonY * 6))
            };
            var newGameText = new Text()
            {
                Position = new Vector2f(newGame.Position.X + 21, newGame.Position.Y + 10), DisplayedString = AssetManager.GetMessage("NewGame"), Color = Color.Black, Font = font, CharacterSize = 60
            };
            var loadGame = new RectangleShape(new Vector2f(ButtonX, ButtonY))
            {
                FillColor = fillColor, Position = new Vector2f((screenSizeX / 2) - ButtonX / 2, screenSizeY - (ButtonY * 4) - 40)
            };
            var loadGameText = new Text()
            {
                Position = new Vector2f(loadGame.Position.X + 14, loadGame.Position.Y + 10), DisplayedString = AssetManager.GetMessage("LoadGame"), Color = Color.Black, Font = font, CharacterSize = 60
            };
            var stats = new RectangleShape(new Vector2f(ButtonX, ButtonY))
            {
                FillColor = fillColor, Position = new Vector2f((screenSizeX / 2) - ButtonX / 2, screenSizeY - (ButtonY * 2) - 80)
            };
            var statsText = new Text()
            {
                Position = new Vector2f(stats.Position.X + 80, stats.Position.Y + 10), DisplayedString = AssetManager.GetMessage("Stats"), Color = Color.Black, Font = font, CharacterSize = 60
            };
            var exit = new RectangleShape(new Vector2f(ButtonX, ButtonY))
            {
                FillColor = fillColor, Position = new Vector2f((screenSizeX / 2) - ButtonX / 2, screenSizeY - (ButtonY * 1) - 40)
            };
            var exitText = new Text()
            {
                Position = new Vector2f(exit.Position.X + 100, exit.Position.Y + 10), DisplayedString = AssetManager.GetMessage("Exit"), Color = Color.Black, Font = font, CharacterSize = 60
            };
            var pointerSpite = AssetManager.LoadSprite("OldTimeyPointer");
            var renderWindow = WinInstance;

            Pointer = new MenuPointer(ref renderWindow, pointerSpite);
            var loadGameItem = new MenuItem(ref renderWindow, loadGameText, loadGame);
            var statsItem    = new MenuItem(ref renderWindow, statsText, stats);
            var newGameItem  = new MenuItem(ref renderWindow, newGameText, newGame);
            var exitItem     = new MenuItem(ref renderWindow, exitText, exit);

            newGameItem.AddAction(NewGameFunc);
            loadGameItem.AddAction(LoadGameFunc);
            statsItem.AddAction(DisplayStats);
            exitItem.AddAction(ExitGameFunc);
            MenuItems.Add(newGameItem);
            MenuItems.Add(loadGameItem);
            MenuItems.Add(statsItem);
            MenuItems.Add(exitItem);
            _originalMenuItems = new List <MenuItem> {
                newGameItem, loadGameItem, statsItem, exitItem
            };
            Pointer.SetPosition(new Vector2f((newGame.Position.X - Pointer.Size.X / 2f), newGame.Position.Y));
            Pointer.SetScale(new Vector2f(0.5f, 0.5f));
            var vector2F = Pointer.GetPosition();

            if (vector2F == null)
            {
                return;
            }
            _pointerPositions = new LinkedList <Vector2f>(new[]
            {
                vector2F.Value,
                new Vector2f((loadGame.Position.X - Pointer.Size.X / 2f), loadGame.Position.Y),
                new Vector2f((stats.Position.X - Pointer.Size.X / 2f), stats.Position.Y),
                new Vector2f((exit.Position.X - Pointer.Size.X / 2f), exit.Position.Y)
            });
            _originalPointerPos = new LinkedList <Vector2f>(new[]
            {
                vector2F.Value,
                new Vector2f((loadGame.Position.X - Pointer.Size.X / 2f), loadGame.Position.Y),
                new Vector2f((stats.Position.X - Pointer.Size.X / 2f), stats.Position.Y),
                new Vector2f((exit.Position.X - Pointer.Size.X / 2f), exit.Position.Y)
            });
        }