Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="blocks"></param>
        /// <param name="blockX"></param>
        /// <param name="blockY"></param>
        /// <returns></returns>
        public bool IsHitBlock(Defs.Blocks[,] blocks, int blockX, int blockY)
        {
            for (int y = 0; y < blocks.GetLength(0); ++y)
            {
                for (int x = 0, max = blocks.GetLength(1); x < max; ++x)
                {
                    if (blocks[y, x] == Defs.Blocks.EmptyField)
                    {
                        continue;
                    }

                    if (y + blockY > FieldBlocks.GetLength(0) - 1)
                    {
                        return(true);
                    }

                    if (x + blockX > FieldBlocks.GetLength(1) - 1)
                    {
                        return(true);
                    }

                    if (x + blockX < 0)
                    {
                        return(true);
                    }

                    if (FieldBlocks[y + blockY, x + blockX] != Defs.Blocks.EmptyField)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        private int ClearLine()
        {
            int count = 0;

            for (int y = 0; y < FieldBlocks.GetLength(0); ++y)
            {
                bool line = true;

                for (int x = 0, max = FieldBlocks.GetLength(1); x < max; ++x)
                {
                    if (FieldBlocks[y, x] == Defs.Blocks.EmptyField)
                    {
                        line = false;
                        break;
                    }
                }

                if (line)
                {
                    ++count;

                    for (int x = 0, max = FieldBlocks.GetLength(1); x < max; ++x)
                    {
                        FieldBlocks[y, x] = Defs.Blocks.EmptyField;
                    }
                }
            }
            return(count);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        private void CloseUpBlocks()
        {
            for (int y = FieldBlocks.GetLength(0) - 1; y >= 0; --y)
            {
                bool exit = true;

                for (int yy = y; yy >= 0; --yy)
                {
                    for (int x = 0, max = FieldBlocks.GetLength(1); x < max; ++x)
                    {
                        if (FieldBlocks[yy, x] != Defs.Blocks.EmptyField)
                        {
                            exit = false;
                            break;
                        }
                    }
                }

                if (exit)
                {
                    return;
                }

                bool line = true;

                for (int x = 0, max = FieldBlocks.GetLength(1); x < max; ++x)
                {
                    if (FieldBlocks[y, x] != Defs.Blocks.EmptyField)
                    {
                        line = false;
                        break;
                    }
                }

                if (line)
                {
                    for (int yy = y; yy >= 1; --yy)
                    {
                        for (int x = 0, max = FieldBlocks.GetLength(1); x < max; ++x)
                        {
                            FieldBlocks[yy, x] = FieldBlocks[yy - 1, x];
                        }
                    }
                    ++y;
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="blocks"></param>
        /// <param name="blockX"></param>
        /// <param name="blockY"></param>
        public void ClearBlock(Defs.Blocks[,] blocks, int blockX, int blockY)
        {
            for (int y = 0; y < blocks.GetLength(0); ++y)
            {
                for (int x = 0, max = blocks.GetLength(1); x < max; ++x)
                {
                    if (blocks[y, x] == Defs.Blocks.EmptyField)
                    {
                        continue;
                    }

                    if (y + blockY > FieldBlocks.GetLength(0) - 1 || x + blockX > FieldBlocks.GetLength(1) - 1)
                    {
                        continue;
                    }

                    FieldBlocks[y + blockY, x + blockX] = Defs.Blocks.EmptyField;
                }
            }
        }