private int?FindMapNeighbour(MapPositionData map, int deltaX, int deltaY) { int?bySubArea = map.SubAreaId != null?m_subAreaMaps.GetBestMap(map.SubAreaId.Value, map.X + deltaX, map.Y + deltaY) : null; if (bySubArea != null) { return(bySubArea); } int?byArea = map.AreaId != null?m_areaChildrens.GetBestMap(map.AreaId.Value, map.X + deltaX, map.Y + deltaY) : null; if (byArea != null) { return(byArea); } int?bySuperArea = map.SuperAreaId != null?m_superAreaChildrens.GetBestMap(map.SuperAreaId.Value, map.X + deltaX, map.Y + deltaY) : null; if (bySuperArea != null) { return(bySuperArea); } int?byWorldMap = map.WorldMapId != null?m_worldMapsChildrens.GetBestMap(map.WorldMapId.Value, map.X + deltaX, map.Y + deltaY) : null; if (byWorldMap != null) { return(byWorldMap); } return(null); }
public void HandleChangeMapMessage(Bot bot, ChangeMapMessage message) { MapPositionData mapPosition = MapsPositionManager.Instance.GetMapPosition(message.mapId); if (m_lastPath != null && m_lastMapPos != null) { MapNeighbour direction = Map.GetDirectionOfTransitionCell(m_lastPath.End); int? neighbour = m_lastMapPos.GetNeighbourId(direction); if (neighbour == null) { bot.Character.SendWarning("The actual map ({0}) is not the {1} neighbour of the previous map {2} (NOT FOUND)", message.mapId, direction, m_lastMapPos.MapId); } else if (neighbour != message.mapId) { bot.Character.SendWarning("The actual map ({0}) is not the {1} neighbour of the previous map {2}" + "(MISMATCH attempt : {3})", message.mapId, direction, m_lastMapPos.MapId, neighbour); } else { bot.Character.SendDebug("You came from {0}", direction); } } m_lastMapPos = mapPosition; }
private IEnumerable <int?> FindMapNeighbours(MapPositionData map) { // right, top, left, bottom yield return(FindMapNeighbour(map, 1, 0)); yield return(FindMapNeighbour(map, 0, -1)); yield return(FindMapNeighbour(map, -1, 0)); yield return(FindMapNeighbour(map, 0, 1)); }