예제 #1
0
        public void test(int x, int y)
        {
            Ultima.Tile l = Ultima.Map.Felucca.Tiles.GetLandTile(x, y);
            var         i = DataFiles.Tiledata.GetLand(l.ID);

            UO.Print(i.Flags.ToString());
        }
예제 #2
0
        private void onMouseMove(object sender, MouseEventArgs e)
        {
            int xDelta = Math.Min(origmap.Width, (int)(e.X / Zoom) + Round(hScrollBar.Value));
            int yDelta = Math.Min(origmap.Height, (int)(e.Y / Zoom) + Round(vScrollBar.Value));

            CoordsLabel.Text = String.Format("Coords: {0},{1}", xDelta, yDelta);
            string diff = "";

            if (moving)
            {
                toolTip1.RemoveAll();
                int deltax = (int)(-1 * (e.X - movingpoint.X) / Zoom);
                int deltay = (int)(-1 * (e.Y - movingpoint.Y) / Zoom);
                movingpoint.X    = e.X;
                movingpoint.Y    = e.Y;
                hScrollBar.Value = Math.Max(0, Math.Min(hScrollBar.Maximum, hScrollBar.Value + deltax));
                vScrollBar.Value = Math.Max(0, Math.Min(vScrollBar.Maximum, vScrollBar.Value + deltay));
                pictureBox.Invalidate();
            }
            else if ((Zoom >= 2) && (currmap != null))
            {
                if (BlockDiff(xDelta >> 3, yDelta >> 3))
                {
                    Ultima.Tile customTile = currmap.Tiles.GetLandTile(xDelta, yDelta);
                    Ultima.Tile origTile   = origmap.Tiles.GetLandTile(xDelta, yDelta);
                    if ((customTile.ID != origTile.ID) || (customTile.Z != origTile.Z))
                    {
                        diff = String.Format("Tile:\n\r0x{0:X} {1} -> 0x{2:X} {3}\n\r", origTile.ID, origTile.Z, customTile.ID, customTile.Z);
                    }
                    Ultima.HuedTile[] customStatics = currmap.Tiles.GetStaticTiles(xDelta, yDelta);
                    Ultima.HuedTile[] origStatics   = origmap.Tiles.GetStaticTiles(xDelta, yDelta);
                    if (customStatics.Length != origStatics.Length)
                    {
                        diff += "Statics:\n\rorig:\n\r";
                        foreach (Ultima.HuedTile tile in origStatics)
                        {
                            diff += String.Format("0x{0:X} {1} {2}\n\r", tile.ID, tile.Z, tile.Hue);
                        }
                        diff += "new:\n\r";
                        foreach (Ultima.HuedTile tile in customStatics)
                        {
                            diff += String.Format("0x{0:X} {1} {2}\n\r", tile.ID, tile.Z, tile.Hue);
                        }
                    }
                    else
                    {
                        bool changed = false;
                        for (int i = 0; i < customStatics.Length; i++)
                        {
                            if ((customStatics[i].ID != origStatics[i].ID) ||
                                (customStatics[i].Z != origStatics[i].Z) ||
                                (customStatics[i].Hue != origStatics[i].Hue))
                            {
                                if (!changed)
                                {
                                    diff   += "Statics diff:\n\r";
                                    changed = true;
                                }
                                diff += String.Format("0x{0:X} {1} {2} -> 0x{3:X} {4} {5}\n\r",
                                                      origStatics[i].ID, origStatics[i].Z, origStatics[i].Hue,
                                                      customStatics[i].ID, customStatics[i].Z, customStatics[i].Hue);
                            }
                        }
                    }
                }
                toolTip1.SetToolTip(pictureBox, diff);
                pictureBox.Invalidate();
            }

            if ((Zoom >= 2) && (markDiffToolStripMenuItem.Checked) && (String.IsNullOrEmpty(diff)))
            {
                Ultima.Map drawmap;
                if (showMap1ToolStripMenuItem.Checked)
                {
                    drawmap = origmap;
                }
                else
                {
                    drawmap = currmap;
                }
                if (drawmap.Tiles.Patch.LandBlocksCount > 0)
                {
                    if (drawmap.Tiles.Patch.IsLandBlockPatched(xDelta >> 3, yDelta >> 3))
                    {
                        Ultima.Tile patchTile = drawmap.Tiles.Patch.GetLandTile(xDelta, yDelta);
                        Ultima.Tile origTile  = drawmap.Tiles.GetLandTile(xDelta, yDelta, false);
                        diff = String.Format("Tile:\n\r0x{0:X} {1} -> 0x{2:X} {3}\n\r", origTile.ID, origTile.Z, patchTile.ID, patchTile.Z);
                    }
                }
                if (drawmap.Tiles.Patch.StaticBlocksCount > 0)
                {
                    if (drawmap.Tiles.Patch.IsStaticBlockPatched(xDelta >> 3, yDelta >> 3))
                    {
                        Ultima.HuedTile[] patchStatics = drawmap.Tiles.Patch.GetStaticTiles(xDelta, yDelta);
                        Ultima.HuedTile[] origStatics  = drawmap.Tiles.GetStaticTiles(xDelta, yDelta, false);
                        diff += "Statics:\n\rorig:\n\r";
                        foreach (Ultima.HuedTile tile in origStatics)
                        {
                            diff += String.Format("0x{0:X} {1} {2}\n\r", tile.ID, tile.Z, tile.Hue);
                        }
                        diff += "patch:\n\r";
                        foreach (Ultima.HuedTile tile in patchStatics)
                        {
                            diff += String.Format("0x{0:X} {1} {2}\n\r", tile.ID, tile.Z, tile.Hue);
                        }
                    }
                }
                toolTip1.SetToolTip(pictureBox, diff);
                pictureBox.Invalidate();
            }
        }
예제 #3
0
        public static Field GetField(ushort x, ushort y)
        {
            StaticTree t = new StaticTree();
            Field      f = new Field();

            f.X = x;
            f.Y = y;
            var l = Ultima.Map.Felucca.Tiles.GetStaticTiles(x, y);

            if (l.Length == 0)
            {
                Ultima.Tile tl = Ultima.Map.Felucca.Tiles.GetLandTile(x, y);
                var         i  = DataFiles.Tiledata.GetLand(tl.ID);
                if (i.Name.Contains("forest") || i.Name.Contains("grass"))
                {
                    f.IsWalkable = true;
                    f.IsTree     = false;
                    f.Tree       = new StaticTree();
                }
                else
                {
                    if (((DataFiles.Tiledata.GetArt(tl.ID).Flags & MulLib.TileData.Flags.Impassible) != 0))
                    {
                        f.IsWalkable = true;
                        f.IsTree     = false;
                        f.Tree       = new StaticTree();
                    }
                    else
                    {
                        f.IsWalkable = false;
                        f.IsTree     = false;
                        f.Tree       = new StaticTree();
                    }
                }
                return(f);
            }
            else
            {
                foreach (var i in l)
                {
                    if (DataFiles.Tiledata.GetArt(i.ID).Name.Contains("tree"))
                    {
                        t.ID        = i.ID;
                        t.X         = x;
                        t.Y         = y;
                        t.Z         = (sbyte)i.Z;
                        t.Harvested = DateTime.MinValue;

                        f.IsWalkable = false;
                        f.IsTree     = true;
                        f.Tree       = t;
                        return(f);
                    }
                    if (((DataFiles.Tiledata.GetArt(i.ID).Flags & MulLib.TileData.Flags.Impassible) == 0))
                    {
                        f.IsWalkable = true;
                        f.IsTree     = false;
                        f.Tree       = t;
                        return(f);
                    }
                    else
                    {
                        f.IsWalkable = false;
                        f.IsTree     = false;
                        f.Tree       = t;
                    }
                }
                return(f);
                //if (l.Length == 1 & !DataFiles.Tiledata.GetArt(l[0].ID).Name.Contains("tree"))
                //{
                //    if (((DataFiles.Tiledata.GetArt(l[0].ID).Flags & MulLib.TileData.Flags.Impassible) != 0))
                //    {
                //        f.IsWalkable = false;
                //        f.IsTree = false;
                //        f.Tree = new StaticTree();
                //    }
                //    else
                //    {
                //        f.IsWalkable = true;
                //        f.IsTree = false;
                //        f.Tree = new StaticTree();
                //    }
                //    return f;
                //}
                //else
                //{
                //    for (var i = 0; i < l.Length; i++)
                //    {
                //        var data = DataFiles.Tiledata.GetArt(l[i].ID);
                //        if (data.Name.Contains("tree"))
                //        {
                //            t.ID = l[i].ID;
                //            t.X = x;
                //            t.Y = y;
                //            t.Z = (sbyte)l[i].Z;
                //            t.Harvested = DateTime.MinValue;

                //            f.IsWalkable = false;
                //            f.IsTree = true;
                //            f.Tree = t;
                //            return f;
                //        }

                //    }
                //}
            }
        }