Пример #1
0
        void GetRandomBlock()
        {
            int RandomPosition = rand.Next(0, 4);

            switch (RandomBlock)
            {
            case 0:
                t_block   = new T_Block(StartPoint, RandomPosition, BlockSize, board);
                moveLeft  = t_block.MoveLeft;
                moveRight = t_block.MoveRight;
                moveDown  = t_block.MoveDown;
                rotate    = t_block.Rotate;

                BlockColor        = t_block.color;
                returnCoordinates = t_block.returnCoordinates;

                break;

            case 1:
                square    = new Square(StartPoint, BlockSize, board);
                moveLeft  = square.MoveLeft;
                moveRight = square.MoveRight;
                moveDown  = square.MoveDown;
                rotate    = square.Rotate;

                BlockColor        = square.color;
                returnCoordinates = square.returnCoordinates;

                break;

            case 2:
                stick     = new Stick(StartPoint, RandomPosition, BlockSize, board);
                moveLeft  = stick.MoveLeft;
                moveRight = stick.MoveRight;
                moveDown  = stick.MoveDown;
                rotate    = stick.Rotate;

                BlockColor        = stick.color;
                returnCoordinates = stick.returnCoordinates;

                break;

            case 3:
                z_block   = new Z_Block(StartPoint, RandomPosition, BlockSize, board);
                moveLeft  = z_block.MoveLeft;
                moveRight = z_block.MoveRight;
                moveDown  = z_block.MoveDown;
                rotate    = z_block.Rotate;

                BlockColor        = z_block.color;
                returnCoordinates = z_block.returnCoordinates;
                break;

            //
            default:
                break;
            }
        }
Пример #2
0
        Bitmap DrawRandomBlock()
        {
            Bitmap  RandomDraft = new Bitmap(RandomBSheet.Width, RandomBSheet.Height);
            Painter @Painter    = new Painter(RandomDraft, BlockSize, RandomDraft.Width, RandomDraft.Height);

            int RandomPosition = rand.Next(0, 4);

            Color RColor = Color.FromArgb(40, 40, 40);

            Point Position = new Point(2 * BlockSize, 2 * BlockSize);

            switch (RandomBlock)
            {
            case 0:
                t_block = new T_Block(RandomDraft, Position, RandomPosition, BlockSize);
                t_block.Draw();
                @Painter.DrawArea(RColor);
                return(RandomDraft);

            case 1:
                square = new Square(RandomDraft, Position, BlockSize);
                square.Draw();
                @Painter.DrawArea(RColor);
                return(RandomDraft);

            case 2:
                stick = new Stick(RandomDraft, Position, RandomPosition, BlockSize);
                stick.Draw();
                @Painter.DrawArea(RColor);
                return(RandomDraft);

            case 3:
                z_block = new Z_Block(RandomDraft, Position, RandomPosition, BlockSize);
                z_block.Draw();
                @Painter.DrawArea(RColor);
                return(RandomDraft);

            default:
                return(RandomDraft);
            }
        }
Пример #3
0
        /// <summary>
        /// Creates a new shape objekt and assigns that to the Shapes objekt you send,
        /// </summary>
        /// <param name="shape"></param>
        /// <param name="startPosition"></param>
        /// <param name="number"></param>
        void NewShape(out Shapes shape, Point startPosition, int number)
        {
            switch (number)
            {
            case 0:
                shape = new Square(startPosition);
                break;

            case 1:
                shape = new L1(startPosition);
                break;

            case 2:
                shape = new L2(startPosition);
                break;

            case 3:
                shape = new TSymbol(startPosition);
                break;

            case 4:
                shape = new S1(startPosition);
                break;

            case 5:
                shape = new S2(startPosition);
                break;

            case 6:
                shape = new Stick(startPosition);
                break;

            default:
                shape = null;
                MessageBox.Show("Number not valid");
                break;
            }
        }
Пример #4
0
        void GetRandomBlock()
        {
            int RandomPosition = rand.Next(0, 4);

            switch (RandomBlock)
            {
                case 0:
                    t_block = new T_Block(StartPoint, RandomPosition, BlockSize,board);
                    moveLeft = t_block.MoveLeft;
                    moveRight = t_block.MoveRight;
                    moveDown = t_block.MoveDown;
                    rotate = t_block.Rotate;

                    BlockColor = t_block.color;
                    returnCoordinates = t_block.returnCoordinates;

                    break;
                case 1:
                    square = new Square(StartPoint, BlockSize,board);
                    moveLeft = square.MoveLeft;
                    moveRight = square.MoveRight;
                    moveDown = square.MoveDown;
                    rotate = square.Rotate;

                    BlockColor = square.color;
                    returnCoordinates = square.returnCoordinates;

                    break;
                case 2:
                    stick = new Stick(StartPoint, RandomPosition, BlockSize,board);
                    moveLeft = stick.MoveLeft;
                    moveRight = stick.MoveRight;
                    moveDown = stick.MoveDown;
                    rotate = stick.Rotate;

                    BlockColor = stick.color;
                    returnCoordinates = stick.returnCoordinates;

                    break;
                case 3:
                    z_block = new Z_Block(StartPoint, RandomPosition, BlockSize,board);
                    moveLeft = z_block.MoveLeft;
                    moveRight = z_block.MoveRight;
                    moveDown = z_block.MoveDown;
                    rotate = z_block.Rotate;

                    BlockColor = z_block.color;
                    returnCoordinates = z_block.returnCoordinates;
                    break;
                //
                default:
                    break;

            }
        }
Пример #5
0
        Bitmap DrawRandomBlock()
        {
            Bitmap RandomDraft = new Bitmap(RandomBSheet.Width, RandomBSheet.Height);
            Painter @Painter = new Painter(RandomDraft, BlockSize, RandomDraft.Width, RandomDraft.Height);

            int RandomPosition = rand.Next(0, 4);

            Color RColor = Color.FromArgb(40, 40, 40);

            Point Position = new Point(2 * BlockSize, 2 * BlockSize);

            switch(RandomBlock)
            {
                case 0:
                    t_block = new T_Block(RandomDraft, Position, RandomPosition, BlockSize);
                    t_block.Draw();
                    @Painter.DrawArea(RColor);
                    return RandomDraft;
                case 1:
                    square = new Square(RandomDraft, Position, BlockSize);
                    square.Draw();
                    @Painter.DrawArea(RColor);
                    return RandomDraft;
                case 2:
                    stick = new Stick(RandomDraft, Position, RandomPosition, BlockSize);
                    stick.Draw();
                    @Painter.DrawArea(RColor);
                    return RandomDraft;
                case 3:
                    z_block = new Z_Block(RandomDraft, Position, RandomPosition, BlockSize);
                    z_block.Draw();
                    @Painter.DrawArea(RColor);
                    return RandomDraft;
                default:
                    return RandomDraft;
            }
        }