public RubiksCube(GameControl control) { gameControl = control; gameControl.cubeMatrix = new List <List <List <Unit> > > (); //初始化所有方块为灰色 for (int i = 0; i < cubeLength; i++) { List <List <Unit> > CubeRow = new List <List <Unit> > (); for (int j = 0; j < cubeLength; j++) { List <Unit> CubeColum = new List <Unit> (); for (int k = 0; k < cubeLength; k++) { Unit tempCube = new Unit(); tempCube.setAllEdgeColors(dto.getGrey()); CubeColum.Add(tempCube); } CubeRow.Add(CubeColum); } gameControl.cubeMatrix.Add(CubeRow); } //为每个面着色,国际魔方标准色为:上黄-下白,前蓝-后绿,左橙-右红。 for (int i = 0; i < cubeLength; i++) { for (int j = 0; j < cubeLength; j++) { gameControl.cubeMatrix[i][2][j].setColor(Unit.faces.top, dto.getYellow()); gameControl.cubeMatrix[i][0][j].setColor(Unit.faces.bottom, dto.getWhite()); gameControl.cubeMatrix[i][j][0].setColor(Unit.faces.front, dto.getBlue()); gameControl.cubeMatrix[i][j][2].setColor(Unit.faces.back, dto.getGreen()); gameControl.cubeMatrix[0][i][j].setColor(Unit.faces.left, dto.getOrange()); gameControl.cubeMatrix[2][i][j].setColor(Unit.faces.right, dto.getRed()); } } }