public IEnumerator CentralMakeTileRotate(RotateTileSo HowToRotate, TileRotationReason TRR, BaseTile TileToRotate) { UngroupingPending = false; if (TRR != TileRotationReason.SteppedOn && TileToRotate.GetTileType() == TileType.Grouped && CurrentTile.GetTileType() != TileType.Grouped) { GroupTiles(TileToRotate); UngroupingPending = true; yield return(new WaitForSeconds(0.1f)); } GameObject Shadow = TileToRotate.GetShadow(); switch (HowToRotate) { case RotateTileSo.BackToOriginal: switch (TileToRotate.ThisTileFlipAxis) { case TileFlipAxis.Horizontal: MidFlipRotation = TileToRotate.transform.rotation; FinalFlipRotation = TileToRotate.transform.rotation; break; case TileFlipAxis.Vertical: MidFlipRotation = TileToRotate.transform.rotation; FinalFlipRotation = TileToRotate.transform.rotation; //MidFlipRotation = Quaternion.Euler(TileToRotate.transform.rotation.eulerAngles + HexAngleValues.HalfFlipVertical); //FinalFlipRotation = Quaternion.Euler(TileToRotate.transform.rotation.eulerAngles); break; } break; case RotateTileSo.FullFlip: switch (TileToRotate.ThisTileFlipAxis) { case TileFlipAxis.Horizontal: MidFlipRotation = Quaternion.Euler(TileToRotate.transform.rotation.eulerAngles + HexAngleValues.HalfFlipHorizontal); FinalFlipRotation = Quaternion.Euler(TileToRotate.transform.rotation.eulerAngles + HexAngleValues.FullFlipHorizontal); break; case TileFlipAxis.Vertical: MidFlipRotation = Quaternion.Euler(TileToRotate.transform.rotation.eulerAngles + HexAngleValues.HalfFlipVertical); FinalFlipRotation = Quaternion.Euler(TileToRotate.transform.rotation.eulerAngles + HexAngleValues.FullFlipVertical); break; } break; case RotateTileSo.Clockwise: FinalFlipRotation = Quaternion.Euler(TileToRotate.transform.rotation.eulerAngles + HexAngleValues.Clockwise); break; case RotateTileSo.AntiClockwise: FinalFlipRotation = Quaternion.Euler(TileToRotate.transform.rotation.eulerAngles + HexAngleValues.AntiClockwise); break; } if (HowToRotate != RotateTileSo.Clockwise && HowToRotate != RotateTileSo.AntiClockwise) { while (Quaternion.Angle(TileToRotate.transform.rotation, MidFlipRotation) > 2) { TileToRotate.transform.rotation = Quaternion.Lerp(TileToRotate.transform.rotation, MidFlipRotation, Time.deltaTime * TileToRotate.TileRotationSpeed); //* TileRotationSpeed Shadow.transform.rotation = Quaternion.Lerp(TileToRotate.transform.rotation, MidFlipRotation, Time.deltaTime * TileToRotate.TileRotationSpeed); //* TileRotationSpeed yield return(new WaitForFixedUpdate()); } TileToRotate.transform.rotation = MidFlipRotation; switch (TRR) { case TileRotationReason.SteppedOff: TileToRotate.TileHalfFlipAfterTraversal(); break; case TileRotationReason.SteppedOn: TileToRotate.TileHalfFlipOnTraversal(); break; case TileRotationReason.Remote: break; } } yield return(new WaitForSeconds(0.1f)); if (TileToRotate)// && HowToRotate != RotateTileSo.BackToOriginal) { while (Quaternion.Angle(TileToRotate.transform.rotation, FinalFlipRotation) > 2) { TileToRotate.transform.rotation = Quaternion.Lerp(TileToRotate.transform.rotation, FinalFlipRotation, Time.deltaTime * TileToRotate.TileRotationSpeed); // Shadow.transform.rotation = Quaternion.Lerp(TileToRotate.transform.rotation, FinalFlipRotation, Time.deltaTime * TileToRotate.TileRotationSpeed); // yield return(new WaitForFixedUpdate()); } TileToRotate.transform.rotation = FinalFlipRotation; TileToRotate.FlipComplete(TRR); } if (UngroupingPending) { UngroupTiles(TileToRotate); yield return(new WaitForSeconds(0.1f)); } RotationQueued = false; StartNewRotation(); }