List<DungeonArea> MakeTunnel( IntVector2 pointA, IntVector2 pointB )
    {
        var roomsColor = SUtil.SRandom.SRandom.GetRandomColor();

        foreach (var r in dunArea_)
            r.color_ = roomsColor;

        IntRect[] areas = dunArea_.Select(r => r.area_).ToArray();

        IntVector2[] points = new IntVector2[]
        {
            pointA,
            pointB,
        };

        var diffArea = IntRect.BLTRRect( points[0], points[1] );

        DungeonArea[] halls = new DungeonArea[]
        {
            new DungeonArea( diffArea ),
            //new DungeonArea( points[0]),
            //new DungeonArea( points[1]),
        };

        var hallcolors = new Color[]
        {
            Color.green, Color.red, Color.red
        };

        for (int i = 0; i < halls.Length; ++i)
            halls[i].color_ = hallcolors[i];

        return halls.ToList();
    }
예제 #2
0
    public static DungeonArea BuildRoomInArea(IntRect area, int minSize )
    {
        var room = new DungeonArea();
        var maxX = area.xMax_;
        var maxY = area.yMax_;
        var minX = area.xMin_;
        var minY = area.yMin_;

        var xMin = Random.Range(minX + 1, maxX - minSize );
        var yMin = Random.Range(minY + 1, maxY - minSize );
        var xMax = Random.Range(xMin + minSize, maxX);
        var yMax = Random.Range(yMin + minSize, maxY);

        room.area_ = IntRect.MinMaxRect(xMin, yMin, xMax, yMax);

        return room;
    }
예제 #3
0
    // Note this creates pretty lame tunnels. Could try to make it do a zigzag pattern or something
    public List<DungeonArea> DigTunnel( DungeonArea roomb )
    {
        DungeonArea[] rooms = new DungeonArea[]
        {
            this,
            roomb,
        };

        var roomsColor = SUtil.SRandom.SRandom.GetRandomColor();

        foreach (var r in rooms)
            r.color_ = roomsColor;

        IntRect[] areas = rooms.Select(r => r.area_).ToArray();

        IntVector2[] points = areas.Select(a => a.GetRandomPoint()).ToArray();

        for (int i = 0; i < 2; ++i)
        {
            points[i] = areas[i].PushPointToTargetEdge(points[i], points[1 - i]);

        }

        var bl = IntVector2.Min( points[0], points[1] );
        var tr = IntVector2.Max( points[0] + IntVector2.one, points[1] + IntVector2.one );

        var diffArea = new IntRect( bl.x, bl.y, tr.x - bl.x, tr.y - bl.y );
        diffArea.w_ = diffArea.w_ <= 0 ? 1 : diffArea.w_;
        diffArea.h_ = diffArea.w_ <= 0 ? 1 : diffArea.h_;

        DungeonArea[] halls = new DungeonArea[]
        {
            new DungeonArea( diffArea ),
            new DungeonArea( points[0]),
            new DungeonArea( points[1]),
        };
        halls[0].color_ = Color.green;
        halls[1].color_ = Color.red;
        halls[2].color_ = Color.red;

        /*
        // The two possible points where our hallways  connect
        IntVector2[] possibleConnections = new IntVector2[]
        {
            new IntVector2(points[0].x, points[1].y),
            new IntVector2(points[1].x, points[0].y),
        };

        var connectionPoint = SUtil.SRandom.SRandom.GetRandomItemFromList( possibleConnections );
        for (int i = 0; i < 2; ++i)
            if (areas[i].Contains(connectionPoint))
                connectionPoint = points[i];

        DungeonArea[] halls = new DungeonArea[]
        {
            new DungeonArea( points[0] ),
            new DungeonArea( points[1] ),
            new DungeonArea( connectionPoint ),
        };

        var color = SUtil.SRandom.SRandom.GetRandomColor();

        for( int i = 0; i < 2; ++i )
        {
            halls[i].area_.position_ = points[i];
            halls[i].area_.Encapsulate(connectionPoint);
            halls[i].color_ = color;
        }

        halls[2].color_ = Color.magenta;
        */

        return halls.ToList();
    }