Пример #1
0
 private void WriteStatic(BinaryWriter bw, HuedTile stat)
 {
     bw.Write((ushort)stat.ID);
     bw.Write((ushort)0);
     bw.Write((sbyte)stat.Z);
     bw.Write((ushort)stat.Hue);
 }
 public HuedTile[] ToArray()
 {
     HuedTile[] huedTileArray = new HuedTile[this.m_Count];
       for (int index = 0; index < this.m_Count; ++index)
     huedTileArray[index] = this.m_Tiles[index];
       this.m_Count = 0;
       return huedTileArray;
 }
Пример #3
0
        private void ExtractFrozenItems(Rect2D rect, string mapName, bool hued)
        {
            Map map = GetMapByName(mapName);

            if (map == null)
            {
                MessageBox.Show("Failed to extract the frozen items from the map " + mapName);
            }
            else
            {
                int xCount = rect.TopX + rect.Width;
                int yCount = rect.TopY + rect.Height;

                for (int x = rect.TopX; x < xCount; ++x)
                {
                    for (int y = rect.TopY; y < yCount; ++y)
                    {
                        HuedTile[] tiles = map.Tiles.GetStaticTiles(x, y);

                        if (tiles == null || tiles.Length == 0)
                        {
                            continue;
                        }

                        for (int i = 0; i < tiles.Length; ++i)
                        {
                            HuedTile tile = tiles[i];

                            if (_useMinZ && tile.Z < _minZ)
                            {
                                continue;
                            }
                            else if (_useMaxZ && tile.Z > _maxZ)
                            {
                                continue;
                            }

                            DesignItem item = new DesignItem();

                            item.ItemID = (short)(tile.ID ^ 0x4000);
                            item.X      = x;
                            item.Y      = y;
                            item.Z      = tile.Z;

                            if (hued)
                            {
                                item.Hue = (short)tile.Hue;
                            }

                            if (_items.IndexOf(item) == -1)
                            {
                                _items.Add(item);
                            }
                        }
                    }
                }
            }
        }
 public HuedTile[] ToArray()
 {
     HuedTile[] huedTileArray = new HuedTile[this.m_Count];
     for (int index = 0; index < this.m_Count; ++index)
     {
         huedTileArray[index] = this.m_Tiles[index];
     }
     this.m_Count = 0;
     return(huedTileArray);
 }
Пример #5
0
        public HuedTile[] ToArray()
        {
            HuedTile[] tiles = new HuedTile[_count];

            for (int i = 0; i < _count; ++i)
                tiles[i] = _tiles[i];

            _count = 0;

            return tiles;
        }
Пример #6
0
        public HuedTile[] ToArray()
        {
            var tiles = new HuedTile[Count];

            for(var i = 0; i < Count; ++i)
            {
                tiles[i] = _tiles[i];
            }

            Count = 0;

            return tiles;
        }
Пример #7
0
 public void Add(HuedTile tile)
 {
     if (this.m_Count + 1 > this.m_Tiles.Length)
     {
         HuedTile[] huedTileArray = this.m_Tiles;
         this.m_Tiles = new HuedTile[huedTileArray.Length * 2];
         for (int index = 0; index < huedTileArray.Length; ++index)
         {
             this.m_Tiles[index] = huedTileArray[index];
         }
     }
     this.m_Tiles[this.m_Count++] = tile;
 }
Пример #8
0
        public HuedTile[] ToArray()
        {
            HuedTile[] tiles = new HuedTile[_count];

            for (int i = 0; i < _count; ++i)
            {
                tiles[i] = _tiles[i];
            }

            _count = 0;

            return(tiles);
        }
Пример #9
0
        public HuedTile[] ToArray()
        {
            var tiles = new HuedTile[Count];

            for (var i = 0; i < Count; ++i)
            {
                tiles[i] = _tiles[i];
            }

            Count = 0;

            return(tiles);
        }
Пример #10
0
        public HuedTile[] ToArray()
        {
            HuedTile[] tiles = new HuedTile[m_Count];

            for (int i = 0; i < m_Count; ++i)
            {
                tiles[i] = m_Tiles[i];
            }

            m_Count = 0;

            return(tiles);
        }
Пример #11
0
 public HuedTile[] ToArray()
 {
     if (this.m_Count == 0)
     {
         return(TileList.m_Empty);
     }
     HuedTile[] huedTileArray = new HuedTile[this.m_Count];
     for (int index = 0; index < this.m_Count; ++index)
     {
         huedTileArray[index] = this.m_Tiles[index];
     }
     this.m_Count = 0;
     return(huedTileArray);
 }
Пример #12
0
 private void WriteStatics(BinaryWriter writer, int x, int y)
 {
     HuedTile[] statics = tileMatrix.GetStaticTiles(x, y);
     if (statics != null && statics.Length > 0)
     {
         writer.Write((byte)statics.Length);                   //BYTE -> STATICScount
         for (int i = 0; i < statics.Length; i++)
         {
             HuedTile hued = statics[i];
             writer.Write((UInt32)(hued.ID - 16384));        //DWORD -> STATICgraphic (16384 is the offet dued to the presence in the art.mul of the map art tiles?)
             writer.Write(GetZ((sbyte)hued.Z));              //BYTE  -> STATIC_z
             writer.Write((UInt32)hued.Hue);                 //DWORD -> STATICcolor (hue)
         }
     }
     else
     {
         writer.Write((byte)0);                                //no statics in this tile
     }
     statics = null;
 }
Пример #13
0
        public static sbyte ZTop(int mapNum, int xCheck, int yCheck, int oldZ)
        {
            try
            {
                Ultima.Map map = GetMap(mapNum);

                Tile landTile = map.Tiles.GetLandTile(xCheck, yCheck);
                int  landZ = 0, landCenter = 0, zTop = 0;

                GetAverageZ(map, xCheck, yCheck, ref landZ, ref landCenter, ref zTop);

                if (zTop > oldZ)
                {
                    oldZ = zTop;
                }

                bool       isSet       = false;
                HuedTile[] staticTiles = map.Tiles.GetStaticTiles(xCheck, yCheck);
                for (int i = 0; i < staticTiles.Length; ++i)
                {
                    HuedTile tile = staticTiles[i];
                    ItemData id   = TileData.ItemTable[tile.ID & 0x3FFF];

                    int calcTop = (tile.Z + id.CalcHeight);

                    if (calcTop <= oldZ + 5 && (!isSet || calcTop > zTop) &&
                        ((id.Flags & TileFlag.Surface) != 0 || (id.Flags & TileFlag.Wet) != 0))
                    {
                        zTop  = calcTop;
                        isSet = true;
                    }
                }

                return((sbyte)zTop);
            }
            catch
            {
                return((sbyte)oldZ);
            }
        }
Пример #14
0
        private static bool IsOk(HuedTile tile, int ourZ, int ourTop)
        {
            var itemData = TileData.ItemTable[tile.ID & (TileData.ItemTable.Length - 1)];

            return(tile.Z + itemData.CalcHeight <= ourZ || ourTop <= tile.Z || (itemData.Flags & ImpassableSurface) == 0);
        }