public bool Generate(int[] Quanity) //Задает массив тетромино { Quanity.CopyTo(Quanities, 0); int index = 0; for (int i = 0; i < 7; i++) { for (int j = 0; j < Quanities[i]; j++) { Tetrominos[index] = new Tetromino(i, true); index++; } } bool Solved = FitIn(0); if (Solved) { Console.Write("\n"); //Печатает решение for (int p = 0; p < _height; p++) { for (int l = 0; l < _width; l++) { Console.Write(Slots[p, _width - l - 1]); } Console.Write("\n"); } } return(Solved); }
public bool Generate() //Генерирует массив тетромино { int index; for (int i = 0; i < Tetrominos.Length; i++) { index = rnd.Next(0, 7); Tetrominos[i] = new Tetromino(index, true); Quanities[index]++; } bool Solved = FitIn(0); if (Solved) { Console.Write("\n"); //Печатает решение for (int p = 0; p < _height; p++) { for (int l = 0; l < _width; l++) { Console.Write(Slots[p, _width - l - 1]); } Console.Write("\n"); } global.form_menu.LoadLevel(new Game(Quanities[2], Quanities[5], Quanities[0], Quanities[1], Quanities[4], Quanities[6], Quanities[3], _width, _height, Backgrounds[rnd.Next(0, 5)])); } else { Console.WriteLine("Failed with L = " + Quanities[2].ToString() + "| I = " + Quanities[5].ToString() + "| O = " + Quanities[0].ToString() + "| J = " + Quanities[1].ToString() + "| Z = " + Quanities[4].ToString() + "| T = " + Quanities[6].ToString() + "| S = " + Quanities[3].ToString()); } return(Solved); }