Exemplo n.º 1
0
        public void Add(Tile tile)
        {
            lock (queue)
            {
                if (thread == null)
                    return;

                queue.Enqueue(new Tile(tile));
                Monitor.Pulse(queue);
            }
        }
Exemplo n.º 2
0
        public void SetTile(Tile tile)
        {
            var location = tile.Location;
            var oldTile = tiles[location.X % 18, location.Y % 14, location.Z % 8];

            tiles[location.X % 18, location.Y % 14, location.Z % 8] = tile;

            knowMap[tile.Location.ToIndex()] = tile.IsBlocked;

            if (oldTile != null && location.Equals(oldTile.Location))
                OnTileUpdated(tile);
            else
                OnTileAdded(tile);
        }
Exemplo n.º 3
0
 public Tile(Tile tile)
 {
     Location = tile.Location;
     things = new List<Thing>(tile.things);
 }
Exemplo n.º 4
0
 protected void OnTileUpdated(Tile tile)
 {
     TileUpdated.Raise(this, new TileUpdatedEventArgs(tile));
 }
Exemplo n.º 5
0
 public TileUpdatedEventArgs(Tile tile)
     : base(tile)
 {
 }
Exemplo n.º 6
0
 public TileEventArgs(Tile tile)
 {
     this.Tile = tile;
 }
Exemplo n.º 7
0
 public TileAddedEventArgs(Tile tile)
     : base(tile)
 {
 }
        private Tile ParseServerTileDescription(InMessage message, Location location)
        {
            Tile tile = new Tile(location);
            if (message.PeekUShort() < 0xFF00)
                message.ReadUShort();

            while (message.PeekUShort() < 0xFF00)
                tile.AddThing(GetThing(message));

            client.Map.SetTile(tile);
            return tile;
        }
Exemplo n.º 9
0
        private void SendTile(Tile tile)
        {
            message.Reset();
            message.WriteByte(0x01);

            message.WriteLocation(tile.Location);
            message.WriteByte((byte)tile.ThingCount);

            for (int i = 0; i < tile.ThingCount; i++)
            {
                var thing = tile.GetThing(i);

                if (thing is Creature)
                {
                    var cr = thing as Creature;
                    message.WriteByte(0x01);
                    message.WriteUInt(cr.Id);
                    message.WriteString(cr.Name);
                    message.WriteByte((byte)cr.Type);
                }
                else
                {
                    var item = thing as Item;
                    message.WriteByte(0x02);
                    message.WriteUShort((ushort)item.Id);
                    message.WriteByte(item.SubType);
                }
            }

            message.WriteInternalHead();
            Adler.Generate(message, true);
            message.WriteHead();

            connection.Send(message);
        }