public MapNpc(Npc npc, Vector position)
 {
     this.Name = npc.Name;
     this.Level = npc.Level;
     this.TextureNumber = npc.TextureNumber;
     this.Position = position;
 }
 public MapItem(Item item, Vector position, int spawnDuration = -1)
 {
     this.Item = item;
     this.Position = position;
     this.SpawnDuration = spawnDuration;
 }
        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
        }
        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);
 }
Exemple #6
0
 public void MoveTo(Vector vector, byte direction)
 {
     throw new NotImplementedException();
 }
Exemple #7
0
        public void SpawnMapNpc(Npc npc, Vector position)
        {
            this.mapNpcs.Add(new MapNpc(npc, position));

            // TODO: send the spawn packet.
        }
Exemple #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);
        }
Exemple #9
0
 public void SetTile(Vector position, Tile tile)
 {
     this.SetTile(position.X, position.Y, tile);
 }
Exemple #10
0
 public Tile GetTile(Vector position)
 {
     return this.GetTile(position.X, position.Y);
 }
Exemple #11
0
 public MapItem GetMapItem(Vector mapItemPos)
 {
     return this.items.FirstOrDefault(mapItem => mapItem.Position == mapItemPos);
 }