Ejemplo n.º 1
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            if (_leftGrabbed || _rightGrabbed)
            {
                EditorForm.MapTool tool = EditorForm.Instance.GetMapTool();
                if (_leftGrabbed)
                {
                    if (tool != EditorForm.MapTool.Pencil)
                    {
                        PaintSelection(tool);
                        this.Refresh();
                    }
                }
                else
                {
                    if (tool == EditorForm.MapTool.Event)
                    {
                        for (int i = 0; i < MapData.MapEventsCount(); i++)
                        {
                            Genus2D.GameData.MapEvent mapEvent = MapData.GetMapEvent(i);
                            if (mapEvent.MapX == _lastX && mapEvent.MapY == _lastY)
                            {
                                Genus2D.GameData.MapInfo.SetMapEventsCount(MapID, MapData.MapEventsCount() - 1);
                                MapData.RemoveMapEvent(i);
                                this.Refresh();
                                break;
                            }
                        }
                    }
                    else if (tool == EditorForm.MapTool.SpawnPoint)
                    {
                        for (int i = 0; i < Genus2D.GameData.MapInfo.NumberSpawnPoints(); i++)
                        {
                            Genus2D.GameData.SpawnPoint spawn = Genus2D.GameData.MapInfo.GetSpawnPoint(i);
                            if (spawn.MapID == MapID && spawn.MapX == _lastX && spawn.MapY == _lastY)
                            {
                                Genus2D.GameData.MapInfo.RemoveSpawnPoint(i);
                                this.Refresh();
                                break;
                            }
                        }
                    }
                }

                _lastX        = -1;
                _lastY        = -1;
                _leftGrabbed  = false;
                _rightGrabbed = false;
                this.Refresh();
            }
        }
Ejemplo n.º 2
0
        private void MapSelection_SelectedIndexChanged(object sender, EventArgs e)
        {
            EventSelection.Items.Clear();
            int selection = MapSelection.SelectedIndex;

            if (selection != -1)
            {
                MapXSelection.Maximum = Genus2D.GameData.MapInfo.GetMapInfo(selection).Width;
                MapYSelection.Maximum = Genus2D.GameData.MapInfo.GetMapInfo(selection).Height;

                Genus2D.GameData.MapData data = Genus2D.GameData.MapInfo.LoadMap(selection);
                for (int i = 0; i < data.MapEventsCount(); i++)
                {
                    EventSelection.Items.Add(data.GetMapEvent(i).Name);
                }
                EventSelection.SelectedIndex = EventSelection.Items.Count > 0 ? 0 : -1;
            }
            else
            {
                EventSelection.SelectedIndex = -1;
                MapXSelection.Maximum        = 0;
                MapYSelection.Maximum        = 0;
            }

            MapXSelection.Value = 0;
            MapYSelection.Value = 0;
        }