public Tetramino(TetraminoTypeEnum type, int[,] matrix, Vector2 pivot, RotationStateEnum currentRotation, MinoColorsEnum color) { Type = type; Matrix = matrix; Pivot = pivot; CurrentRotationState = currentRotation; Color = color; Size = new Vector2Int(Matrix.GetLength(0), Matrix.GetLength(1)); }
public static RotationStateEnum AddRotation(this RotationStateEnum state, RotationDirectionEnum rotation) { int length = Enum.GetValues(typeof(RotationStateEnum)).Length; int newValue = ((int)state + (int)rotation) % length; if (newValue < 0) { newValue += length; } return((RotationStateEnum)newValue); }
public static List <Vector2Int> Get(TetraminoTypeEnum type, RotationStateEnum currentState, RotationDirectionEnum direction) { WallKicksInfo wallKicks; switch (type) { case TetraminoTypeEnum.O: return(new List <Vector2Int>() { new Vector2Int(0, 0) }); case TetraminoTypeEnum.I: wallKicks = WallKicksI[currentState]; break; case TetraminoTypeEnum.L: case TetraminoTypeEnum.J: case TetraminoTypeEnum.Z: case TetraminoTypeEnum.S: case TetraminoTypeEnum.T: wallKicks = WallKicksJLSTZ[currentState]; break; default: throw new InvalidOperationException(); } switch (direction) { case RotationDirectionEnum.Clockwise: return(wallKicks.clockwiseWallKicks); case RotationDirectionEnum.Counterclockwise: return(wallKicks.counterClockwiseWallKicks); default: throw new InvalidOperationException(); } }