示例#1
0
        private void generateRoomMappingTemplateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_bitmap == null)
            {
                return;
            }

            List <Color> colors = new List <Color>();
            Color        color;

            for (int y = 0; y < _bitmap.Height; y++)
            {
                for (int x = 0; x < _bitmap.Width; x++)
                {
                    color = _bitmap.GetPixel(x, y);
                    if (!colors.Contains(color))
                    {
                        colors.Add(color);
                    }
                }
            }
            _roomTemplates.Clear();
            MiniRoomTemplate temp;

            foreach (Color col in colors)
            {
                temp             = new MiniRoomTemplate();
                temp.Title       = "No Title";
                temp.Description = String.Empty;
                temp.ImageColor  = col;
                temp.Terrain     = TerrainType.field;
                _roomTemplates.Add(temp);
            }
            BindData();
        }
示例#2
0
        private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.ColumnIndex == 3)
            {
                DataGridView     dgv  = sender as DataGridView;
                MiniRoomTemplate data = dgv.Rows[e.RowIndex].DataBoundItem as MiniRoomTemplate;

                e.CellStyle.BackColor = data.ImageColor;
            }
        }
示例#3
0
        /// <summary>
        /// Generates a zone file.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void generateZoneToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.Filter = "xml files (*.xml)|*.xml";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                int  vnum = Int32.Parse(txtStartVnum.Text);
                Area area = new Area();
                area.AreaFlags[Area.AREA_WORLDMAP.Group] = Area.AREA_WORLDMAP.Vector;
                area.Width    = _bitmap.Width;
                area.Height   = _bitmap.Height;
                area.Author   = txtAuthor.Text;
                area.Builders = txtAuthor.Text;
                area.Name     = txtZoneName.Text;
                for (int y = 0; y < _bitmap.Height; y++)
                {
                    for (int x = 0; x < _bitmap.Width; x++)
                    {
                        Color            col  = _bitmap.GetPixel(x, y);
                        MiniRoomTemplate temp = GetTemplate(col);
                        RoomTemplate     room = new RoomTemplate();
                        room.Title       = temp.Title;
                        room.Description = temp.Description;
                        room.TerrainType = temp.Terrain;
                        room.IndexNumber = vnum + x + (y * _bitmap.Width);
                        // Only add exits and add the room to the zone if the room is not impassable.
                        //
                        // TODO: Don't create exits that point to impassable rooms.
                        Color            pixel;
                        MiniRoomTemplate target;
                        if (room.TerrainType != TerrainType.underground_impassable || (x == 0 && y == 0))
                        {
                            if (x > 0)
                            {
                                pixel  = _bitmap.GetPixel(x - 1, y);
                                target = GetTemplate(pixel);
                                if (target.Terrain != TerrainType.underground_impassable)
                                {
                                    Exit exit = new Exit();
                                    exit.IndexNumber = vnum + x + (y * _bitmap.Width) - 1;
                                    room.ExitData[(int)Exit.Direction.west] = exit;
                                }
                            }
                            if (x < (_bitmap.Width - 1))
                            {
                                pixel  = _bitmap.GetPixel(x + 1, y);
                                target = GetTemplate(pixel);
                                if (target.Terrain != TerrainType.underground_impassable)
                                {
                                    Exit exit = new Exit();
                                    exit.IndexNumber = vnum + x + (y * _bitmap.Width) + 1;
                                    room.ExitData[(int)Exit.Direction.east] = exit;
                                }
                            }
                            if (y > 0)
                            {
                                pixel  = _bitmap.GetPixel(x, y - 1);
                                target = GetTemplate(pixel);
                                if (target.Terrain != TerrainType.underground_impassable)
                                {
                                    Exit exit = new Exit();
                                    exit.IndexNumber = vnum + x + ((y - 1) * _bitmap.Width);
                                    room.ExitData[(int)Exit.Direction.north] = exit;
                                }
                            }
                            if (y < (_bitmap.Height - 1))
                            {
                                pixel  = _bitmap.GetPixel(x, y + 1);
                                target = GetTemplate(pixel);
                                if (target.Terrain != TerrainType.underground_impassable)
                                {
                                    Exit exit = new Exit();
                                    exit.IndexNumber = vnum + x + ((y + 1) * _bitmap.Width);
                                    room.ExitData[(int)Exit.Direction.south] = exit;
                                }
                            }
                            area.Rooms.Add(room);
                        }
                    }
                }
                area.Save(dialog.FileName);
            }
        }