public FildColor(Fild fg) { FildColorArray = new ConsoleColor[fg.FildGame.GetLength(0), fg.FildGame.GetLength(1)]; for (int y = 0; y < fg.FildGame.GetLength(0); y++) { for (int x = 0; x < fg.FildGame.GetLength(1); x++) { FildColorArray[y, x] = Settings.ConsColBackground; } } }
public static void RunGame() { haveGame = true; isSave = false; Console.CursorVisible = false; Console.Clear(); GameFild = new Fild(Settings.FildHeight, Settings.FildWidth); GameFild.NewFigure(); bodyWhile(); }
public static void TakeOutFigForm(Fild fg) { for (int i = 0; i < fg.FigNow.Form.GetLength(0); i++) { for (int j = 0; j < fg.FigNow.Form.GetLength(1); j++) { if (fg.FigNow.Form[i, j] == true) { fg.FildGame[i + dotMove[0], j + dotMove[1]] = false; if (fg.DelBrickColor != null) { fg.DelBrickColor(i + dotMove[0], j + dotMove[1], Settings.ConsColBackground); } } } } }
public static void SetFigForm(Fild fg) { for (int i = 0; i < fg.FigNow.Form.GetLength(0); i++) { for (int j = 0; j < fg.FigNow.Form.GetLength(1); j++) { if (fg.FigNow.Form[i, j] == true) { fg.FildGame[i + dotMove[0], j + dotMove[1]] = true; if (fg.AddBrickColor != null) { fg.AddBrickColor(dotMove[0] + i, dotMove[1] + j, fg.FigNow.FigureColor); } } } } }
public static bool CheckRight(Fild fg) { if (Move.dotMove[1] + fg.FigNow.Form.GetLength(1) == fg.FildGame.GetLength(1)) { return(false); } else { Move.dotMove[1]++; if (SupportMethods.Intersection(fg.FigNow.Form, fg)) { Move.dotMove[1]--; return(true); } else { Move.dotMove[1]--; return(false); } } }
public static bool CheckLeft(Fild fg) { if (Move.dotMove[1] == 0) { return(false); } else { Move.dotMove[1]--; if (SupportMethods.Intersection(fg.FigNow.Form, fg)) { Move.dotMove[1]++; return(true); } else { Move.dotMove[1]++; return(false); } } }
public static void CheckRows(Fild fg) { Move.SetFigForm(fg); var flag = 0b11; for (int i = 0; i < fg.FildGame.GetLength(0); i++) { flag = flag | 0b10; for (int j = 0; j < fg.FildGame.GetLength(1); j++) { if (fg.FildGame[i, j] == false) { flag = flag & 0b01; break; } } if ((flag & 0b10) == 0b10) { FallWall(i); fg.Score += fg.FildGame.GetLength(1); } } void FallWall(int row) { for (int i = row; i > 0; i--) { for (int j = 0; j < fg.FildGame.GetLength(1); j++) { fg.FildGame[i, j] = fg.FildGame[i - 1, j]; if (Run.GameFild.FallWallColorScreen != null) { Run.GameFild.FallWallColorScreen(i, j); } } } for (int i = 0, j = 0; j < fg.FildGame.GetLength(1); j++) { fg.FildGame[i, j] = false; if (Run.GameFild.ClearUpLine != null) { Run.GameFild.ClearUpLine(i, j); } } } }
public static void Push(ConsoleKeyInfo key, Fild GameFild) { char ch = key.KeyChar; if (ch.Equals(Settings.controlsKeys[0])) { ch = 'h'; } else if (ch.Equals(Settings.controlsKeys[1])) { ch = 'k'; } else if (ch.Equals(Settings.controlsKeys[2])) { ch = 'j'; } else if (ch.Equals(Settings.controlsKeys[3])) { ch = 'u'; } else if (ch.Equals(Settings.controlsKeys[4])) { ch = 'q'; } else { return; } switch (ch) { case ('h'): if (Move.CheckLeft(GameFild)) { Move.MoveLeft(GameFild); GameFild.ScreenRender(); } break; case ('k'): if (Move.CheckRight(GameFild)) { Move.MoveRight(GameFild); GameFild.ScreenRender(); } break; case ('j'): if (Move.CheckDowd(GameFild)) { if (!Run.FlagFastFall) { Move.MoveDowd(GameFild); } Run.FlagFastFall = !Run.FlagFastFall; Run.count = 0; Run.StepFall = Run.FlagFastFall ? 10 : 99; } else { GameFild.NewFigure(); } GameFild.ScreenRender(); break; case ('u'): GameFild.FigNow.Rotate(GameFild); GameFild.ScreenRender(); break; case ('q'): GameFild.RunGame = false; Console.ResetColor(); Console.CursorVisible = true; break; } }
public static void PrintCharScreen(Fild fg) { Move.SetFigForm(fg); System.Console.CursorTop = 0; Console.CursorLeft = 0; Console.BackgroundColor = Settings.ConsColBackground; Console.ForegroundColor = Settings.ConsColBrick; for (int i = 0; i < fg.FildGame.GetLength(0); i++) { for (int j = 0; j < fg.FildGame.GetLength(1); j++) { if (fg.FildGame[i, j]) { System.Console.Write(Settings.keyBuild); } else { System.Console.Write(Settings.keyBackground); } } System.Console.WriteLine(); } Move.TakeOutFigForm(fg); Console.ResetColor(); System.Console.WriteLine(Fild.counter); // print Score Console.CursorTop = 0; Console.CursorLeft = fg.FildGame.GetLength(1) + 3; Console.ForegroundColor = ConsoleColor.Red; System.Console.WriteLine(String.Format($"{fg.Score,10}")); // clear place for view NextFig for (int i = 0; i < fg.FigNext.Form.GetLength(0); i++) { ClearLine(); for (int j = 0; j < fg.FigNext.Form.GetLength(1); j++) { if (fg.FigNext.Form[i, j]) { System.Console.Write(Settings.keyBuild); } else { System.Console.Write(Settings.keyBackground); } } } if (fg.FigNext.Form.GetLength(0) < 3) { ClearLine(); ClearLine(); } else if (fg.FigNext.Form.GetLength(0) < 4) { ClearLine(); } void ClearLine() { System.Console.WriteLine(); Console.CursorLeft = fg.FildGame.GetLength(1) + 3; System.Console.Write($" "); Console.CursorLeft = fg.FildGame.GetLength(1) + 3; } // Task System.Console.WriteLine(); System.Console.WriteLine(); Console.CursorLeft = fg.FildGame.GetLength(1) + 3; System.Console.Write("Q: quit."); }
public static void MoveRight(Fild fg) { Move.dotMove[1]++; }
public static void MoveLeft(Fild fg) { Move.dotMove[1]--; }
public static void MoveDowd(Fild fg) { Move.dotMove[0]++; }