当前位置: 首页>>代码示例>>C#>>正文


C# EditorMap.RemoveMapGrh方法代码示例

本文整理汇总了C#中EditorMap.RemoveMapGrh方法的典型用法代码示例。如果您正苦于以下问题:C# EditorMap.RemoveMapGrh方法的具体用法?C# EditorMap.RemoveMapGrh怎么用?C# EditorMap.RemoveMapGrh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EditorMap的用法示例。


在下文中一共展示了EditorMap.RemoveMapGrh方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MapContainer_KeyUp

        /// <summary>
        /// Handles when a key is raised on a map.
        /// </summary>
        /// <param name="sender">The <see cref="IToolTargetMapContainer"/> the event came from. Cannot be null.</param>
        /// <param name="map">The <see cref="EditorMap"/>. Cannot be null.</param>
        /// <param name="camera">The <see cref="ICamera2D"/>. Cannot be null.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data. Cannot be null.</param>
        protected override void MapContainer_KeyUp(IToolTargetMapContainer sender, EditorMap map, ICamera2D camera, KeyEventArgs e)
        {
            // Handle deletes
            if (e.KeyCode == Keys.Delete)
            {
                // Only delete when it is an Entity that is on this map
                var removed = new List<object>();
                foreach (var x in SOM.SelectedObjects.OfType<MapGrh>().ToImmutable())
                {
                    if (map.Spatial.CollectionContains(x))
                    {
                        map.RemoveMapGrh(x);
                        removed.Add(x);
                    }
                }

                SOM.SetManySelected(SOM.SelectedObjects.Except(removed).ToImmutable());
            }

            base.MapContainer_KeyUp(sender, map, camera, e);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:28,代码来源:MapGrhCursorTool.cs

示例2: HandleMouseClickAndMove

        /// <summary>
        /// Handles both mouse clicks and moves.
        /// </summary>
        /// <param name="map">The <see cref="EditorMap"/>. Cannot be null.</param>
        /// <param name="camera">The <see cref="ICamera2D"/>. Cannot be null.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data. Cannot be null.</param>
        void HandleMouseClickAndMove(EditorMap map, ICamera2D camera, MouseEventArgs e)
        {
            // Update some vars
            var cursorPos = e.Position();
            _mouseOverMap = map;
            _mousePos = cursorPos;

            var globalState = GlobalState.Instance;
            var currentGrhData = globalState.Map.GrhToPlace.GrhData;

            Vector2 worldPos = camera.ToWorld(cursorPos);

            // Handle mouse
            if (e.Button == MouseButtons.Left)
            {
                if (!Input.IsShiftDown)
                {
                    // Fill
                    if (currentGrhData != null)
                    {
                        var mapGrhsToReplace = GetFillMapGrhs(map, worldPos);
                        foreach (var mapGrh in mapGrhsToReplace)
                        {
                            mapGrh.Grh.SetGrh(currentGrhData);
                        }
                    }
                }
                else
                {
                    // Select grh under cursor
                    var grhToSelect = MapGrhPencilTool.GetGrhToSelect(map, worldPos);
                    if (grhToSelect != null)
                    {
                        globalState.Map.SetGrhToPlace(grhToSelect.Grh.GrhData.GrhIndex);
                        globalState.Map.Layer = grhToSelect.MapRenderLayer;
                        globalState.Map.LayerDepth = grhToSelect.LayerDepth;
                    }
                }

            }
            else if (e.Button == MouseButtons.Right)
            {
                // Fill-delete
                if (currentGrhData != null)
                {
                    var mapGrhsToReplace = GetFillMapGrhs(map, worldPos);
                    foreach (var mapGrh in mapGrhsToReplace)
                    {
                        map.RemoveMapGrh(mapGrh);
                    }
                }
            }
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:59,代码来源:MapGrhFillTool.cs

示例3: MapContainer_MouseMove

        /// <summary>
        /// Handles when the mouse moves over a map.
        /// </summary>
        /// <param name="sender">The <see cref="IToolTargetMapContainer"/> the event came from. Cannot be null.</param>
        /// <param name="map">The <see cref="EditorMap"/>. Cannot be null.</param>
        /// <param name="camera">The <see cref="ICamera2D"/>. Cannot be null.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data. Cannot be null.</param>
        protected override void MapContainer_MouseMove(IToolTargetMapContainer sender, EditorMap map, ICamera2D camera,
                                                       MouseEventArgs e)
        {
            base.MapContainer_MouseMove(sender, map, camera, e);

            var cursorPos = e.Position();

            _mouseOverMap = map;
            _mousePos = cursorPos;

            // Support dragging operations when using TileMode
            if (TileMode)
            {
                if (Input.IsKeyDown(_placeMapGrhKey))
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        // Drag placement
                        PlaceMapGrh(map, camera, e.Position(), true);
                    }
                    else if (e.Button == MouseButtons.Right)
                    {
                        // Drag delete
                        var worldPos = camera.ToWorld(e.Position());
                        worldPos = GridAligner.Instance.Align(worldPos, true);
                        var worldPosArea = worldPos.ToRectangle(Vector2.One, false);
                        var toDelete = map.Spatial.GetMany<MapGrh>(worldPosArea, x => IsObjectVisible(map, x));

                        foreach (var x in toDelete)
                        {
                            map.RemoveMapGrh(x);
                        }
                    }
                }
            }
        }
开发者ID:Vizzini,项目名称:netgore,代码行数:43,代码来源:MapGrhCursorTool.cs

示例4: HandleMouseClickAndMove

        /// <summary>
        /// Handles both mouse clicks and moves (does the place/deletes of grhs).
        /// </summary>
        /// <param name="map">The <see cref="EditorMap"/>. Cannot be null.</param>
        /// <param name="camera">The <see cref="ICamera2D"/>. Cannot be null.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data. Cannot be null.</param>
        void HandleMouseClickAndMove(EditorMap map, ICamera2D camera, MouseEventArgs e)
        {
            // Update some vars
            var cursorPos = e.Position();
            _mouseOverMap = map;
            _mousePos = cursorPos;

            // Don't do any place/deletes while selecting
            if (IsSelecting)
                return;

            Vector2 worldPos = camera.ToWorld(cursorPos);

            // Handle mouse
            if (e.Button == MouseButtons.Left)
            {
                if (!Input.IsShiftDown)
                {
                    // Place grh
                    PlaceMapGrhAtScreenPos(map, camera, cursorPos, !Input.IsCtrlDown);
                }
                else
                {
                    // Select grh under cursor
                    var grhToSelect = GetGrhToSelect(map, worldPos);
                    if (grhToSelect != null)
                    {
                        GlobalState.Instance.Map.SetGrhToPlace(grhToSelect.Grh.GrhData.GrhIndex);
                        GlobalState.Instance.Map.Layer = grhToSelect.MapRenderLayer;
                        GlobalState.Instance.Map.LayerDepth = grhToSelect.LayerDepth;
                    }
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                if (!Input.IsShiftDown)
                {
                    // Delete from current layer
                    var grhToDelete = GetGrhToSelect(map, worldPos, mustBeOnLayer: GlobalState.Instance.Map.Layer);
                    if (grhToDelete != null)
                        map.RemoveMapGrh(grhToDelete);
                }
                else
                {
                    // Delete from all layers
                    var grhToSelect = GetGrhToSelect(map, worldPos);
                    if (grhToSelect != null)
                        map.RemoveMapGrh(grhToSelect);
                }
            }
        }
开发者ID:wtfcolt,项目名称:game,代码行数:57,代码来源:MapGrhPencilTool.cs


注:本文中的EditorMap.RemoveMapGrh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。