public static bool GetCellOffsetXYOccupiedForShape ( STPieceShape shape, // O,I,S,Z,L,J,T; None int orientation, // 1,2,3,4; 0 == none int x, int y ) { if (STPieceShape.None == shape) { return(false); } // force orientation to range 1..totalOrientations int totalOrientations = 0; totalOrientations = STPiece.GetMaximumOrientationsOfShape(shape); if (0 == totalOrientations) { return(false); } orientation = 1 + ((((orientation - 1) % totalOrientations) + totalOrientations) % totalOrientations); // Loop through all cells and test against supplied cell. int totalCells = 0; totalCells = STPiece.GetTotalCellsForShape(shape); int cellIndex = 0; for (cellIndex = 1; cellIndex <= totalCells; cellIndex++) { int cellX = 0; int cellY = 0; STPiece.GetCellOffsetXYForShape(shape, orientation, cellIndex, ref cellX, ref cellY); if ((x == cellX) && (y == cellY)) { return(true); } } return(false); }
public void GetTranslatedCellXY ( int cellIndex, // 1,2,3,4; 0 == none ref int x, ref int y ) { x = 0; y = 0; if (cellIndex < 1) { return; } if (cellIndex > 4) { return; } int cellX = 0; int cellY = 0; STPiece.GetCellOffsetXYForShape(this.mShape, this.mOrientation, cellIndex, ref cellX, ref cellY); x = this.mX + cellX; y = this.mY + cellY; }