Exemple #1
0
        public MapEditor(GraphicsDevice graphicsDevice, ContentManager content)
        {
            GraphicsDevice = graphicsDevice;
            Content        = content;
            Input          = new Input();
            var bindings = new Dictionary <string, List <Keys> > {
                [Commands.CameraStrafeLeft] = new List <Keys> {
                    Keys.Left
                },
                [Commands.CameraStrafeRight] = new List <Keys> {
                    Keys.Right
                },
                [Commands.CameraForward] = new List <Keys> {
                    Keys.Up
                },
                [Commands.CameraBackward] = new List <Keys> {
                    Keys.Down
                },
                [Commands.CameraZoomIn] = new List <Keys> {
                    Keys.OemPlus, Keys.Add
                },
                [Commands.CameraZoomOut] = new List <Keys> {
                    Keys.OemMinus, Keys.Subtract
                },
                [Commands.CameraOrbitRight] = new List <Keys> {
                    Keys.PageDown
                },
                [Commands.CameraOrbitLeft] = new List <Keys> {
                    Keys.Delete
                },
                [Commands.CameraOrbitDown] = new List <Keys> {
                    Keys.End
                },
                [Commands.CameraOrbitUp] = new List <Keys> {
                    Keys.Home
                },

                [Commands.OpenMenu] = new List <Keys> {
                    Keys.Escape
                },

                [Commands.ToggleHexCoordinates] = new List <Keys> {
                    Keys.C
                },
                [Commands.ToggleHexGrid] = new List <Keys> {
                    Keys.G
                },
                [Commands.ToggleWireframe] = new List <Keys> {
                    Keys.W
                },
                [Commands.ToggleHexHeights] = new List <Keys> {
                    Keys.H
                },
                [Commands.CmdRaiseTerrain] = new List <Keys> {
                    Keys.F1
                },
                [Commands.CmdTrees] = new List <Keys> {
                    Keys.F2
                },


                [Commands.SaveMap] = new List <Keys> {
                    Keys.S
                },
                [Commands.LoadMap] = new List <Keys> {
                    Keys.L
                }
            };

            Input.AddBindings(bindings);

            Camera = new Camera(Input);
            Camera.SetLens(MathHelper.ToRadians(45), graphicsDevice.DisplayMode.AspectRatio, .01f, 1000f);
            Camera.LookAt(new Vector3(0, 10, 1), Vector3.Zero, Vector3.Up);

            SettingsMenu = new SettingsMenu(Exit, SaveMap, LoadMap);

            EditorPanel = new MapEditorTools(content);
            Interface.AddEntity(EditorPanel);



            SpriteBatch = new SpriteBatch(GraphicsDevice);
            _font       = Content.Load <SpriteFont>("default");

            var texture = Content.Load <Texture2D>("Dry Grass 2");

            Map = new HexMap(GraphicsDevice, 100, 100, texture, _font);
            MapResources.LoadContent(Content);
        }