Example #1
0
    private void StreightAndCurvedWallsTest()
    {
        var nextWall = WallData.CreateStreight(new Vector2(0f, 0f), new Vector2(0f, 2f), 0.2f, 2f);
        var prevWall = WallData.CreateStreight(new Vector2(3f, 2f), new Vector2(3f, 0f), 0.1f, 2f);

        var curvedWall1 = WallData.CreateCurved(
            new Vector2(3f, 0f),
            new Vector2(1.5f, -1.5f),
            new Vector2(0f, 0f),
            0.15f,
            2f,
            new[]
        {
            new OpeningData(OpeningType.Outer, CreateBezierHoleShape(), 0.05f),
            new OpeningData(OpeningType.Inner, CreateRectHoleShape())
        });

        var curvedWall2 = curvedWall1.Reverse();

/*        var curvedWall2 = WallData.CreateCurved (
 *          new Vector2 (3f, 0f),
 *          new Vector2 (1.5f, -1.5f),
 *          new Vector2 (0f, 0f),
 *          0.15f,
 *          2f,
 *          new[]
 *          {
 *              new OpeningData (OpeningType.Through, CreateBezierHoleShape (), 0.05f),
 *              new OpeningData (OpeningType.Through, CreateRectHoleShape ())
 *          });*/

        var matrix       = Matrix3x2.CreateTranslation(0f, 3f);
        var streightWall = WallData.CreateStreight(
            new Vector2(3f, 0f),
            new Vector2(0f, 0f),
            0.3f,
            2f,
            new[]
        {
            new OpeningData(OpeningType.Through, CreateBezierHoleShape()),
            new OpeningData(OpeningType.Through, CreateRectHoleShape())
        });

        RoomMeshesGenerator.CreateWallMeshes(curvedWall1, null, null);
//        SingleWallTest (streightWall.Transform (matrix), nextWall.Transform (matrix), prevWall.Transform (matrix));
        RoomMeshesGenerator.CreateWallMeshes(streightWall.Transform(matrix), nextWall.Transform(matrix), null);

        matrix = Matrix3x2.CreateTranslation(0f, -3f);
        RoomMeshesGenerator.CreateWallMeshes(
            curvedWall2.Transform(matrix),
            prevWall.Reverse().Transform(matrix),
            nextWall.Reverse().Transform(matrix));
    }
Example #2
0
    private void WallsTest()
    {
        var walls = new Walls();

        walls.AddWallData(WallData.CreateCurved(-2f, -2f, -4f, -0f, -2, 2, 0.3f, 2f));
        walls.AddWallData(
            WallData.CreateStreight(-2f, 2f, 0f, 2f, 0.4f, 2f, null, WidthChangeType.Type2));
        walls.AddWallData(WallData.CreateStreight(0f, 2f, 2f, 2f, 0.1f, 1f));
        walls.AddWallData(WallData.CreateStreight(2f, 2f, 2f, -2f, 0.2f, 2f));
        walls.AddWallData(WallData.CreateStreight(2f, -2f, -2f, -2f, 0.5f, 2f));

//        var walls = new Dictionary<Vector2, List<WallData>> ();


/*        var walls = new[]
 *      {
 * //            BaseWallData.CreateStreight (new Vector2 (-2, -2), new Vector2 (-2, 2), 0.2f, 2f),
 *          WallData.CreateCurved (new Vector2 (-2, -2), new Vector2 (-4, -0), new Vector2 (-2, 2), 0.3f, 2f),
 *          WallData.CreateStreight (new Vector2 (-2, 2), new Vector2 (0, 2), 0.4f, 2f, null, WidthChangeType.Type2),
 *          WallData.CreateStreight (new Vector2 (0, 2), new Vector2 (2, 2), 0.1f, 1f),
 *          WallData.CreateStreight (new Vector2 (2, 2), new Vector2 (2, -2), 0.2f, 2f),
 *          WallData.CreateStreight (new Vector2 (2, -2), new Vector2 (-2, -2), 0.5f, 2f)
 *      };*/

/*        var walls = new[]
 *      {
 *          WallData.CreateStreight (new Vector2 (0, -2), new Vector2 (-2, 0), 0.2f, 2f),
 *          WallData.CreateStreight (new Vector2 (-2, 0), new Vector2 (0, 2), 0.2f, 2f),
 *          WallData.CreateStreight (new Vector2 (0, 2), new Vector2 (2, 0), 0.2f, 2f),
 *          WallData.CreateStreight (new Vector2 (2, 0), new Vector2 (0, -2), 0.2f, 2f)
 *      };*/

/*        var wallsCount = walls.Count;
 *      for (int i = 0; i < wallsCount; i++) {
 *          var prevIndex = (i - 1 + wallsCount) % wallsCount;
 *          var nextIndex = (i + 1) % wallsCount;
 *
 *          var meshes = WallMeshesGenerator.GetWallMeshes (walls[prevIndex], walls[i], walls[nextIndex]);
 *          var parent = new GameObject ($"Wall {i}").transform;
 *          for (int j = 0; j < meshes.Length; j++) {
 *              var mesh = meshes[j];
 *              MeshGenerator
 *                  .CreateGameObject (mesh.name, mesh)
 *                  .transform
 *                  .SetParent (parent, false);
 *          }
 *      }*/
    }
Example #3
0
    private void RoomsFinderTest()
    {
        var walls = new Walls();

        walls.AddWallData(WallData.CreateStreight(1f, 2f, 0f, 3f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(0f, 2f, 0f, 3f, 0.1f, 2f));

        walls.AddWallData(WallData.CreateStreight(1f, 1f, 0.5f, 0.5f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(0f, 0f, 0f, 2f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(0f, 2f, 1f, 2f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(1f, 2f, 1f, 3f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(1f, 3f, 4f, 3f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(4f, 3f, 2f, 2f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(2f, 2f, 1f, 2f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(2f, 2f, 2f, 0f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(2f, 0f, 0f, 0f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(1f, 2f, 1f, 1f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(2f, 0f, 1.5f, 0.5f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(1.5f, 0.5f, 1.5f, 1f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(1.5f, 1f, 1f, 1f, 0.1f, 2f));


        walls.AddWallData(WallData.CreateStreight(10f, 10f, 10f, 15f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(10f, 15f, 15f, 15f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(15f, 15f, 15f, 10f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(15f, 10f, 10f, 10f, 0.1f, 2f));

        walls.AddWallData(WallData.CreateStreight(11f, 11f, 11f, 13f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(11f, 13f, 13f, 13f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(13f, 13f, 13f, 11f, 0.1f, 2f));
        walls.AddWallData(WallData.CreateStreight(13f, 11f, 11f, 11f, 0.1f, 2f));


/*        walls.AddWallData (WallData.CreateStreight (0f, 0f, 0f, 2f, 0.1f, 2f));
 *      walls.AddWallData (WallData.CreateStreight (0f, 2f, 2f, 2f, 0.1f, 2f));
 *      walls.AddWallData (WallData.CreateStreight (2f, 2f, 2f, 0f, 0.1f, 2f));
 *      walls.AddWallData (WallData.CreateStreight (0f, 0f, 2f, 0f, 0.1f, 2f));*/

/*        walls.AddWallData (WallData.CreateStreight (2f, 2f, 3f, 2f, 0.1f, 2f));
 *      walls.AddWallData (WallData.CreateStreight (3f, 2f, 3f, 0f, 0.1f, 2f));
 *      walls.AddWallData (WallData.CreateStreight (3f, 0f, 2f, 0f, 0.1f, 2f));*/


        RoomMeshesGenerator.CreateRoomMeshes(walls);
    }