예제 #1
0
    public void Init(Data.BlockType type, Data.BlockPosition position)
    {
        this.Type     = type;
        this.Position = position;

        landTime = -1;
    }
예제 #2
0
    // 回転できるかチェック.回転できるようなら回転を行う
    protected void CheckAndRotate(Data.BlockRotation nextRot, Vector3[,] rotCoodinate)
    {
        // ブロックの移動先を取得
        var idx       = 0;
        var positions = new List <Data.BlockPosition>();

        foreach (var block in Blocks)
        {
            var diff     = rotCoodinate[(int)nextRot, idx] - rotCoodinate[(int)Rotation, idx];
            var position = new Data.BlockPosition(block.Position.x + (int)diff.x, block.Position.y + (int)diff.y);

            positions.Add(position);

            idx++;
        }

        // 回転できるか
        var canRotate = OnRotateChecked(positions);

        if (!canRotate)
        {
            return;
        }

        // ブロックの位置を更新する
        idx = 0;
        foreach (var block in Blocks)
        {
            block.transform.localPosition = rotCoodinate[(int)nextRot, idx];
            block.Position = positions[idx];

            idx++;
        }

        Rotation = nextRot;
    }