コード例 #1
0
        [Fact] public unsafe void Extractor_StructToBytesArray_Test()
        {
            byte[] b     = rcobj.GetStructureBytes();
            bool   equal = b.BlockEqual(structBytes);

            Assert.True(equal);
            object ro = rcobj;

            structBytes2 = new byte[rcobj.GetSize()];
            Extractor.StructureToBytes(ro, ref structBytes2, 0);
            bool equal2 = structBytes2.BlockEqual(structBytes);

            Assert.True(equal2);
        }
コード例 #2
0
ファイル: Tetris1.cs プロジェクト: pixnek/tetris
    //Поворот фигуры
    void Rotate()
    {
        int[,] tmpFigure = figure.Rotate();
        int size = figure.GetSize();

        int[] coord = figure.GetCoord();
        int[,] tmpTable = new int[size, size];

        for (int y = coord [0]; y < coord [0] + size; y++)
        {
            for (int x = coord [1]; x < coord [1] + size; x++)
            {
                if ((y >= 0) && (y < heightTable) && (x >= 0) && (x < widthTable))
                {
                    tmpTable [y - coord [0], x - coord [1]] = table [y, x];
                    if (table [y, x] == 2)
                    {
                        return;
                    }
                }
                else
                {
                    if (tmpFigure [y - coord [0], x - coord [1]] != 0)
                    {
                        return;
                    }
                }
            }
        }

        for (int y = coord [0]; y < coord [0] + size; y++)
        {
            for (int x = coord [1]; x < coord [1] + size; x++)
            {
                if ((y >= 0) && (y < heightTable) && (x >= 0) && (x < widthTable))
                {
                    table [y, x] = tmpFigure [y - coord [0], x - coord [1]];
                }
            }
        }
        figure.SetFigure(tmpFigure);
    }
コード例 #3
0
ファイル: Tetris1.cs プロジェクト: pixnek/tetris
    //Добавлене фигуры
    void AddFigure()
    {
        int n = RandomFigure();

        figure = mas[n];
        figure.Figure();
        n = figure.GetSize();
        int[] coord = figure.GetCoord();
        int[,] tmp       = new int[n, n];
        int[,] tmpFigure = figure.GetFigure();

        for (int y = coord [0]; y < coord [0] + n; y++)
        {
            for (int x = coord [1]; x < coord [1] + n; x++)
            {
                if (y >= 0)
                {
                    tmp [y - coord [0], x - coord [1]] = table [y, x];
                    if (tmpFigure [y - coord [0], x - coord [1]] > 0 && tmp [y - coord [0], x - coord [1]] == 2)
                    {
                        return;
                    }
                }
            }
        }

        for (int y = coord [0]; y < coord [0] + n; y++)
        {
            for (int x = coord [1]; x < coord [1] + n; x++)
            {
                if (y >= 0)
                {
                    table [y, x] = tmpFigure [y - coord [0], x - coord [1]];
                }
            }
        }
    }