Beispiel #1
0
    private void TurnLeft()
    {
        TeteriminoData tmpData = ScriptableObject.Instantiate <TeteriminoData>(data);

        tmpData.TurnLeft();

        for (int x = 0; x < tmpData.size; ++x)
        {
            for (int y = 0; y < tmpData.size; ++y)
            {
                if (!tmpData.actual[x, y])
                {
                    continue;
                }
                if (matrix.cells[x + xPos, y + Mathf.CeilToInt(offset)].hasBlock)
                {
                    return;
                }
                if (matrix.cells[x + xPos, y + Mathf.CeilToInt(offset) - 1].hasBlock)
                {
                    return;
                }
            }
        }

        data.TurnLeft();
    }
Beispiel #2
0
    public void Init(TeteriminoData data, Matrix matrix)
    {
        this.data = data;
        offset    = 23f;
        xPos      = 9 - data.size / 2;

        groundedTime = 0f;

        this.matrix = matrix;

        objects = new GameObject[4];
        int i = 0;

        for (int x = 0; x < data.size; ++x)
        {
            for (int y = 0; y < data.size; ++y)
            {
                if (!data.actual[x, y])
                {
                    continue;
                }
                objects[i] = (GameObject.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/Block_R")));
                ++i;
            }
        }
    }