Exemplo n.º 1
0
 public MapNpc(Npc npc, Vector position)
 {
     this.Name = npc.Name;
     this.Level = npc.Level;
     this.TextureNumber = npc.TextureNumber;
     this.Position = position;
 }
Exemplo n.º 2
0
 public MapItem(Item item, Vector position, int spawnDuration = -1)
 {
     this.Item = item;
     this.Position = position;
     this.SpawnDuration = spawnDuration;
 }
Exemplo n.º 3
0
        public void MoveTo(Vector vector, byte direction)
        {
            this.Direction = direction;

            //// If the tile is blocked, we obviously can't move to it.
            if (vector.X >= 0 && vector.Y >= 0 && vector.X < this.Map.MapWidth && vector.Y < this.Map.MapHeight && !this.Map.GetTile(vector).Blocked && !this.Map.GetTile(vector).IsOccupied)
            {
                // Unblock the previous tile so that another entity may occupy it.
                this.Map.GetTile(this.Position).IsOccupied = false;

                // Change our character's position to the new position.
                this.Position = vector;

                // Block the tile that we're moving to.
                this.Map.GetTile(vector).IsOccupied = true;
            }

            Packet packet = new Packet(PacketType.PlayerMovementPacket);
            packet.Message.Write(this.PlayerIndex);
            packet.Message.Write(this.Position);
            packet.Message.Write(direction);
            //this.Connection.SendMessage(packet, NetDeliveryMethod.ReliableOrdered, (int)ChannelTypes.WORLD);
            // SENDTOMAP
        }
Exemplo n.º 4
0
        public void TryPickupItem(Vector mapItemPos)
        {
            MapItem mapItem = this.Map.GetMapItem(mapItemPos);

            if (mapItem == null) return;

            this.Map.RemoveMapItem(mapItem);

            this.GiveItem(mapItem.Item);
        }
 public static void Write(this NetBuffer nb, Vector vector)
 {
     nb.Write(vector.X);
     nb.Write(vector.Y);
 }
Exemplo n.º 6
0
 public void MoveTo(Vector vector, byte direction)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 7
0
        public void SpawnMapNpc(Npc npc, Vector position)
        {
            this.mapNpcs.Add(new MapNpc(npc, position));

            // TODO: send the spawn packet.
        }
Exemplo n.º 8
0
        public void SpawnItem(Item item, Vector position, int spawnTime)
        {
            var mapItem = new MapItem(item, position, spawnTime);

            this.items.Add(mapItem);

            Packet packet = new Packet(PacketType.SpawnMapItemPacket);
            packet.Message.Write(mapItem.Item.Name);
            packet.Message.Write(mapItem.Item.TextureNumber);
            packet.Message.Write(mapItem.Position);
            packet.Message.Write(mapItem.SpawnDuration);
            this.SendPacket(packet, NetDeliveryMethod.ReliableOrdered, ChannelTypes.WORLD, true);
        }
Exemplo n.º 9
0
 public void SetTile(Vector position, Tile tile)
 {
     this.SetTile(position.X, position.Y, tile);
 }
Exemplo n.º 10
0
 public Tile GetTile(Vector position)
 {
     return this.GetTile(position.X, position.Y);
 }
Exemplo n.º 11
0
 public MapItem GetMapItem(Vector mapItemPos)
 {
     return this.items.FirstOrDefault(mapItem => mapItem.Position == mapItemPos);
 }