예제 #1
0
        private void OnDrawTile(TileEventArgs e)
        {
            var tileWidth  = e.TileSize.Width;
            var tileHeight = e.TileSize.Height;
            var tilePos    = e.TileLocation.ToVector();


            var npc = m_mapMeta?.GetNPC(tilePos);

            if (npc != null)
            {
                var destRect = new Rectangle(e.Location.X - npc.Animation.spriteWidth + tileWidth, e.Location.Y - npc.Animation.spriteHeight + tileHeight, npc.Animation.spriteWidth, npc.Animation.spriteHeight);
                m_actorManager.Graphics = e.Graphics;
                e.Graphics.DrawImage(m_actorManager.Actors[npc.CharSet], destRect, npc.Animation.SourceRect.X, npc.Animation.SourceRect.Y, npc.Animation.spriteWidth, npc.Animation.spriteHeight, GraphicsUnit.Pixel, new System.Drawing.Imaging.ImageAttributes());
            }

            var eventId = m_mapMeta?.GetEventId(tilePos);

            if (eventId != null)
            {
                var destRect   = new Rectangle(e.Location.X, e.Location.Y, tileWidth, tileHeight);
                var tileBitmap = Properties.Resources.Event_32;
                e.Graphics.DrawImage(tileBitmap, destRect, 0, 0, tileWidth, tileHeight, GraphicsUnit.Pixel, new System.Drawing.Imaging.ImageAttributes());
            }
        }
예제 #2
0
        public void OnEditorMouseDown(MouseEventArgs mouseEventArgs, MapEventArgs mapEventArgs)
        {
            var selectedPos = new Vector(mapEventArgs.X, mapEventArgs.Y);

            if (m_npcToolBarButton.Checked)
            {
                using (var form = new NPCDialog())
                {
                    var result = form.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        form.Selected.Pos = selectedPos;

                        m_mapMeta.AddNPC(form.Selected);
                    }
                }
            }
            else if (m_eventToolBarButton.Checked)
            {
                var input   = Prompt.ShowDialog("Event Id", "Enter an event id");
                var eventId = input.ToInt();
                if (eventId > 0)
                {
                    m_mapMeta.AddEvent(new EventId {
                        Id = eventId, Pos = selectedPos
                    });
                }
            }
            else if (m_eraserToolBarButton.Checked)
            {
                var npc = m_mapMeta.GetNPC(selectedPos);

                if (npc != null)
                {
                    m_mapMeta.RemoveNPC(npc);
                }
            }
        }