コード例 #1
0
    private void CombineCells()
    {
        for (int y = 0; y < height; ++y)
        {
            for (float x = cellSize.x * 0.5f; x < width * cellSize.x;)
            {
                PathfindingNode test = CellAt(new Vector2(x, (y + 0.5f) * cellSize.y));
                if (test == null)
                {
                    x += cellSize.x;
                }
                else
                {
                    test.CheckHorizontalCombine(this);
                    x += test.Area.width;
                }
            }
        }

        for (int y = 0; y < height; ++y)
        {
            for (float x = cellSize.x * 0.5f; x < width * cellSize.x;)
            {
                PathfindingNode test = CellAt(new Vector2(x, (y + 0.5f) * cellSize.y));
                if (test == null)
                {
                    x += cellSize.x;
                }
                else
                {
                    test.CheckVerticalCombine(this);
                    x += test.Area.width;
                }
            }
        }
    }