Exemplo n.º 1
0
 // Return the index of the faces corresponding to the given row index
 public static IList<CubePieceIndex> GetFacesInRow(CubeRowIndex rowIndex)
 {
     if (rowIndex == CubeRowIndex.Top)
     {
         return new List<CubePieceIndex>()
         {
             CubePieceIndex.Topleft,
             CubePieceIndex.TopCenter,
             CubePieceIndex.TopRight
         };
     }
     if (rowIndex == CubeRowIndex.Left)
     {
         return new List<CubePieceIndex>()
         {
             CubePieceIndex.Topleft,
             CubePieceIndex.CenterLeft,
             CubePieceIndex.BottomLeft
         };
     }
     if (rowIndex == CubeRowIndex.Right)
     {
         return new List<CubePieceIndex>()
         {
             CubePieceIndex.TopRight,
             CubePieceIndex.CenterRight,
             CubePieceIndex.BottomRight
         };
     }
     if (rowIndex == CubeRowIndex.Bottom)
     {
         return new List<CubePieceIndex>()
         {
             CubePieceIndex.BottomLeft,
             CubePieceIndex.BottomCenter,
             CubePieceIndex.BottomRight
         };
     }
     if (rowIndex == CubeRowIndex.CenterHorizontal)
     {
         return new List<CubePieceIndex>()
         {
             CubePieceIndex.CenterLeft,
             CubePieceIndex.Center,
             CubePieceIndex.CenterRight
         };
     }
     //if (rowIndex == CubeRowIndex.CenterVertical)
     //{
     return new List<CubePieceIndex>()
     {
         CubePieceIndex.TopCenter,
         CubePieceIndex.Center,
         CubePieceIndex.BottomCenter
     };
     //}
 }
Exemplo n.º 2
0
 // Replace the given rows with the new ones, and return the old row. Reverse the new pieces if required
 public IList<GameObject> ReplaceRow(CubeRowIndex rowIndex, IList<GameObject> newPieces, bool reversed)
 {
     // Reverse the new pieces if required
     if (reversed)
     {
         var swapPiece = newPieces[0];
         newPieces[0] = newPieces[2];
         newPieces[2] = swapPiece;
     }
     // Get the old row before replacig the new rows
     var oldRow = this.GetPiecesInRow(rowIndex);
     // Get all the faces in the given row and replace them with the new piece
     var faces = CubeRow.GetFacesInRow(rowIndex);
     for (int i = 0; i < 3; i++)
     {
         this.CubePieceList[faces[i]] = newPieces[i];
     }
     // Return the value of the old row
     return oldRow;
 }
Exemplo n.º 3
0
        // Return a list of the pieces from the certain row, from left to right and/or top to bottom
        public IList<GameObject> GetPiecesInRow(CubeRowIndex rowIndex)
        {
            // Get all the faces in the given row
            var faces = CubeRow.GetFacesInRow(rowIndex);

            // Add all the pieces from the face list to the result
            var result = new List<GameObject>();
            foreach (var face in faces)
            {
                result.Add(this.CubePieceList[face]);
            }
            return result;
        }