public Figure(FiguresTypes figureType, ConsoleColor color, bool previewFigure = false) { PreviewFigure = previewFigure; FigureType = figureType; FigureAngle = FiguresAngle.StartPosition; FigureColor = color; Elements = GenerateFigureElements(FigureType, color, PreviewFigure); }
internal static int RotateRightArray2DValue(int x, int y, FiguresTypes figureType) { int a = x + 1; if (y > 24 || x > 16) { return(-1); } else { return(Array2D[y, a]); } }
internal List <BoxElement> GenerateFigureElements(FiguresTypes figureType, ConsoleColor color, bool NextFigure = false) { List <BoxElement> Elements = new List <BoxElement>(); int rowNumber = (int)FiguresAngle.StartPosition; int FigureTypeRowInList = (int)figureType; var figure_row = FigureCoordinates.Coordinates[FigureTypeRowInList][rowNumber]; int x = NextFigure ? GameData.NextStartCenterX : GameData.StartCenterX; int y = NextFigure ? GameData.NextStartCenterY : GameData.StartCenterY; Elements.Add(new BoxElement(x + figure_row.Item1.X, y + figure_row.Item1.Y, 0, color)); Elements.Add(new BoxElement(x + figure_row.Item2.X, y + figure_row.Item2.Y, 1, color)); Elements.Add(new BoxElement(x + figure_row.Item3.X, y + figure_row.Item3.Y, 2, color)); Elements.Add(new BoxElement(x + figure_row.Item4.X, y + figure_row.Item4.Y, 3, color)); return(Elements); }
internal bool CanRotateRight(FiguresTypes figureType, FiguresAngle figureAngle, int centerX, int centerY) { int rowNumber = (int)figureAngle + 1; if (rowNumber > 3) { rowNumber = 0; } int FigureTypeRowInList = (int)figureType; var figure_row = FigureCoordinates.Coordinates[FigureTypeRowInList][rowNumber]; int nextX = 88; int nextY = 88; switch (BoxIndex) { case 0: nextX = centerX + figure_row.Item1.X; nextY = centerY + figure_row.Item1.Y; break; case 1: nextX = centerX + figure_row.Item2.X; nextY = centerY + figure_row.Item2.Y; break; case 2: nextX = centerX + figure_row.Item3.X; nextY = centerY + figure_row.Item3.Y; break; case 3: nextX = centerX + figure_row.Item4.X; nextY = centerY + figure_row.Item4.Y; break; } return(TetrisArray.Array2DValue(nextX, nextY) == 0); }
internal void RotateRight(FiguresTypes figureType, FiguresAngle figureAngle, int x, int y) { int rowNumber = (int)figureAngle + 1; if (rowNumber > 3) { rowNumber = 0; } int FigureTypeRowInList = (int)figureType; var figure_row = FigureCoordinates.Coordinates[FigureTypeRowInList][rowNumber]; switch (BoxIndex) { case 0: X = x + figure_row.Item1.X; Y = y + figure_row.Item1.Y; break; case 1: X = x + figure_row.Item2.X; Y = y + figure_row.Item2.Y; break; case 2: X = x + figure_row.Item3.X; Y = y + figure_row.Item3.Y; break; case 3: X = x + figure_row.Item4.X; Y = y + figure_row.Item4.Y; break; } Render(); }
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); }