public void Rotate(Coordinates coordinates, EFace lookingFace, ERotateDirection rotateDirection, float rotationTime) { //start rotation (can NOT skip) Rotate(new RotationStruct(new Coordinates[1] { coordinates }, lookingFace, rotateDirection, rotationTime, false)); }
IEnumerator RandomizeWorld() { //wait before randomize yield return(new WaitForSeconds(world.randomWorldConfig.TimeBeforeRandomize)); //for n times, rotate row or column for (int i = 0; i < world.randomWorldConfig.RandomizeTimes; i++) { //randomize rotation EFace face = (EFace)Random.Range(0, 6); int x = Random.Range(0, world.worldConfig.NumberCells); int y = Random.Range(0, world.worldConfig.NumberCells); ERotateDirection randomDirection = (ERotateDirection)Random.Range(0, 4); //effective rotation Rotate(new Coordinates(face, x, y), EFace.front, randomDirection, world.randomWorldConfig.RotationTime); //wait until the end of the rotation OnStartRotation(); yield return(new WaitWhile(() => waitRotation)); //if not last rotation, wait time between every rotation yield return(new WaitForSeconds(world.randomWorldConfig.TimeBetweenRotation)); //repeat if (world.randomWorldConfig.Loop) { i = 0; } } //call start game GameManager.instance.levelManager.StartGame(); }
public RotationStruct(Coordinates[] coordinates, EFace lookingFace, ERotateDirection rotateDirection, float rotationTime, bool canSkipAnimation) { this.coordinates = coordinates; this.lookingFace = lookingFace; this.rotateDirection = rotateDirection; this.rotationTime = rotationTime; this.canSkipAnimation = canSkipAnimation; }
public void PlayerRotate(Coordinates[] coordinates, EFace lookingFace, ERotateDirection rotateDirection, float rotationTime) { //do nothing if is running a rotation not skippable (enemy rotation) if (rotatingWorld_Coroutine != null && rotationsToDo.Peek().canSkipAnimation == false) { return; } //else start rotation (can skip) Rotate(new RotationStruct(coordinates, lookingFace, rotateDirection, rotationTime, true)); }
/// <summary> /// Enemy rotate cube /// </summary> public void RotateByEnemy(int numberRotations, float rotationTime) { //for n times, rotate row or column for (int i = 0; i < numberRotations; i++) { //randomize rotation EFace face = (EFace)Random.Range(0, 6); int x = Random.Range(0, worldConfig.NumberCells); int y = Random.Range(0, worldConfig.NumberCells); ERotateDirection randomDirection = (ERotateDirection)Random.Range(0, 4); //effective rotation worldRotator.Rotate(new Coordinates(face, x, y), EFace.front, randomDirection, rotationTime); } }
List <Coordinates> RotateMoreCells(ERotateDirection rotateDirection) { int selectorSize = GameManager.instance.levelManager.levelConfig.SelectorSize; EFace lookingFace = WorldUtility.LateralFace(transform); //check if get cells on x or y bool useX = rotateDirection == ERotateDirection.up || rotateDirection == ERotateDirection.down; //if rotating up or down face, when looking from right or left, inverse useX if (coordinates.face == EFace.up || coordinates.face == EFace.down) { if (lookingFace == EFace.right || lookingFace == EFace.left) { useX = !useX; } } int value = useX ? coordinates.x : coordinates.y; //check if there are enough cells to the right (useX) or up (!useX) bool increase = value + selectorSize - 1 < GameManager.instance.world.worldConfig.NumberCells; //min (next after our cell) and max (until selector size) //or min (from selector cell) and max (next after our cell) int min = increase ? value + 1 : value - (selectorSize - 1); int max = increase ? value + selectorSize : value; //increase or decrease List <Coordinates> coordinatesToRotate = new List <Coordinates>(); for (int i = min; i < max; i++) { //get coordinates using x or y Coordinates coords = useX ? new Coordinates(coordinates.face, i, coordinates.y) : new Coordinates(coordinates.face, coordinates.x, i); //if there is a cell, add it if (GameManager.instance.world.Cells.ContainsKey(coords)) { coordinatesToRotate.Add(coords); } } return(coordinatesToRotate); }
void DoRotation(ERotateDirection rotateDirection) { //do for number of rotations for (int i = 0; i < GameManager.instance.levelManager.levelConfig.NumberRotations; i++) { //if selector is greater, rotate more cells if (GameManager.instance.levelManager.levelConfig.SelectorSize > 1) { List <Coordinates> coordinatesToRotate = RotateMoreCells(rotateDirection); //get list of coordinates to rotate coordinatesToRotate.Add(coordinates); //add our coordinates GameManager.instance.world.PlayerRotate(coordinatesToRotate.ToArray(), WorldUtility.LateralFace(transform), rotateDirection, GameManager.instance.world.worldConfig.RotationTime); } //else rotate only this cell else { GameManager.instance.world.PlayerRotate(coordinates, WorldUtility.LateralFace(transform), rotateDirection, GameManager.instance.world.worldConfig.RotationTime); } } }
private RotateCommand(ERotateDirection p_rotation) : base(ECommandTypes.ROTATE) { m_rotation = p_rotation; }
/// <summary> /// Rotate the cube /// </summary> /// <param name="coordinates">coordinates to rotate</param> /// <param name="lookingFace">rotation of the camera</param> /// <param name="rotateDirection">row (right, left) or column (up, down)</param> public void PlayerRotate(Coordinates[] coordinates, EFace lookingFace, ERotateDirection rotateDirection, float rotationTime) { worldRotator.PlayerRotate(coordinates, lookingFace, rotateDirection, rotationTime); }
void DoSelectionCell(ERotateDirection direction) { //update coordinates coordinates = WorldUtility.SelectCell(WorldUtility.SelectFace(transform), coordinates.x, coordinates.y, WorldUtility.LateralFace(transform), direction); }
/// <summary> /// Select new cell /// </summary> public static Coordinates SelectCell(EFace startFace, int x, int y, EFace lookingFace, ERotateDirection rotateDirection) { Coordinates selectedCell = new Coordinates(startFace, x, y); //select right left if (rotateDirection == ERotateDirection.right || rotateDirection == ERotateDirection.left) { bool forward = rotateDirection == ERotateDirection.right; if (startFace == EFace.up || startFace == EFace.down) { //if face up or face down, the inputs are differents based on the rotation of the camera switch (lookingFace) { case EFace.front: selectedCell.x = SelectIndex(x, forward, GameManager.instance.world.worldConfig.NumberCells); break; case EFace.right: if (startFace == EFace.up) { selectedCell.y = SelectIndex(y, forward, GameManager.instance.world.worldConfig.NumberCells); } else { selectedCell.y = SelectIndex(y, !forward, GameManager.instance.world.worldConfig.NumberCells); } break; case EFace.back: selectedCell.x = SelectIndex(x, !forward, GameManager.instance.world.worldConfig.NumberCells); break; case EFace.left: if (startFace == EFace.up) { selectedCell.y = SelectIndex(y, !forward, GameManager.instance.world.worldConfig.NumberCells); } else { selectedCell.y = SelectIndex(y, forward, GameManager.instance.world.worldConfig.NumberCells); } break; } } else { //else just select row lateral faces selectedCell.x = SelectIndex(x, forward, GameManager.instance.world.worldConfig.NumberCells); } } //select up down else { bool forward = rotateDirection == ERotateDirection.up; //if face up or face down, the inputs are differents based on the rotation of the camera if (startFace == EFace.up || startFace == EFace.down) { switch (lookingFace) { case EFace.front: selectedCell.y = SelectIndex(y, forward, GameManager.instance.world.worldConfig.NumberCells); break; case EFace.right: if (startFace == EFace.up) { selectedCell.x = SelectIndex(x, !forward, GameManager.instance.world.worldConfig.NumberCells); } else { selectedCell.x = SelectIndex(x, forward, GameManager.instance.world.worldConfig.NumberCells); } break; case EFace.back: selectedCell.y = SelectIndex(y, !forward, GameManager.instance.world.worldConfig.NumberCells); break; case EFace.left: if (startFace == EFace.up) { selectedCell.x = SelectIndex(x, forward, GameManager.instance.world.worldConfig.NumberCells); } else { selectedCell.x = SelectIndex(x, !forward, GameManager.instance.world.worldConfig.NumberCells); } break; } } else { //else just select column selectedCell.y = SelectIndex(y, forward, GameManager.instance.world.worldConfig.NumberCells); } } return(selectedCell); }