Exemple #1
0
        /* Area map*/
        static public void Make_AreaMap(string base_dir, Dictionary <int, List <Toolbox.Area> > Areas, Wdt wdt)
        {
            Console.WriteLine("Making area map:");
            string area_fullmap  = base_dir + "/map_areas.png";
            var    tilesize      = 256;
            int    size_per_mcnk = tilesize / 16;
            string areasjson     = "[";
            List <System.Drawing.Color> colors = new List <System.Drawing.Color>();

            using (var areaall = new System.Drawing.Bitmap(wdt.size_y * tilesize, wdt.size_x * tilesize)) {
                using (var area_graphics = System.Drawing.Graphics.FromImage(areaall)) {
                    areaall.MakeTransparent();
                    area_graphics.DrawImage(areaall, 0, 0, areaall.Width, areaall.Height);
                    foreach (KeyValuePair <int, List <Toolbox.Area> > area in Areas)
                    {
                        Random rnd       = new Random();
                        var    AreaColor = System.Drawing.Color.FromArgb(255 / 2, rnd.Next(255), rnd.Next(255), rnd.Next(255));
                        while (colors.Contains(AreaColor))
                        {
                            AreaColor = System.Drawing.Color.FromArgb(255 / 2, rnd.Next(255), rnd.Next(255), rnd.Next(255));
                        }
                        colors.Add(AreaColor);
                        if (areasjson != "[")
                        {
                            areasjson += ",";
                        }
                        //Console.WriteLine(AreaColor.R + " / " + AreaColor.G + " /  " + AreaColor.B);
                        areasjson += "{\"r\":" + (Math.Round(AreaColor.R * (1.0f - (64.0f / 127f)))) + ",\"g\":" + (Math.Round(AreaColor.G * (1.0f - (64.0f / 127f)))) + ",\"b\":" + (Math.Round(AreaColor.B * (1.0f - (64.0f / 127f)))) + ",\"ID\":\"" + area.Value[0].ID + "\",\"ZoneName\":\"" + area.Value[0].ZoneName + "\",\"ContinentID\":" + area.Value[0].ContinentID + ",\"AreaName_lang\":\"" + area.Value[0].AreaName_lang + "\"}";
                        using (System.Drawing.SolidBrush AreaBrush = new System.Drawing.SolidBrush(AreaColor)) {
                            foreach (Toolbox.Area a in area.Value)
                            {
                                area_graphics.FillRectangle(AreaBrush, ((a.y - wdt.min_y) * tilesize) + (a.sub_x * size_per_mcnk), ((a.x - wdt.min_x) * tilesize) + (a.sub_y * size_per_mcnk), size_per_mcnk, size_per_mcnk);
                            }
                        }
                    }
                }
                Console.WriteLine("writing area map");
                NetVips.Image netimg = BitmapConverter.ToVips(areaall);
                netimg = netimg.Resize(2, "VIPS_KERNEL_NEAREST");
                netimg.WriteToFile(area_fullmap);
            }
            CutMap(area_fullmap, base_dir + "/area_tiles", 10);
            areasjson += "]";
            File.WriteAllText(base_dir + "/areas.json", areasjson);
        }
Exemple #2
0
        /* Unknown map */
        static public void Make_UnknownMap(string base_dir, Adt[,] adts, Wdt wdt)
        {
            Console.WriteLine("Making unknown map:");
            string unknown_fullmap = base_dir + "/map_unknown.png";
            var    tilesize        = 256;
            int    size_per_mcnk   = tilesize / 16;

            System.Drawing.SolidBrush unknown_brush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(170, 255, 255, 255));
            using (var areaall = new System.Drawing.Bitmap(wdt.size_y * tilesize, wdt.size_x * tilesize)) {
                using (var area_graphics = System.Drawing.Graphics.FromImage(areaall)) {
                    /*areaall.MakeTransparent();
                     * area_graphics.DrawImage(areaall, 0, 0, areaall.Width, areaall.Height);*/
                    for (int x = 0; x < 64; x++)
                    {
                        for (int y = 0; y < 64; y++)
                        {
                            for (int sub_x = 0; sub_x < 16; sub_x++)
                            {
                                for (int sub_y = 0; sub_y < 16; sub_y++)
                                {
                                    if (adts[x, y].unknown[sub_x, sub_y] == 1)
                                    {
                                        area_graphics.FillRectangle(unknown_brush, ((y - wdt.min_y) * tilesize) + (sub_x * size_per_mcnk), ((x - wdt.min_x) * tilesize) + (sub_y * size_per_mcnk), size_per_mcnk, size_per_mcnk);
                                    }
                                }
                            }
                        }
                    }
                }
                unknown_brush.Dispose();
                Console.WriteLine("writing unknown map");
                NetVips.Image netimg = BitmapConverter.ToVips(areaall);
                netimg = netimg.Resize(2, "VIPS_KERNEL_NEAREST");
                netimg.WriteToFile(unknown_fullmap);
            }
            CutMap(unknown_fullmap, base_dir + "/unknown_tiles", 10);
        }
Exemple #3
0
        /* Impass map */
        static public void Make_ImpassMap(string base_dir, Adt[,] adts, Wdt wdt)
        {
            Console.WriteLine("Making impass map:");
            string impass_fullmap = base_dir + "/map_impass.png";
            var    tilesize       = 256;
            int    size_per_mcnk  = tilesize / 16;
            Pen    impass_pen     = new Pen(Color.FromArgb(220, 255, 255, 0), 2.5f);
            Pen    mid_impass_pen = new Pen(Color.FromArgb(220, 255, 0, 0), 2.5f);

            //Console.WriteLine(wdt.size_x + " / "+  wdt.size_y);

            using (var bitmap = new System.Drawing.Bitmap(wdt.size_y * tilesize, wdt.size_x * tilesize)) {
                using (var g_impass = System.Drawing.Graphics.FromImage(bitmap)) {
                    bitmap.MakeTransparent();
                    g_impass.DrawImage(bitmap, 0, 0, bitmap.Width, bitmap.Height);
                    for (int a = 0; a < 64; a++)
                    {
                        for (int b = 0; b < 64; b++)
                        {
                            for (int i = 0; i < 16; i++)
                            {
                                for (int j = 0; j < 16; j++)
                                {
                                    Point topright    = new Point((b - wdt.min_y) * tilesize + (int)size_per_mcnk * (int)i, (a - wdt.min_x) * tilesize + (int)size_per_mcnk * ((int)j + 1));
                                    Point topleft     = new Point((b - wdt.min_y) * tilesize + (int)size_per_mcnk * (int)i, (a - wdt.min_x) * tilesize + (int)size_per_mcnk * (int)j);
                                    Point bottomright = new Point((b - wdt.min_y) * tilesize + (int)size_per_mcnk * ((int)i + 1), (a - wdt.min_x) * tilesize + (int)size_per_mcnk * ((int)j + 1));
                                    Point botttomleft = new Point((b - wdt.min_y) * tilesize + (int)size_per_mcnk * ((int)i + 1), (a - wdt.min_x) * tilesize + (int)size_per_mcnk * (int)j);

                                    int up      = 0;
                                    int down    = 0;
                                    int left    = 0;
                                    int right   = 0;
                                    int current = adts[a, b].impasses[i, j];

                                    if (j > 0)
                                    {
                                        left = adts[a, b].impasses[i, j - 1];
                                    }
                                    else if (a > 0)
                                    {
                                        left = adts[a - 1, b].impasses[i, 15];
                                    }
                                    else
                                    {
                                        left = -1; // wall
                                    }
                                    if (j < 15)
                                    {
                                        right = adts[a, b].impasses[i, j + 1];
                                    }
                                    else if (a < 63)
                                    {
                                        right = adts[a + 1, b].impasses[i, 0];
                                    }
                                    else
                                    {
                                        right = -1; // wall
                                    }
                                    if (i > 0)
                                    {
                                        up = adts[a, b].impasses[i - 1, j];
                                    }
                                    else if (b > 0)
                                    {
                                        up = adts[a, b - 1].impasses[15, j];
                                    }
                                    else
                                    {
                                        up = -1; // wall
                                    }
                                    if (i < 15)
                                    {
                                        down = adts[a, b].impasses[i + 1, j];
                                    }
                                    else if (b < 63)
                                    {
                                        down = adts[a, b + 1].impasses[0, j];
                                    }
                                    else
                                    {
                                        down = -1; // wall
                                    }
                                    if (current == 1)
                                    {
                                        if (left == 1)
                                        {
                                            g_impass.DrawLine(mid_impass_pen, topleft, botttomleft);
                                        }
                                        else if (left == -1)
                                        {
                                            g_impass.DrawLine(impass_pen, topleft, botttomleft);
                                        }
                                        if (right == 1)
                                        {
                                            g_impass.DrawLine(mid_impass_pen, topright, bottomright);
                                        }
                                        else if (right == -1)
                                        {
                                            g_impass.DrawLine(impass_pen, topright, bottomright);
                                        }
                                        if (up == 1)
                                        {
                                            g_impass.DrawLine(mid_impass_pen, topleft, topright);
                                        }
                                        else if (up == -1)
                                        {
                                            g_impass.DrawLine(impass_pen, topleft, topright);
                                        }
                                        if (down == 1)
                                        {
                                            g_impass.DrawLine(mid_impass_pen, botttomleft, bottomright);
                                        }
                                        else if (down == -1)
                                        {
                                            g_impass.DrawLine(impass_pen, botttomleft, bottomright);
                                        }
                                    }
                                    else if (current == 0)
                                    {
                                        if (left == 1)
                                        {
                                            g_impass.DrawLine(mid_impass_pen, topleft, botttomleft);
                                        }
                                        if (right == 1)
                                        {
                                            g_impass.DrawLine(mid_impass_pen, topright, bottomright);
                                        }
                                        if (up == 1)
                                        {
                                            g_impass.DrawLine(mid_impass_pen, topleft, topright);
                                        }
                                        if (down == 1)
                                        {
                                            g_impass.DrawLine(mid_impass_pen, botttomleft, bottomright);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                impass_pen.Dispose();
                mid_impass_pen.Dispose();
                Console.WriteLine("writing impass map");
                NetVips.Image netimg = BitmapConverter.ToVips(bitmap);
                netimg = netimg.Resize(2, "VIPS_KERNEL_NEAREST");
                netimg.WriteToFile(impass_fullmap);
            }
            CutMap(impass_fullmap, base_dir + "/impass_tiles", 10);
        }