static void DrawMap(VoxelBuilder target)
    {
        var nowHeight = target.GetNowFlowerHeight();
        var original  = target.transform.position + nowHeight;

        //畫點
        var offsetX  = 0.5f * Vector3.right * VoxelBuilder.xUnit;
        var offsetY  = 0.5f * Vector3.forward * VoxelBuilder.yUnit;
        var offsetXY = offsetX + offsetY;

        var nowFloorIndex = target.GetNowFloorIndex();

        if (!target.IsValidatedFloorIndex(nowFloorIndex))
        {
            return;
        }

        var CountY = target.CountY(); var CountX = target.CountX();

        for (var y = 0; y < CountY; ++y)
        {
            var from = original + offsetXY + offsetY * y;
            for (var x = 0; x < CountX; ++x)
            {
                ChoseColor(target, nowFloorIndex, y, x);
                Gizmos.DrawSphere(from, PointR);
                from = from + offsetX;
            }
        }
    }
Beispiel #2
0
    List <Voxel[]> GetLines(int floor, int y)
    {
        List <Voxel[]> batch  = new List <Voxel[]>();
        List <Voxel>   line   = new List <Voxel>();
        bool           adding = false;

        var x = 0;

        while (x < voxelBuilder.CountX())
        {
            var voxel = GetVoxel(floor, y, x);
            if (voxel.IsUse())
            {
                adding = true;
                line.Add(voxel);
                x = x + 2;//相連會差2格
                continue;
            }
            else
            {
                if (adding)
                {
                    batch.Add(line.ToArray());
                    line.Clear();
                    adding = false;
                }
            }
            x = x + 1;
        }

        //如果最後1次add是在末端
        if (adding)
        {
            batch.Add(line.ToArray());
        }

        return(batch);
    }