示例#1
0
        public void CreateMainMenu()
        {
            Font       titleFont     = fontContainer.GetFont("SairaRegular");
            MenuPanel  mainMenu      = new MenuPanel(new Vector2i(0, 0), new Vector2i(200, 200), new FloatRect(0, 0, 96, 96), 4, null, new Color(255, 255, 255, 224));
            MenuButton newGameButton = new MenuButton(new Vector2i(150, 50), program.CreateMapGenMenu);
            MenuText   startGameText = new MenuText(new Vector2i(150, 50), titleFont, "New Game", 24, 0.6f);

            mainMenu.AttachComponent(newGameButton);
            newGameButton.AttachComponent(startGameText);
            MenuText   quitGameText   = new MenuText(new Vector2i(150, 50), titleFont, "Quit Game", 24, 0.6f);
            MenuButton quitGameButton = new MenuButton(new Vector2i(150, 50), program.SwitchGameState);

            quitGameButton.tag = "exit";
            mainMenu.AttachComponent(quitGameButton);
            quitGameButton.AttachComponent(quitGameText);

            //Component adjustment
            mainMenu.SetInitialPosition(camera.GetGUIView());
            newGameButton.SetPivots("top", "center", "inside", 25);
            newGameButton.SetInitialPosition(camera.GetGUIView());
            quitGameButton.SetPivots("bottom", "center", "outside", 0);
            quitGameButton.SetInitialPosition(newGameButton);

            menuContainer.AttachMenu(mainMenu);
        }
示例#2
0
        public void CreateMinimap()
        {
            MenuPanel    minimapPanel = new MenuPanel(new Vector2i(0, 0), new Vector2i(300, 350), new FloatRect(0, 0, 96, 96), 4, null, new Color(255, 255, 255, 224));
            MenuWorldMap minimap      = new MenuWorldMap(new Vector2i(250, 250), camera, renderer);

            minimap.mapScale = 1.25f;
            MenuButton minimapPollutionToggle = new MenuButton(new Vector2i(50, 50), minimap.TogglePollution);

            minimapPanel.AttachComponent(minimap);
            minimapPanel.AttachComponent(minimapPollutionToggle);
            minimapPollutionToggle.SetInitialPosition(camera.GetGUIView());
            minimapPanel.closePanelKey = InputBindings.showMinimap;
            minimapPanel.SetPivots("top", "right", "inside", 0);
            minimapPanel.SetInitialPosition(camera.GetGUIView());
            minimapPanel.lockedPosition = true;
            minimap.SetPivots("top", "center", "inside", 25);
            minimap.SetInitialPosition(camera.GetGUIView());
            minimapPollutionToggle.SetPivots("bottom", "center", "inside", 25);
            minimapPollutionToggle.SetInitialPosition(camera.GetGUIView());
            menuContainer.AttachMenu(minimapPanel);
        }
示例#3
0
        public void CreatePauseMenu()
        {
            Font pauseMenuFont = fontContainer.GetFont("SairaRegular");

            MenuPanel pausemenu = new MenuPanel(new Vector2i(0, 0), new Vector2i(200, 200), new FloatRect(0, 0, 96, 96), 4, program.SwitchGameState, new Color(255, 255, 255, 224));

            pausemenu.tag = "inGame";

            MenuText   resumeGameText   = new MenuText(new Vector2i(150, 50), pauseMenuFont, "Resume Game", 24, 0.6f);
            MenuButton resumeGameButton = new MenuButton(new Vector2i(150, 50), pausemenu.ClosePanel);

            resumeGameButton.tag = "inGame";

            MenuText   endGameText   = new MenuText(new Vector2i(150, 50), pauseMenuFont, "Return to Title", 24, 0.6f);
            MenuButton endGameButton = new MenuButton(new Vector2i(150, 50), program.SwitchGameState);

            endGameButton.tag = "mainMenu";

            MenuText   quitGameText   = new MenuText(new Vector2i(150, 50), pauseMenuFont, "Quit Game", 24, 0.6f);
            MenuButton quitGameButton = new MenuButton(new Vector2i(150, 50), program.SwitchGameState);

            quitGameButton.tag = "exit";

            pausemenu.AttachComponent(resumeGameButton);
            resumeGameButton.AttachComponent(resumeGameText);
            pausemenu.AttachComponent(endGameButton);
            endGameButton.AttachComponent(endGameText);
            pausemenu.AttachComponent(quitGameButton);
            quitGameButton.AttachComponent(quitGameText);

            pausemenu.closePanelKey = InputBindings.showPauseMenu;
            pausemenu.SetPivots("center", "center", "inside", 0);
            pausemenu.SetInitialPosition(camera.GetGUIView());
            resumeGameButton.SetPivots("top", "center", "inside", 25);
            resumeGameButton.SetInitialPosition(camera.GetGUIView());
            endGameButton.SetPivots("bottom", "center", "outside", 0);
            endGameButton.SetInitialPosition(resumeGameButton);
            quitGameButton.SetPivots("bottom", "center", "outside", 0);
            quitGameButton.SetInitialPosition(endGameButton);

            menuContainer.AttachMenu(pausemenu);

            //Pause the game
            program.SwitchGameState("paused");
        }
示例#4
0
        public void CreateWorldMap()
        {
            Vector2i     screenSize             = new Vector2i((int)camera.GetGUIView().Size.X, (int)camera.GetGUIView().Size.Y);
            MenuPanel    minimapPanel           = new MenuPanel(new Vector2i(0, 0), screenSize, new FloatRect(0, 0, 96, 96), 4, null, new Color(255, 255, 255, 224));
            MenuWorldMap minimap                = new MenuWorldMap(screenSize - new Vector2i(50, 50), camera, renderer);
            MenuButton   minimapPollutionToggle = new MenuButton(new Vector2i(50, 50), minimap.TogglePollution);

            minimapPanel.AttachComponent(minimap);
            minimapPanel.AttachComponent(minimapPollutionToggle);
            minimap.controllable = true;
            minimapPollutionToggle.SetInitialPosition(camera.GetGUIView());
            minimapPanel.closePanelKey = InputBindings.showWorldMap;
            minimapPanel.SetInitialPosition(camera.GetGUIView());
            minimapPanel.lockedPosition = true;
            renderer.ToggleCullingMinimap("");
            minimapPanel.ClosePanelAction = renderer.ToggleCullingMinimap;
            minimap.SetInitialPosition(camera.GetGUIView());
            menuContainer.AttachMenu(minimapPanel);
        }
示例#5
0
        public void CreateMapGenMenu(SurfaceGenerator surfaceGenerator)
        {
            //Declaring elements
            Font      mapGenFont = fontContainer.GetFont("SairaRegular");
            MenuPanel worldMenu  = new MenuPanel(new Vector2i(0, 0), new Vector2i(600, 500), new FloatRect(0, 0, 96, 96), 4, null, new Color(255, 255, 255, 224));

            //Noise dropdowns
            string[]    noiseNames        = Enum.GetNames(typeof(FastNoise.NoiseType));
            int[]       noiseValues       = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            MenuListBox moistureNoiseType = new MenuListBox(new Vector2i(150, 25), noiseNames, noiseValues, surfaceGenerator.SetNoiseType, mapGenFont, 24, 24, 0);

            moistureNoiseType.tag = "moisture";
            MenuText moistureNoiseText = new MenuText(new Vector2i(150, 25), mapGenFont, "Moisture Noise:", 24, 24);

            moistureNoiseText.SetTextPosition("right", "center");
            MenuListBox elevationNoiseType = new MenuListBox(new Vector2i(150, 25), noiseNames, noiseValues, surfaceGenerator.SetNoiseType, mapGenFont, 24, 24, 0);

            elevationNoiseType.tag = "elevation";
            MenuText elevationNoiseText = new MenuText(new Vector2i(150, 25), mapGenFont, "Elevation Noise:", 24, 24);

            elevationNoiseText.SetTextPosition("right", "center");
            MenuListBox temperatureNoiseType = new MenuListBox(new Vector2i(150, 25), noiseNames, noiseValues, surfaceGenerator.SetNoiseType, mapGenFont, 24, 24, 0);
            MenuText    temperatureNoiseText = new MenuText(new Vector2i(150, 25), mapGenFont, "Temperature Noise:", 24, 24);

            temperatureNoiseText.SetTextPosition("right", "center");
            temperatureNoiseType.tag = "temperature";
            //Surface size field
            MenuText  surfaceSizeFieldTitle = new MenuText(new Vector2i(100, 25), mapGenFont, "Map size:", 24, 24);
            MenuField surfaceSizeField      = new MenuField(new Vector2i(150, 25), mapGenFont, surfaceGenerator.ParseString);

            surfaceSizeField.tag = "surfacesize";
            surfaceSizeField.AttachComponent(surfaceSizeFieldTitle);
            surfaceSizeFieldTitle.SetTextPosition("right", "center");
            surfaceSizeFieldTitle.SetPivots("left", "center", "outside", 0);
            surfaceSizeFieldTitle.SetInitialPosition(surfaceSizeField);
            //Seed field
            MenuText  seedFieldTitle = new MenuText(new Vector2i(100, 25), mapGenFont, "Map Seed:", 24, 24);
            MenuField seedField      = new MenuField(new Vector2i(150, 25), mapGenFont, surfaceGenerator.ParseString);

            seedField.tag = "seed";
            seedField.AttachComponent(seedFieldTitle);
            seedFieldTitle.SetTextPosition("right", "center");
            seedFieldTitle.SetPivots("left", "center", "outside", 0);
            seedFieldTitle.SetInitialPosition(seedField);
            //Start game button
            MenuButton startGame     = new MenuButton(new Vector2i(100, 40), program.SwitchGameState);
            MenuText   startGameText = new MenuText(new Vector2i(100, 40), mapGenFont, "Start Game", 24, 24);

            startGame.AttachComponent(startGameText);
            startGameText.SetTextPosition("center", "center");
            startGameText.SetPivots("center", "center", "inside", 0);
            startGame.tag = "inGame";
            //Slider
            MenuSlider elevationFactor = new MenuSlider(5, surfaceGenerator.SetNoiseFactor, 0.5f, 1.5f, 1.0f);

            elevationFactor.tag = "elevation";
            MenuText   elevationSliderText = new MenuText(new Vector2i(150, 25), mapGenFont, "Elevation Factor", 24, 24);
            MenuSlider moistureFactor      = new MenuSlider(5, surfaceGenerator.SetNoiseFactor, 0.5f, 1.5f, 1.0f);

            moistureFactor.tag = "moisture";
            MenuText   moistureSliderText    = new MenuText(new Vector2i(150, 25), mapGenFont, "Moisture Factor", 24, 24);
            MenuSlider temperatureFactor     = new MenuSlider(5, surfaceGenerator.SetNoiseFactor, 0.5f, 1.5f, 1.0f);
            MenuText   temperatureSliderText = new MenuText(new Vector2i(150, 25), mapGenFont, "Temperature Factor", 24, 24);

            temperatureFactor.tag = "temperature";
            //Attaching Elements
            worldMenu.AttachComponent(startGame);
            worldMenu.AttachComponent(seedField);
            worldMenu.AttachComponent(surfaceSizeField);
            worldMenu.AttachComponent(temperatureNoiseType);
            worldMenu.AttachComponent(elevationNoiseType);
            worldMenu.AttachComponent(moistureNoiseType);
            worldMenu.AttachComponent(moistureNoiseText);
            worldMenu.AttachComponent(temperatureNoiseText);
            worldMenu.AttachComponent(elevationNoiseText);


            worldMenu.AttachComponent(elevationFactor);
            worldMenu.AttachComponent(moistureFactor);
            worldMenu.AttachComponent(temperatureFactor);
            worldMenu.AttachComponent(elevationSliderText);
            worldMenu.AttachComponent(moistureSliderText);
            worldMenu.AttachComponent(temperatureSliderText);

            //Positioning elements
            seedField.SetRelativePosition(new Vector2i(100, 25));
            surfaceSizeField.SetPivots("bottom", "center", "outside", 25);
            surfaceSizeField.SetInitialPosition(seedField);
            startGame.SetPivots("bottom", "right", "inside", 25);
            startGame.SetInitialPosition();
            worldMenu.SetInitialPosition(camera.GetGUIView());
            elevationFactor.SetInitialPosition(camera.GetGUIView());
            moistureFactor.SetPivots("bottom", "center", "outside", 25);
            moistureFactor.SetInitialPosition(elevationFactor);
            temperatureFactor.SetPivots("bottom", "center", "outside", 25);
            temperatureFactor.SetInitialPosition(moistureFactor);
            moistureNoiseType.SetPivots("top", "right", "inside", 25);
            moistureNoiseType.SetInitialPosition(camera.GetGUIView());
            elevationNoiseType.SetPivots("bottom", "center", "outside", 25);
            elevationNoiseType.SetInitialPosition(moistureNoiseType);
            temperatureNoiseType.SetPivots("bottom", "center", "outside", 25);
            temperatureNoiseType.SetInitialPosition(elevationNoiseType);

            moistureNoiseText.SetRelativePosition(moistureNoiseType.position - new Vector2i(230, 0));
            elevationNoiseText.SetRelativePosition(elevationNoiseType.position - new Vector2i(230, 0));
            temperatureNoiseText.SetRelativePosition(temperatureNoiseType.position - new Vector2i(230, 0));

            moistureSliderText.SetRelativePosition(moistureFactor.position - new Vector2i(150, 0));
            elevationSliderText.SetRelativePosition(elevationFactor.position - new Vector2i(150, 0));
            temperatureSliderText.SetRelativePosition(temperatureFactor.position - new Vector2i(150, 0));

            //Finalize into menu container
            menuContainer.AttachMenu(worldMenu);
        }