public void Init() { _world = new InMemoryWorld(); _map = new FacilityMap(_world); _sampleLayer = new FacilityLayer(); _sampleSpace = new FacilitySpace(); }
public void Init() { ObjectLayer = ObjectLayer.GroundPlaceable; _map = new FacilityMap(new InMemoryWorld()); _layer = new FacilityLayer(2, 2); _map.Add(_layer); }
public void FacilityMap_SinglePortalMapInstruction_LayersAndPortalsCorrect() { var map = new FacilityMap(_world, CreateInstruction("Layer:Size=1,1", "Portal-Door:0,0,0;End1=(OffMap);End2=(OffMap)")); Assert.AreEqual(1, map.LayerCount); Assert.AreEqual(1, map.Portals.Count()); }
public void GenerateWalls(FacilityMap map) { foreach (var layer in map) { GenerateWalls(layer.Obj); } }
private FacilityMap CreateEmptyMap() { var map = new FacilityMap(new InMemoryWorld()); _layer = new FacilityLayer(3, 3); map.Add(_layer); return(map); }
public Thief(IBody thiefBody, FacilityMap map, IDesires desires, IPathFinder pathFinder, int itemCapacity) { _thiefBody = thiefBody; _desires = desires; _map = map; _pathFinder = pathFinder; ItemsRemaining = itemCapacity; CurrentLocation = SpecialLocation.OffOfMap; }
private string SetRouteDisplayMap(int mapId, DateTime startTime, DateTime endTime, int hostId, string hostName, double moveSpeed, string iconFile, IList <TagPositionLog> tracks) { StringBuilder sb = new StringBuilder(); Facility facility = Facility.All.SingleOrDefault(f => f.MapId == mapId); FacilityMap facilityMap = FacilityMap.SelectFacilityMapById(mapId); if (facility != null && facilityMap != null) { sb.Append(this.GetFacilityInnerXml(facility, facilityMap, endTime)); sb.AppendLine(string.Format(" <tag id=\"{0}\" name=\"{1}\" moveSpeed=\"{2}\" icon=\"{3}\">", hostId, hostName, moveSpeed.ToString("#.#"), iconFile)); //sb.AppendLine(" <tag id=\"" + tags[0].HostId + "\" name=\"" + tags[0].HostName + "\" moveSpeed=\"0.5\" icon=\"../images/person.gif\">"); sb.Append(this.GetRouteInnerXml(tracks)); sb.AppendLine(" </tag>"); sb.AppendLine(" </routeDisplaymap>"); } return(sb.ToString()); }
private string GetFacilityInnerXml(Facility facility, FacilityMap facilityMap, DateTime endTime) { StringBuilder sb = new StringBuilder(); IList <MapArea> areas; areas = this.GetAreaList(facility.MapId); sb.AppendLine(" <routeDisplaymap>"); sb.AppendLine(" <facilityInfo>"); sb.AppendLine(" <facilityName>"+ facility.FacilityName + "</facilityName>"); sb.AppendLine(" <facilityEastWest>"+ facilityMap.FacilityEastWest + "</facilityEastWest>"); sb.AppendLine(" <facilityNorthSouth>"+ facilityMap.FacilitySouthNorth + "</facilityNorthSouth>"); sb.AppendLine(" <facilityMap>"+ WebConfig.BasePath + "/Objects/MapFile.ashx?id=" + facilityMap.Id + "</facilityMap>"); sb.AppendLine(" <facilityEndTime>"+ endTime.ToString("yyyy/M/d H:mm:ss").Replace("-", "/") + "</facilityEndTime>"); sb.AppendLine(" <facilityArea>"); sb.Append(this.GetAreaInnerXml(areas)); sb.AppendLine(" </facilityArea>"); sb.AppendLine(" </facilityInfo>"); return(sb.ToString()); }
public EraseCommand(FacilityMap map, XYZ location) { _map = map; _location = location; }
public void FacilityMap_EmptyMapInstruction_EmptyMapReturned() { var map = new FacilityMap(_world, CreateInstruction()); Assert.AreEqual(0, map.LayerCount); }
public PatrolRouteProposal(FacilityMap map, XYZ startingNode, Action <IEnumerable <Path> > onChange) : this(new CachedPathFinder(map), startingNode, new ObservableList <Path>(onChange)) { }
public Thief(IBody thiefBody, FacilityMap map, IDesires desires) : this(thiefBody, map, desires, new CachedPathFinder(map), 1) { }
public EditCommand(FacilityMap map, XYZ location, IEngineer engineer) { _map = map; _location = location; _engineer = engineer; }
public SingleMemberThiefTeam(FacilityMap map) : base(new List <Thief> { new Thief(new BodyDummy(), map) }) { }
public void Init() { _map = new FacilityMap(new InMemoryWorld()); _layer = new FacilityLayer(2, 2); _map.Add(_layer); }
public LayeredPathFinder(FacilityMap map) { _map = map; }
public ThiefTeamFactoryStub(FacilityMap map) : this(new SingleMemberThiefTeam(map)) { }
public BuildCommand(FacilityMap map, XYZ location, SecurityObjectBase securityObject) { _map = map; _securityObject = securityObject; _location = location; }
public InspectCommand(FacilityMap map, XYZ location, IInspector inspector) { _map = map; _location = location; _inspector = inspector; }
public void ProcessRequest(HttpContext context) { context.Response.Buffer = true; context.Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1); context.Response.Expires = 0; context.Response.CacheControl = "no-cache"; int mapId = Fetch.QueryUrlAsIntegerOrDefault("mapId", 0); int[] hostIdArray = Strings.ParseToArray <int>(Fetch.QueryUrl("tagId")); int requestSeconds = Fetch.QueryUrlAsInteger("minutes"); int seconds = requestSeconds * 60; DateTime startTime; if (requestSeconds < 0) { seconds = Math.Abs(requestSeconds); startTime = DateTime.Now.AddSeconds(-seconds); } else { startTime = DateTime.Parse(Fetch.QueryUrl("startTime")); } Facility facility; FacilityMap facilityMap; HostTag[] tags; using (AppDataContext db = new AppDataContext()) { tags = db.HostTags.Where(h => hostIdArray.Contains(h.HostId)).ToArray(); if (tags.Length == 0) { return; } } StringBuilder sb = new StringBuilder(); sb.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); sb.AppendLine("<routeDisplay>"); sb.AppendLine(" <title>" + (requestSeconds < 0 ? "标签实时定位" : "标签历史轨迹") + "</title>"); sb.AppendLine(" <loop>" + (requestSeconds < 0 ? "True" : "False") + "</loop>"); sb.AppendLine(" <timeInfo>"); sb.AppendLine(" <fromTime>"+ startTime.ToString("yyyy/M/d H:mm:ss").Replace("-", "/") + "</fromTime>"); sb.AppendLine(" <toTime>"+ startTime.AddSeconds(seconds + 1).ToString("yyyy/M/d H:mm:ss").Replace("-", "/") + "</toTime>"); sb.AppendLine(" <timeZone>GMT"+ (Fetch.ServerUtcOffset > 0 ? "+" : "-") + Math.Abs(Fetch.ServerUtcOffset) + "</timeZone>"); sb.AppendLine(" </timeInfo>"); DateTime endTime; if (mapId > 0 && hostIdArray.Length >= 1) { facility = Facility.All.SingleOrDefault(f => f.MapId == mapId); if (facility == null) { return; } facilityMap = FacilityMap.SelectFacilityMapById(mapId); if (facilityMap == null) { return; } endTime = startTime.AddSeconds(seconds + 1); sb.Append(this.GetFacilityInnerXml(facility, facilityMap, endTime)); foreach (var tag in tags) { IList <TagPositionLog> tracks = this.GetPositionList(tag.HostId, startTime, seconds).Where(t => t.MapId == mapId).ToList(); if (tracks.Count == 0) { continue; } sb.AppendLine(" <tag id=\"" + tag.HostId + "\" name=\"" + tag.HostName + "\" moveSpeed=\"0.5\" icon=\"" + CommonExtension.IdentityIcon(tag.TagId) + "\">"); sb.Append(this.GetRouteInnerXml(tracks)); sb.AppendLine(" </tag>"); } sb.AppendLine(" </routeDisplaymap>"); } else { IList <TagPositionLog> tracksall = this.GetPositionList(tags[0].HostId, startTime, seconds); IList <TagPositionLog> tracks = new List <TagPositionLog>(); string iconFile = CommonExtension.IdentityIcon(tags[0].TagId); for (int i = 0; i < tracksall.Count; i++) { if (tracksall[i].MapId == 0) { continue; } if (mapId != tracksall[i].MapId) { if (tracks.Count > 0) { if (i + 1 == tracksall.Count) { endTime = startTime.AddSeconds(seconds); } else { endTime = tracksall[i].WriteTime; } sb.AppendLine(SetRouteDisplayMap(mapId, startTime, endTime, tags[0].HostId, tags[0].HostName, 0.5, iconFile, tracks)); } mapId = tracksall[i].MapId; tracks = new List <TagPositionLog>(); tracks.Add(tracksall[i]); } else { tracks.Add(tracksall[i]); if (i + 1 == tracksall.Count) { endTime = startTime.AddSeconds(seconds + 1); sb.AppendLine(SetRouteDisplayMap(mapId, startTime, endTime, tags[0].HostId, tags[0].HostName, 0.5, iconFile, tracks)); } } } if (tracks.Count == 1) { endTime = startTime.AddSeconds(seconds + 1); sb.AppendLine(SetRouteDisplayMap(mapId, startTime, endTime, tags[0].HostId, tags[0].HostName, 0.5, iconFile, tracks)); } } sb.AppendLine("</routeDisplay>"); context.Response.ContentType = "text/xml"; context.Response.Write(sb.ToString()); }
public CachedPathFinder(FacilityMap map) : this(new LayeredPathFinder(map)) { }
public Thief(IBody thiefBody, FacilityMap map) : this(thiefBody, map, new ThiefDesires(map.SpatialValuables)) { }
public void Init() { _map = new FacilityMap(new InMemoryWorld()); _team = new SingleMemberThiefTeam(_map); }
public Thief(IBody thiefBody, FacilityMap map, IDesires desires, int itemCapacity) : this(thiefBody, map, desires, new CachedPathFinder(map), itemCapacity) { }
public SimpleThiefTeamFactory(Func <IBody> bodyFactory, FacilityMap map) { _bodyFactory = bodyFactory; _map = map; }
public void Init() { _map = new FacilityMap(new InMemoryWorld()); _map.Add(new FacilityLayer(3, 3)); }
public PatrolRouteProposal(FacilityMap map, PatrolRoute route, Action <IEnumerable <Path> > onChange) : this(new CachedPathFinder(map), route.Route.Last().Destination, new ObservableList <Path>(route.Route.ToList(), onChange)) { }