void RotateRightLeftColumn(EFace startFace, bool toUp) { //foreach coordinate, use x to select foreach (Coordinates coordinates in coordinatesToRotate) { int x = coordinates.x; //right face. Left face is the inverse if (startFace == EFace.right) { SelectRightLeftColumnCells(x); } else { SelectRightLeftColumnCells(WorldMath.InverseN(x, world.worldConfig.NumberCells)); } } //in the left is inverse if (startFace == EFace.left) { toUp = !toUp; } //rotate animation if (world.gameObject.activeInHierarchy) { rotatingWorld_Coroutine = world.StartCoroutine(AnimationRotate(Vector3.forward, toUp)); } //update dictionary UpdateDictionaryRightLeftColumn(toUp); }
void SelectFrontColumnCells(int x) { //select x in every front face for (int faceIndex = 0; faceIndex < 4; faceIndex++) { //set f equal to faceIndex, but instead of right and left, use up and down EFace face = (EFace)faceIndex; if ((EFace)faceIndex == EFace.right) { face = EFace.up; } if ((EFace)faceIndex == EFace.left) { face = EFace.down; } for (int y = 0; y < world.worldConfig.NumberCells; y++) { //line is equal to x //but when is face back is the inverse of the other faces, so column 0 is 2, column 1 is 1, column 2 is 0 int line = face != EFace.back ? x : WorldMath.InverseN(x, world.worldConfig.NumberCells); SelectCell(new Coordinates(face, line, y)); } } //select all face right or left SelectAllFace(x, EFace.left, EFace.right); }
void RotateUpDownRow(EFace startFace, bool toRight) { //foreach coordinate, use y to select foreach (Coordinates coordinates in coordinatesToRotate) { int y = coordinates.y; //rotate y. Down face is the inverse if (startFace == EFace.up) { SelectUpDownRowCells(y); } else { SelectUpDownRowCells(WorldMath.InverseN(y, world.worldConfig.NumberCells)); } } //in the down face is inverse if (startFace == EFace.down) { toRight = !toRight; } //rotate animation if (world.gameObject.activeInHierarchy) { rotatingWorld_Coroutine = world.StartCoroutine(AnimationRotate(Vector3.forward, !toRight)); } //update dictionary UpdateDictionaryUpDownRow(toRight); }
public static Vector2Int Self_InverseInverse(int x, int y, int numberCells) { //0,0 -> 2,2 //1,0 -> 1,2 //2,0 -> 0,2 //0,1 -> 2,1 //1,1 -> 1,1 //2,1 -> 0,1 //0,2 -> 2,0 //1,2 -> 1,0 //2,2 -> 0,0 int newX = WorldMath.InverseN(x, numberCells); int newY = WorldMath.InverseN(y, numberCells); return(new Vector2Int(newX, newY)); }
void SelectUpDownRowCells(int y) { //select y in up, right, down, left face for (int faceIndex = 0; faceIndex < 4; faceIndex++) { //set f equal to faceIndex, but instead of front and back, use up and down EFace face = (EFace)faceIndex; if ((EFace)faceIndex == EFace.front) { face = EFace.up; } if ((EFace)faceIndex == EFace.back) { face = EFace.down; } for (int x = 0; x < world.worldConfig.NumberCells; x++) { switch (face) { case EFace.up: //up select the row SelectCell(new Coordinates(face, x, y)); break; case EFace.down: //down select the row but inverse of up SelectCell(new Coordinates(face, x, WorldMath.InverseN(y, world.worldConfig.NumberCells))); break; case EFace.right: //right select the column instead of row SelectCell(new Coordinates(face, y, x)); break; case EFace.left: //left select the column instead of row //but if you are rotating the first row, this is the last column, if you are rotating the last row, this is the first column SelectCell(new Coordinates(face, WorldMath.InverseN(y, world.worldConfig.NumberCells), x)); break; } } } //select all face front or back SelectAllFace(y, EFace.front, EFace.back); }
void SelectRightLeftColumnCells(int x) { //select line in up, right, down, left face for (int faceIndex = 0; faceIndex < 4; faceIndex++) { //set f equal to faceIndex, but instead of front and back, use up and down EFace face = (EFace)faceIndex; if ((EFace)faceIndex == EFace.front) { face = EFace.up; } if ((EFace)faceIndex == EFace.back) { face = EFace.down; } for (int y = 0; y < world.worldConfig.NumberCells; y++) { switch (face) { case EFace.right: //select column SelectCell(new Coordinates(face, x, y)); break; case EFace.left: //left select the column, but inverse (when select 0 is the last, when select last is the 0) SelectCell(new Coordinates(face, WorldMath.InverseN(x, world.worldConfig.NumberCells), y)); break; case EFace.up: //up select the row instead of column SelectCell(new Coordinates(face, y, x)); break; case EFace.down: //down is inverse of up SelectCell(new Coordinates(face, y, WorldMath.InverseN(x, world.worldConfig.NumberCells))); break; } } } //select all face front or back SelectAllFace(x, EFace.front, EFace.back); }