//填补空白 public int[,] Fill(out List <FillPiece> fillList) { fillList = new List <FillPiece> (); //随机对象 System.Random rand = new System.Random(); //遍历图块数组找出所有空白 for (int i = 0; i < DataDefine.RowNum; i++) { for (int j = 0; j < DataDefine.ColNum; j++) { if (coreArray[i, j] == (int)BaseElement.None) { //随机1-5的数字,填充空白 coreArray[i, j] = rand.Next(1, 6); //生成填充图块对象 FillPiece fillpiece = new FillPiece(); fillpiece.row = i; fillpiece.col = j; fillpiece.type = coreArray[i, j]; //添加到列表 fillList.Add(fillpiece); } } } return(coreArray); }
public void Fill(ref List <FillPiece> fillList) //填补空白 { System.Random rand = new System.Random(); for (int i = 0; i < DataDefine.RowNum; i++) { for (int j = 0; j < DataDefine.ColNum; j++) { if (coreArray[i, j] == (int)BaseElement.None) { coreArray[i, j] = rand.Next(1, 6); FillPiece fillpiece = new FillPiece(); fillpiece.row = i; fillpiece.col = j; fillpiece.type = coreArray[i, j]; fillList.Add(fillpiece); } } } }