Esempio n. 1
0
        public static Figure CreateFigure(int[,] bodyCurrF, TColor colorCurrFig, FiguresTypes idCurrFigType, TetrisGameBoard board)
        {
            Figure fig = null;

            switch (idCurrFigType)
            {
            case FiguresTypes.LeftG:
                fig = new LeftG(colorCurrFig, bodyCurrF, board);
                break;

            case FiguresTypes.LeftZigzag:
                fig = new LeftZigzag(colorCurrFig, bodyCurrF, board);
                break;

            case FiguresTypes.LetterT:
                fig = new LetterT(colorCurrFig, bodyCurrF, board);
                break;

            case FiguresTypes.RightG:
                fig = new RightG(colorCurrFig, bodyCurrF, board);
                break;

            case FiguresTypes.RightZigzag:
                fig = new RightZigzag(colorCurrFig, bodyCurrF, board);
                break;

            case FiguresTypes.Square:
                fig = new Square(colorCurrFig, bodyCurrF, board);
                break;

            case FiguresTypes.Stick:
                fig = new Stick(colorCurrFig, bodyCurrF, board);
                break;
            }
            return(fig);
        }
Esempio n. 2
0
        public static Figure GetFigure(TetrisGameBoard board)
        {
            Figure fig;
            int    choseFigure = Rnd.Next(0, NumberOfFigures);
            TColor color       = (TColor)Rnd.Next(1, NumberOfColors + 1);

            int[,] body;
            switch (choseFigure)
            {
            case 0:
                body = new int[, ] {
                    { 1, 0 }, { 2, 0 }, { 2, 1 }, { 2, 2 }
                };
                fig = new LeftG(color, (int[, ])body.Clone(), board);
                break;

            case 1:
                body = new int[, ] {
                    { 2, 0 }, { 2, 1 }, { 1, 2 }, { 2, 2 }
                };
                fig = new RightG(color, (int[, ])body.Clone(), board);
                break;

            case 2:
                body = new int[, ] {
                    { 1, 0 }, { 1, 1 }, { 2, 1 }, { 2, 2 }
                };
                fig = new LeftZigzag(color, (int[, ])body.Clone(), board);
                break;

            case 3:
                body = new int[, ] {
                    { 2, 0 }, { 1, 1 }, { 2, 1 }, { 1, 2 }
                };
                fig = new RightZigzag(color, (int[, ])body.Clone(), board);
                break;

            case 4:
                body = new int[, ] {
                    { 1, 1 }, { 2, 1 }, { 3, 1 }, { 2, 2 }
                };
                fig = new LetterT(color, (int[, ])body.Clone(), board);
                break;

            case 5:
                body = new int[, ] {
                    { 1, 1 }, { 2, 1 }, { 1, 2 }, { 2, 2 }
                };
                fig = new Square(color, (int[, ])body.Clone(), board);
                break;

            case 6:
                body = new int[, ] {
                    { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 }
                };
                fig = new Stick(color, (int[, ])body.Clone(), board);
                break;

            default:
                body = new int[, ] {
                    { 1, 1 }, { 2, 1 }, { 1, 2 }, { 2, 2 }
                };
                fig = new Square(color, (int[, ])body.Clone(), board);
                break;
            }
            return(fig);
        }