Ejemplo n.º 1
0
    /// <summary>
    /// Initialize this instance.
    /// </summary>
    public void Initialize(MapResources mapResources)
    {
        m_mapResources = mapResources;
        if (m_lanesRoot == null)
        {
            m_lanesRoot        = new GameObject("Lanes").transform;
            m_lanesRoot.parent = transform;
        }
        if (m_grassEdgeItemsRoot == null)
        {
            m_grassEdgeItemsRoot        = new GameObject("GrassEdgeItems").transform;
            m_grassEdgeItemsRoot.parent = transform;
        }
        if (m_grassObstaclesRoot == null)
        {
            m_grassObstaclesRoot        = new GameObject("GrassObstacles").transform;
            m_grassObstaclesRoot.parent = transform;
        }
        if (m_platformsRoot == null)
        {
            m_platformsRoot        = new GameObject("Platforms").transform;
            m_platformsRoot.parent = transform;
        }
        if (m_vehiclesRoot == null)
        {
            m_vehiclesRoot        = new GameObject("Vehicles").transform;
            m_vehiclesRoot.parent = transform;
        }
        if (m_coinsRoot == null)
        {
            m_coinsRoot        = new GameObject("Coins").transform;
            m_coinsRoot.parent = transform;
        }
        if (m_sharedItemsRoot == null)
        {
            m_sharedItemsRoot        = new GameObject("SharedItems").transform;
            m_sharedItemsRoot.parent = transform;
        }

        // Create shared items
        CreateSharedAssets();
    }
Ejemplo n.º 2
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);
        }