Esempio n. 1
0
    public override void AddWalls(WallsSpecification specification, FloorSpecification floorSpecification)
    {
        var size = floorSpecification.Size;

        var start = ClampCoords(floorSpecification.Size, new Vector2Int(Mathf.RoundToInt(_startPoint.x * size.x), Mathf.RoundToInt(_startPoint.y * size.y)));
        var end   = ClampCoords(floorSpecification.Size, new Vector2Int(Mathf.RoundToInt(_endPoint.x * size.x), Mathf.RoundToInt(_endPoint.y * size.y)));

        var points = GetPointsOnLine(start.x, start.y, end.x, end.y).ToList();

        for (int i = 0; i < points.Count - 1; i++)
        {
            var p1 = points[i];
            var p2 = points[i + 1];

            if (p1.x == p2.x)
            {
                //do nothing
            }
            else if (p1.x == p2.x)
            {
                TryAddingWall(new Vector2Int(p1.x, p1.y), WallDirection.Up, specification, floorSpecification);
            }
            else if (p1.x - 1 == p2.x)
            {
                if (p1.y <= p2.y)
                {
                    TryAddingWall(new Vector2Int(p1.x, p1.y), WallDirection.Up, specification, floorSpecification);
                }
                else
                {
                    TryAddingWall(new Vector2Int(p1.x, p1.y - 1), WallDirection.Up, specification, floorSpecification);
                }
            }
            else if (p1.x + 1 == p2.x)
            {
                if (p1.y <= p2.y)
                {
                    TryAddingWall(new Vector2Int(p1.x + 1, p1.y), WallDirection.Up, specification, floorSpecification);
                }
                else
                {
                    TryAddingWall(new Vector2Int(p1.x, p1.y - 1), WallDirection.Up, specification, floorSpecification);
                }
            }

            else
            {
                MyAssert.Fail($"x delta is too big {p1} {p2}");
            }

            if (p1.y == p2.y)
            {
                //do nothing
            }
            else if (p1.y + 1 == p2.y)
            {
                TryAddingWall(new Vector2Int(p1.x, p1.y), WallDirection.Right, specification, floorSpecification);
            }
            else if (p1.y - 1 == p2.y)
            {
                TryAddingWall(new Vector2Int(p1.x, p1.y), WallDirection.Right, specification, floorSpecification);
            }
            else
            {
                MyAssert.Fail($"y delta is too big {p1} {p2}");
            }
        }
    }
Esempio n. 2
0
 public void Assert_always_fail()
 {
     MyAssert.Fail("Always fail");
 }