public void UpdateFloorToDimensions(VisualFloor floor) { // remove old walls ((IFloorEntity)floor.SourceEntity).Walls.RemoveAll(wall => wall.IsOuterWall); var toRemove = floor.MapEntities.Where(item => item is WallElement && ((WallElement)item).IsOuterWall).ToList(); if (toRemove != null) { for (int j = 0; j < toRemove.Count; j++) { foreach (VisualDoor door in ((WallElement)toRemove[j]).Doors) { floor.MapEntities.Remove(door); } floor.MapEntities.Remove(toRemove[j]); } } // update dimensions of map SetBoundingDimensions(); int i = 0; bool finished = false; Point offset = new Point(MapWidth / 2, MapHeight / 2); while (!finished) { Wall wall = new Wall() { Id = 0, Thickness = Constants.DefaultOutsideWallThickness, Name = Constants.DefaultOuterWallName, IsOuterWall = true }; WallElement visualWall = new WallElement(wall); visualWall.X1 = Corners[i].X + offset.X; visualWall.Y1 = Corners[i].Y + offset.Y; if (i == Corners.Count - 1) { visualWall.X2 = Corners[0].X + offset.X; visualWall.Y2 = Corners[0].Y + offset.Y; finished = true; } else { visualWall.X2 = Corners[i + 1].X + offset.X; visualWall.Y2 = Corners[i + 1].Y + offset.Y; i++; } floor.MapEntities.Add(visualWall); } }
public void CreateFloorFromDimensions() { VisualFloor newFloor = new VisualFloor(new Floor() { Name = Constants.DefaultFloorName }); UpdateFloorToDimensions(newFloor); Floors.Add(newFloor); if (CurrentFloor == null) { CurrentFloor = newFloor; } }