/// <summary> /// Draws a bundle of halls from one direction, going up to the specified point, and connects them. /// </summary> /// <param name="map"></param> /// <param name="dir"></param> /// <param name="forwardEnd"></param> /// <param name="starts"></param> public void DrawCombinedHall(ITiledGenContext map, Dir4 dir, int forwardEnd, int[] starts) { bool vertical = dir.ToAxis() == Axis4.Vert; // Choose whether to start at the min X/Y, or the max X/Y Loc forwardStartLoc = (dir == Dir4.Up || dir == Dir4.Left) ? this.Draw.Start : this.Draw.End - new Loc(1); IntRange start = this.Draw.GetSide(dir.ToAxis()); start.Max -= 1; start = new IntRange(start.Max, start.Min); // draw the halls for (int jj = 0; jj < starts.Length; jj++) { start.Min = Math.Min(start.Min, starts[jj]); start.Max = Math.Max(start.Max, starts[jj]); Loc startLoc = new Loc(vertical ? starts[jj] : forwardStartLoc.X, vertical ? forwardStartLoc.Y : starts[jj]); Loc endLoc = new Loc(vertical ? starts[jj] : forwardEnd, vertical ? forwardEnd : starts[jj]); this.DrawHall(map, startLoc, endLoc, vertical); } // combine the halls Loc combineStart = new Loc(vertical ? start.Min : forwardEnd, vertical ? forwardEnd : start.Min); Loc combineEnd = new Loc(vertical ? start.Max : forwardEnd, vertical ? forwardEnd : start.Max); this.DrawHall(map, combineStart, combineEnd, !vertical); }
public void DrawOnMap(ITiledGenContext map) { GenContextDebug.StepIn("Main Rooms"); for (int ii = 0; ii < this.Rooms.Count; ii++) { // take in the broad fulfillables from adjacent rooms that have not yet drawn IFloorRoomPlan plan = this.Rooms[ii]; foreach (RoomHallIndex adj in plan.Adjacents) { if (adj.IsHall || adj.Index > ii) { IRoomGen adjacentGen = this.GetRoomHall(adj).RoomGen; plan.RoomGen.ReceiveFulfillableBorder(adjacentGen, GetDirAdjacent(plan.RoomGen, adjacentGen)); } } plan.RoomGen.DrawOnMap(map); this.TransferBorderToAdjacents(new RoomHallIndex(ii, false)); GenContextDebug.DebugProgress("Draw Room"); } GenContextDebug.StepOut(); GenContextDebug.StepIn("Connecting Halls"); for (int ii = 0; ii < this.Halls.Count; ii++) { // take in the broad fulfillables from adjacent rooms that have not yet drawn IFloorRoomPlan plan = this.Halls[ii]; foreach (RoomHallIndex adj in plan.Adjacents) { if (adj.IsHall && adj.Index > ii) { IRoomGen adjacentGen = this.GetRoomHall(adj).RoomGen; plan.RoomGen.ReceiveFulfillableBorder(adjacentGen, GetDirAdjacent(plan.RoomGen, adjacentGen)); } } plan.RoomGen.DrawOnMap(map); this.TransferBorderToAdjacents(new RoomHallIndex(ii, true)); GenContextDebug.DebugProgress("Draw Hall"); } GenContextDebug.StepOut(); }
/// <summary> /// Draws a hall in a straight cardinal direction, starting with one point and ending with another (inclusive). /// </summary> /// <param name="map"></param> /// <param name="point1"></param> /// <param name="point2"></param> /// <param name="vertical"></param> private void DrawHall(ITiledGenContext map, Loc point1, Loc point2, bool vertical) { if (point1 == point2) { this.Brush.DrawHallBrush(map, this.Draw, point1, vertical); } else if (point1.X == point2.X) { if (point2.Y > point1.Y) { for (int ii = point1.Y; ii <= point2.Y; ii++) { this.Brush.DrawHallBrush(map, this.Draw, new Loc(point1.X, ii), vertical); } } else if (point2.Y < point1.Y) { for (int ii = point1.Y; ii >= point2.Y; ii--) { this.Brush.DrawHallBrush(map, this.Draw, new Loc(point1.X, ii), vertical); } } } else if (point1.Y == point2.Y) { if (point2.X > point1.X) { for (int ii = point1.X; ii <= point2.X; ii++) { this.Brush.DrawHallBrush(map, this.Draw, new Loc(ii, point1.Y), vertical); } } else if (point2.X < point1.X) { for (int ii = point1.X; ii >= point2.X; ii--) { this.Brush.DrawHallBrush(map, this.Draw, new Loc(ii, point1.Y), vertical); } } } GenContextDebug.DebugProgress("Hall Line"); }
/// <summary> /// Draws a hall in a straight cardinal direction, starting with one point and ending with another (inclusive). /// </summary> /// <param name="map"></param> /// <param name="point1"></param> /// <param name="point2"></param> /// <param name="terrain"></param> private static void DrawHall(ITiledGenContext map, Loc point1, Loc point2, ITile terrain) { if (point1 == point2) { map.SetTile(point1, terrain.Copy()); } else if (point1.X == point2.X) { if (point2.Y > point1.Y) { for (int ii = point1.Y; ii <= point2.Y; ii++) { map.SetTile(new Loc(point1.X, ii), terrain.Copy()); } } else if (point2.Y < point1.Y) { for (int ii = point1.Y; ii >= point2.Y; ii--) { map.SetTile(new Loc(point1.X, ii), terrain.Copy()); } } } else if (point1.Y == point2.Y) { if (point2.X > point1.X) { for (int ii = point1.X; ii <= point2.X; ii++) { map.SetTile(new Loc(ii, point1.Y), terrain.Copy()); } } else if (point2.X < point1.X) { for (int ii = point1.X; ii >= point2.X; ii--) { map.SetTile(new Loc(ii, point1.Y), terrain.Copy()); } } } GenContextDebug.DebugProgress("Hall Line"); }
public abstract void DrawHallBrush(ITiledGenContext map, Rect bounds, Loc point, bool vertical);