Ejemplo n.º 1
0
    //Closes open edges
    void RecheckPoints()
    {
        List <GridPoint> ValidCheckPoints = new List <GridPoint>();

        foreach (GridPoint gp in Grid)
        {
            if (gp.IsRoofType() || gp.Type == PointType.Filler)
            {
                ValidCheckPoints.Add(gp);
            }
        }

        List <GridPoint> PointsToRemove = new List <GridPoint>();

        foreach (GridPoint gp in ValidCheckPoints)
        {
            GridPoint Neighboor = gp.GetNeighbor(new Vector3(0, 1f, 0), Grid);
            if (Neighboor != null && Neighboor.IsRoofType())
            {
                if (Neighboor.Type == PointType.HalfRoof)
                {
                    gp.Type = PointType.HalfWall;
                    gp.Dir  = Neighboor.Dir;
                }
                else if (Neighboor.Type == PointType.Roof)
                {
                    gp.Type = PointType.Wall;
                    gp.Dir  = Neighboor.Dir;
                }
                else
                {
                    PointsToRemove.Add(gp);
                }
            }
            else
            {
                PointsToRemove.Add(gp);
            }
        }

        foreach (GridPoint gp in PointsToRemove)
        {
            ValidCheckPoints.Remove(gp);
        }

        foreach (GridPoint gp in ValidCheckPoints)
        {
            gp.CreateGridObject(this.transform, HouseCollection);
        }
    }
Ejemplo n.º 2
0
    void RecheckRoofCorners()
    {
        List <GridPoint> newPoints = new List <GridPoint>();

        List <GridPoint> newFullRoofPoints = new List <GridPoint>();
        List <GridPoint> newHalfRoofPoints = new List <GridPoint>();
        List <GridPoint> newSkipRoofPoints = new List <GridPoint>();

        foreach (GridPoint gp in Grid)
        {
            if (!gp.IsPointValid())
            {
                continue;
            }
            if (gp.IsRoofType())
            {
                continue;
            }

            GridPoint NeighboorPoint = gp.GetNeighbor(gp.Dir, Grid, true);
            if (NeighboorPoint != null)
            {
                if (NeighboorPoint.IsRoofType())
                {
                    GridPoint newGP = new GridPoint(PointType.Wall, gp.Location);
                    newPoints.Add(newGP);

                    if (gp.IsHalf())
                    {
                        newHalfRoofPoints.Add(gp);
                    }
                    else
                    {
                        newFullRoofPoints.Add(gp);
                        GridPoint HalfNeighboor = gp.GetNeighbor(gp.Dir * 0.5f, Grid, false);
                        if (HalfNeighboor != null)
                        {
                            newSkipRoofPoints.Add(HalfNeighboor);
                        }
                    }

                    for (int i = 0; i < DirectionArray.Length; i++)
                    {
                        GridPoint g = newGP.GetNeighbor(DirectionArray[i], Grid, false);
                        if (g != null)
                        {
                            if (g.IsPointValid() && !g.IsRoofType())
                            {
                                if (DirectionArray[i] * -1f != g.Dir)
                                {
                                    newGP.Dir      = DirectionArray[i];
                                    newGP.IsCorner = true;
                                    g.IsCorner     = true;

                                    GridPoint newEmptyRoofPoint = new GridPoint(PointType.None_SkipRoof, g.Location);
                                    newPoints.Add(newEmptyRoofPoint);
                                }
                            }
                        }
                    }
                }
            }
        }

        foreach (GridPoint gp in newFullRoofPoints)
        {
            gp.Type = PointType.Roof;
        }

        foreach (GridPoint gp in newHalfRoofPoints)
        {
            gp.Type = PointType.HalfRoof;
        }

        foreach (GridPoint gp in newSkipRoofPoints)
        {
            gp.Type = PointType.None_SkipRoof;
        }

        foreach (GridPoint gp in newPoints)
        {
            Grid.Add(gp);
        }
    }