Beispiel #1
0
        public void CreateOrEditEvent(Rectangle selectedRect)
        {
            MapEditorManager.IgnoreInput = true;

            var camera = this.context.SceneProvider.Cameras["camera1"];

            int xOffset = (int)camera.Location.X / 32;
            int yOffset = (int)camera.Location.Y / 32;

            IMapEvent mapevent = this.context.EventProvider.GetMapsEvents(MapEditorManager.CurrentMap.Name).Where(e => e.Rectangle.Intersects(selectedRect)).FirstOrDefault();

            bool newEvent = false;
            if (mapevent != null)
            {
                SelectedPoint = new Point(mapevent.Rectangle.X * 32, mapevent.Rectangle.Y * 32);
                EndSelectedPoint = new Point((mapevent.Rectangle.X * 32) + ((mapevent.Rectangle.Width - 1) * 32), (mapevent.Rectangle.Y * 32) + ((mapevent.Rectangle.Height - 1) * 32));
            }
            else
            {
                newEvent = true;
            }

            MapPoint size = new MapPoint(((this.EndSelectedPoint.X - this.SelectedPoint.X) / 32) + 1, ((this.EndSelectedPoint.Y - this.SelectedPoint.Y) / 32) + 1);

            frmMapEvent dialog = new frmMapEvent(mapevent);
            DialogResult result = dialog.ShowDialog();

            mapevent = dialog.Event;
            if (mapevent != null)
            {
                if (!newEvent)
                    mapevent.Rectangle = new Rectangle(mapevent.Rectangle.X, mapevent.Rectangle.Y, size.IntX, size.IntY);
                else
                    mapevent.Rectangle = new Rectangle(selectedRect.X, selectedRect.Y, size.IntX, size.IntY);
            }

            if (result == DialogResult.OK)
            {
                this.context.EventProvider.ReferenceSetOrAdd(MapEditorManager.CurrentMap.Name, mapevent);
                MapEditorManager.OnMapChanged();
            }
            else if (result == DialogResult.Abort)
            {
                this.context.EventProvider.RemoveEvent(MapEditorManager.CurrentMap.Name, mapevent);
                MapEditorManager.OnMapChanged();
            }

            MapEditorManager.IgnoreInput = false;
        }
Beispiel #2
0
        public void newEvent()
        {
            if (Cancel)
                return;

            if (IsStartAfterEnd())
            {
                Point temp = SelectedPoint;
                SelectedPoint = EndSelectedPoint;
                EndSelectedPoint = temp;
            }

            int xOffset = (int)TileEngine.Camera.MapOffset.X / 32 + (int)TileEngine.Camera.CameraOffset.X;
            int yOffset = (int)TileEngine.Camera.MapOffset.Y / 32 + (int)TileEngine.Camera.CameraOffset.Y;

            MapPoint point = new MapPoint(SelectedPoint.X - xOffset, SelectedPoint.Y - yOffset);
            MapPoint size = new MapPoint(this.EndSelectedPoint.X - this.SelectedPoint.X, this.EndSelectedPoint.Y - this.SelectedPoint.Y);

            Event e = TileEngine.EventSystem.GetEventInRect(point, size);

            frmMapEvent frm = new frmMapEvent();

            if (e == null)
            {
                e = new Event(point, size);
            }
            else
            {
                SelectedPoint = e.Location.ToPoint();
                EndSelectedPoint = (e.Location+e.Size).ToPoint();
            }

            frm.LoadEvent(e);

            DialogResult res = frm.ShowDialog();

            if (res == DialogResult.OK)
            {
                e.Type = frm.inType.Text;
                //e.ParmOne = frm.tbArgOne.Text;
                //e.ParmTwo = frm.tbArgTwo.Text;
                e.Direction = frm.inDirection.Text;
                TileEngine.EventSystem.SetEvent(e);
            }
            else if (res == DialogResult.Abort)
            {
                TileEngine.EventSystem.DelEvent(e);
            }
        }