public bool CanBeDoor(int gx, int gy, params GenDetail.DetailType[] checkFor) { if (checkFor.Length == 0) { checkFor = new GenDetail.DetailType[] { GenDetail.DetailType.Wall }; } bool horizontal = false; bool vertical = false; int walls = 0; GenTile r = GetTile(gx + 1, gy); if (r == null || r.AnyTypes(checkFor)) { walls++; } GenTile l = GetTile(gx - 1, gy); if (l == null || l.AnyTypes(checkFor)) { walls++; } if ((r == null || r.AnyTypes(checkFor)) && (l == null || l.AnyTypes(checkFor))) { horizontal = true; } GenTile t = GetTile(gx, gy - 1); if (t == null || t.AnyTypes(checkFor)) { walls++; } GenTile b = GetTile(gx, gy + 1); if (b == null || b.AnyTypes(checkFor)) { walls++; } if ((t == null || t.AnyTypes(checkFor)) && (b == null || b.AnyTypes(checkFor))) { vertical = true; } return(walls % 2 == 0 && (horizontal ^ vertical)); }
/// <summary> /// checks if Position is in the corner (floor, not wall) /// </summary> public bool IsCornerG(int gx, int gy, params GenDetail.DetailType[] checkFor) { if (checkFor.Length == 0) { checkFor = new GenDetail.DetailType[] { GenDetail.DetailType.Wall }; } GenTile tile = GetTile(gx, gy); // if it is a wall we dont need to bother as it is never a corner if (tile == null || tile.AnyTypes(checkFor)) { return(false); } int horizontal = 0; int vertical = 0; GenTile r = GetTile(gx + 1, gy); if (r.AnyTypes(checkFor)) { horizontal++; } GenTile l = GetTile(gx - 1, gy); if (l.AnyTypes(checkFor)) { horizontal++; } GenTile t = GetTile(gx, gy - 1); if (t.AnyTypes(checkFor)) { vertical++; } GenTile b = GetTile(gx, gy + 1); if (b.AnyTypes(checkFor)) { vertical++; } return(horizontal > 0 && vertical > 0); }
/// <summary> /// checks if Position is in the corner (floor, not wall) /// </summary> public bool IsCornerGR(int gx, int gy, GenRoom room, GenDetail.DetailType[] checkFor = null, GenDetail.DetailType[] noWall = null) { if (checkFor == null) { checkFor = new GenDetail.DetailType[] { GenDetail.DetailType.Wall }; } if (noWall == null) { noWall = new GenDetail.DetailType[] { GenDetail.DetailType.Door }; } bool vertical = false; bool horizontal = false; GenTile tile; if (room != null) { tile = room.GetAtWorldspaceG(gx, gy); if (tile != null) { GenTile check = room.GetAtWorldspaceG(gx + 1, gy); if (check != null && check.AnyTypes(checkFor) && check.NonTypes(noWall)) { horizontal = true; } check = room.GetAtWorldspaceG(gx - 1, gy); if (check != null && check.AnyTypes(checkFor) && check.NonTypes(noWall)) { horizontal = true; } check = room.GetAtWorldspaceG(gx, gy + 1); if (check != null && check.AnyTypes(checkFor) && check.NonTypes(noWall)) { vertical = true; } check = room.GetAtWorldspaceG(gx, gy - 1); if (check != null && check.AnyTypes(checkFor) && check.NonTypes(noWall)) { vertical = true; } return(horizontal && vertical); } return(false); } else { tile = GetTile(gx, gy); if (tile != null) { GenTile check = GetTile(gx + 1, gy); if (check != null && check.AnyTypes(GenDetail.DetailType.Wall)) { horizontal = true; } check = GetTile(gx - 1, gy); if (check != null && check.AnyTypes(GenDetail.DetailType.Wall)) { horizontal = true; } check = GetTile(gx, gy + 1); if (check != null && check.AnyTypes(GenDetail.DetailType.Wall)) { vertical = true; } check = GetTile(gx, gy - 1); if (check != null && check.AnyTypes(GenDetail.DetailType.Wall)) { vertical = true; } return(horizontal && vertical); } return(false); } }