コード例 #1
0
    private void InitCubes()
    {
        pattern = patterns[PatternIndex];

        points         = new List <Vector2>();
        cubesInPattern = new GameObject[patternSize * patternSize];

        if (cubes == null)
        {
            cubes = new List <GameObject>();
        }

        currentPoint = new Vector3(spawnPoint.x, spawnPoint.y);

        for (int i = 0; i < patternSize; i++)
        {
            for (int j = 0; j < patternSize; j++)
            {
                int index = i * patternSize + j;

                if (pattern[index] != 0)
                {
                    GameObject cube = cubeController.GetCube(targetParent);
                    cube.transform.position = new Vector3(spawnPoint.x + j + positionShift, spawnPoint.y + (patternSize - 1 - i) + positionShift);
                    cubes.Add(cube);

                    points.Add(new Vector2(spawnPoint.x + j, spawnPoint.y + (patternSize - 1 - i)));

                    cubesInPattern[index] = cube;
                }
                else
                {
                    cubesInPattern[index] = null;
                }
            }
        }
    }