public bool TestPattern(System.Drawing.Point center, MapRecord map) { bool result; try { bool bluesOk; bool redsOk; if (this.Relativ) { bluesOk = this.Blues.All((System.Drawing.Point entry) => map.Walkable(entry.X + center.X, entry.Y + center.Y)); redsOk = this.Reds.All((System.Drawing.Point entry) => map.Walkable(entry.X + center.X, entry.Y + center.Y)); } else { bluesOk = this.Blues.All((System.Drawing.Point entry) => map.Walkable(entry.X, entry.Y)); redsOk = this.Reds.All((System.Drawing.Point entry) => map.Walkable(entry.X, entry.Y)); } result = (bluesOk && redsOk); } catch (Exception) { result = false; } return(result); }
public static ushort GetTeleporterCell(MapRecord map, InteractiveElementRecord ele) { ushort cellId = (ushort)ele.Point.GetCellInDirection(DirectionsEnum.DIRECTION_SOUTH_WEST, 1).CellId; if (!map.Walkable(cellId)) { ushort[] array = map.CloseCells(ele.CellId); cellId = array.Length == 0 ? map.RandomWalkableCell() : array[0]; } return(cellId); }
public static List <Node> GetNodes(MapRecord map) { var nodes = new List <Node>(); for (short cell = 0; cell < 560; cell++) { var node = new Node(CoordCells.GetCell(cell)); node.Walkable = map.Walkable((ushort)cell); nodes.Add(node); } return(nodes); }
public static void ChangeMapMessage(ChangeMapMessage message, WorldClient client) { MapScrollEnum scrollType = MapScrollEnum.UNDEFINED; if (client.Character.Map.LeftMap == message.mapId) { scrollType = MapScrollEnum.Left; } if (client.Character.Map.RightMap == message.mapId) { scrollType = MapScrollEnum.Right; } if (client.Character.Map.DownMap == message.mapId) { scrollType = MapScrollEnum.Bottom; } if (client.Character.Map.TopMap == message.mapId) { scrollType = MapScrollEnum.Top; } if (scrollType != MapScrollEnum.UNDEFINED) { int overrided = ScrollActionRecord.GetOverrideScrollMapId(client.Character.Map.Id, scrollType); ushort cellid = ScrollActionRecord.GetScrollDefaultCellId(client.Character.Record.CellId, scrollType); client.Character.Record.Direction = ScrollActionRecord.GetScrollDirection(scrollType); int teleportMapId = overrided != -1 ? overrided : message.mapId; if (overrided == 0) { teleportMapId = message.mapId; } MapRecord teleportedMap = MapRecord.GetMap(teleportMapId); if (teleportedMap != null) { cellid = teleportedMap.Walkable(cellid) ? cellid : ScrollActionRecord.SearchScrollCellId(cellid, scrollType, teleportedMap); client.Character.Teleport(teleportMapId, cellid); } else { client.Character.ReplyError("This map cannot be founded"); } } else { scrollType = ScrollActionRecord.GetScrollTypeFromCell((short)client.Character.Record.CellId); if (scrollType == MapScrollEnum.UNDEFINED) { client.Character.ReplyError("Unknown Map Scroll Action..."); } else { int overrided = ScrollActionRecord.GetOverrideScrollMapId(client.Character.Map.Id, scrollType); ushort cellid = ScrollActionRecord.GetScrollDefaultCellId(client.Character.Record.CellId, scrollType); MapRecord teleportedMap = MapRecord.GetMap(overrided); if (teleportedMap != null) { client.Character.Record.Direction = ScrollActionRecord.GetScrollDirection(scrollType); cellid = teleportedMap.Walkable(cellid) ? cellid : ScrollActionRecord.SearchScrollCellId(cellid, scrollType, teleportedMap); client.Character.Teleport(overrided, cellid); } else { client.Character.ReplyError("This map cannot be founded"); } } } }
public static void HandleChangeMap(ChangeMapMessage message, WorldClient client) { MapScrollType scrollType = MapScrollType.UNDEFINED; if (client.Character.Map.LeftMap == message.mapId) { scrollType = MapScrollType.LEFT; } if (client.Character.Map.RightMap == message.mapId) { scrollType = MapScrollType.RIGHT; } if (client.Character.Map.DownMap == message.mapId) { scrollType = MapScrollType.BOTTOM; } if (client.Character.Map.TopMap == message.mapId) { scrollType = MapScrollType.TOP; } if (scrollType != MapScrollType.UNDEFINED) { int overrided = MapScrollActionRecord.GetOverrideScrollMapId(client.Character.Map.Id, scrollType); short cellid = MapScrollActionRecord.GetScrollDefaultCellId(client.Character.Record.CellId, scrollType); client.Character.Record.Direction = MapScrollActionRecord.GetScrollDirection(scrollType); int teleportMapId = overrided != -1 ? overrided : message.mapId; if (overrided == 0) { teleportMapId = message.mapId; } MapRecord teleportedMap = MapRecord.GetMap(teleportMapId); if (teleportedMap != null) { cellid = teleportedMap.Walkable(cellid) ? cellid : MapScrollActionRecord.SearchScrollCellId(cellid, scrollType, teleportedMap); client.Character.Teleport(teleportMapId, cellid); } else { client.Character.NotificationError("This map cannot be founded"); } } else { scrollType = MapScrollActionRecord.GetScrollTypeFromCell(client.Character.Record.CellId); if (scrollType == MapScrollType.UNDEFINED) { client.Character.NotificationError("Unknown Map Scroll Action..."); } else { int overrided = MapScrollActionRecord.GetOverrideScrollMapId(client.Character.Map.Id, scrollType); short cellid = MapScrollActionRecord.GetScrollDefaultCellId(client.Character.Record.CellId, scrollType); MapRecord teleportedMap = MapRecord.GetMap(overrided); if (teleportedMap != null) { client.Character.Record.Direction = MapScrollActionRecord.GetScrollDirection(scrollType); cellid = teleportedMap.Walkable(cellid) ? cellid : MapScrollActionRecord.SearchScrollCellId(cellid, scrollType, teleportedMap); client.Character.Teleport(overrided, cellid); } else { client.Character.NotificationError("This map cannot be founded"); } } } }