예제 #1
0
        /// <summary>
        /// Check if block in direction is same color and break it
        /// </summary>
        /// <param name="block"></param>
        /// <param name="dir"></param>
        public void CheckBreak(Block block, Direction dir)
        {
            Block other;

            switch (dir)
            {
            case Direction.up:
                other = block.GetTopAdjacent();
                CompareAndBreak(block, other, dir);
                break;

            case Direction.right:
                other = block.GetRightAdjacent();
                CompareAndBreak(block, other, dir);
                break;

            case Direction.down:
                other = block.GetBottomAdjacent();
                CompareAndBreak(block, other, dir);
                break;

            case Direction.left:
                other = block.GetLeftAdjacent();
                CompareAndBreak(block, other, dir);
                break;

            default:

                break;
            }
        }
예제 #2
0
        /// <summary>
        /// 1 < x < width - 1, 1
        /// </summary>
        private void FormBottom()
        {
            int currentWidth = 1;

            Block current = data.bottomLeft;

            while (currentWidth < (data.width - 1))
            {
                current = current.GetRightAdjacent();
                current.SetSprite(BlockPosition.bottom);
                currentWidth++;
            }
        }
예제 #3
0
        private void GroupBlocks()
        {
            Block place = data.bottomLeft;
            Block current;

            for (int currWidth = 0; currWidth < data.width; currWidth++)
            {
                current = place;

                for (int currHeight = 0; currHeight < data.height; currHeight++)
                {
                    blocks.Add(current);
                    current.groupable.SetGroup(this);
                    current = current.GetTopAdjacent();
                }

                place = place.GetRightAdjacent();
            }
        }