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); }
public void MoveTo(Vector vector, byte direction) { throw new NotImplementedException(); }
public void SpawnMapNpc(Npc npc, Vector position) { this.mapNpcs.Add(new MapNpc(npc, position)); // TODO: send the spawn packet. }
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); }
public void SetTile(Vector position, Tile tile) { this.SetTile(position.X, position.Y, tile); }
public Tile GetTile(Vector position) { return this.GetTile(position.X, position.Y); }
public MapItem GetMapItem(Vector mapItemPos) { return this.items.FirstOrDefault(mapItem => mapItem.Position == mapItemPos); }