Ejemplo n.º 1
0
 public void EdgeWalls(char c, GenRoom specific = null)
 {
     if (specific != null)
     {
         foreach (var tile in specific.GetEdge())
         {
             tile.Tile.Details.Add(new GenDetail()
             {
                 Char = c, Type = GenDetail.DetailType.Wall
             });
         }
     }
     else
     {
         foreach (GenRoom item in Rooms)
         {
             foreach (var tile in item.GetEdge())
             {
                 tile.Tile.Details.Add(new GenDetail()
                 {
                     Char = c, Type = GenDetail.DetailType.Wall
                 });
             }
         }
     }
 }
Ejemplo n.º 2
0
    public List <GenPositionTile> GetConnectingTiles(GenRoom a, GenRoom b)
    {
        List <GenPositionTile> at = a.GetEdge().ToList();
        List <GenPositionTile> aa = a.GetAllTiles();
        List <GenPositionTile> bt = b.GetEdge().ToList();
        List <GenPositionTile> ba = b.GetAllTiles();

        List <GenPositionTile> result = new List <GenPositionTile>();

        foreach (var item in at)
        {
            if (ba.Any(x => x.Tile == item.Tile))
            {
                result.Add(item);
            }
        }
        foreach (var item in bt)
        {
            if (aa.Any(x => x.Tile == item.Tile))
            {
                result.Add(item);
            }
        }
        result = result.Distinct().ToList();
        return(result);
    }
Ejemplo n.º 3
0
    public void FixOverlap()
    {
        for (int i = 0; i < Rooms.Count - 1; i++)
        {
            for (int j = i + 1; j < Rooms.Count; j++)
            {
                GenRoom a = Rooms[i];
                GenRoom b = Rooms[j];

                if (a.Outer.Overlaps(b.Outer))
                {
                    GenRect rA = a.Outer;
                    GenRect rB = b.Outer;
                    // find the union of both
                    int     uLeft  = Mathf.Max(rA.MinX, rB.MinX);
                    int     uTop   = Mathf.Max(rA.MinY, rB.MinY);
                    int     uRight = Mathf.Min(rA.MaxX, rB.MaxX);
                    int     uBot   = Mathf.Min(rA.MaxY, rB.MaxY);
                    GenRect union  =
                        new GenRect(uLeft, uRight, uTop, uBot);

                    GenRoom dominant = a.SpacePriority > b.SpacePriority ? a : b;
                    GenRoom weaker   = a.SpacePriority > b.SpacePriority ? b : a;

                    HashSet <GenPositionTile> dominantEdge = dominant.GetEdge();

                    for (int x = union.MinX; x <= union.MaxX; x++)
                    {
                        for (int y = union.MinY; y <= union.MaxY; y++)
                        {
                            // check if on the edge
                            if (dominantEdge.Any(e => e.Tile == dominant.GetAtWorldspaceG(x, y)))
                            {
                                // this Tile is on the Edge and should be shared
                                weaker.SetTileAtG(x, y, dominant.GetAtWorldspaceG(x, y));
                            }
                            else
                            {
                                // remove the tile from weaker one
                                weaker.RemoveTileAtG(x, y);
                            }
                        }
                    }
                }
            }
        }
    }