IEnumerator Transition() { if (!UseTopBoundary && !UseBottomBoundary && !UseLeftBoundary && !UseRightBoundary) { NumericBoundaries.UseNumericBoundaries = false; yield break; } // Avoid unnecessary transitions var skip = true; if (UseTopBoundary && (NumericBoundaries.TopBoundary != TopBoundary || !NumericBoundaries.UseTopBoundary)) { skip = false; } if (UseBottomBoundary && (NumericBoundaries.BottomBoundary != BottomBoundary || !NumericBoundaries.UseBottomBoundary)) { skip = false; } if (UseLeftBoundary && (NumericBoundaries.LeftBoundary != LeftBoundary || !NumericBoundaries.UseLeftBoundary)) { skip = false; } if (UseRightBoundary && (NumericBoundaries.RightBoundary != RightBoundary || !NumericBoundaries.UseRightBoundary)) { skip = false; } if (skip) { yield break; } NumericBoundaries.UseNumericBoundaries = true; GetTargetBoundaries(); _boundsAnim.UseTopBoundary = UseTopBoundary; _boundsAnim.TopBoundary = _targetTopBoundary; _boundsAnim.UseBottomBoundary = UseBottomBoundary; _boundsAnim.BottomBoundary = _targetBottomBoundary; _boundsAnim.UseLeftBoundary = UseLeftBoundary; _boundsAnim.LeftBoundary = _targetLeftBoundary; _boundsAnim.UseRightBoundary = UseRightBoundary; _boundsAnim.RightBoundary = _targetRightBoundary; _boundsAnim.TransitionDuration = TransitionDuration; _boundsAnim.TransitionEaseType = TransitionEaseType; // Zoom if (ChangeZoom && _initialCamSize / TargetZoom != ProCamera2D.ScreenSizeInWorldCoordinates.y * .5f) { ProCamera2D.UpdateScreenSize(_initialCamSize / TargetZoom, ZoomSmoothness, TransitionEaseType); } // Move camera "manually" if (_boundsAnim.GetAnimsCount() > 1) { if (NumericBoundaries.MoveCameraToTargetRoutine != null) { NumericBoundaries.StopCoroutine(NumericBoundaries.MoveCameraToTargetRoutine); } NumericBoundaries.MoveCameraToTargetRoutine = NumericBoundaries.StartCoroutine(MoveCameraToTarget()); } // Start bounds animation yield return(new WaitForEndOfFrame()); _boundsAnim.Transition(); }
IEnumerator Transition() { if (!UseTopBoundary && !UseBottomBoundary && !UseLeftBoundary && !UseRightBoundary) { NumericBoundaries.UseTopBoundary = false; NumericBoundaries.UseBottomBoundary = false; NumericBoundaries.UseLeftBoundary = false; NumericBoundaries.UseRightBoundary = false; yield break; } var position = transform.position; var topBoundary = AreBoundariesRelative ? position.y + TopBoundary : TopBoundary; var bottomBoundary = AreBoundariesRelative ? position.y + BottomBoundary : BottomBoundary; var leftBoundary = AreBoundariesRelative ? position.x + LeftBoundary : LeftBoundary; var rightBoundary = AreBoundariesRelative ? position.x + RightBoundary : RightBoundary; const float epsilon = 0.01f; // Avoid unnecessary transitions var skip = true; if (UseTopBoundary && (Mathf.Abs(NumericBoundaries.TopBoundary - topBoundary) > epsilon || !NumericBoundaries.UseTopBoundary)) { skip = false; } if (skip && UseBottomBoundary && (Mathf.Abs(NumericBoundaries.BottomBoundary - bottomBoundary) > epsilon || !NumericBoundaries.UseBottomBoundary)) { skip = false; } if (skip && UseLeftBoundary && (Mathf.Abs(NumericBoundaries.LeftBoundary - leftBoundary) > epsilon || !NumericBoundaries.UseLeftBoundary)) { skip = false; } if (skip && UseRightBoundary && (Mathf.Abs(NumericBoundaries.RightBoundary - rightBoundary) > epsilon || !NumericBoundaries.UseRightBoundary)) { skip = false; } if (skip) { yield break; } GetTargetBoundaries(); _boundsAnim.UseTopBoundary = UseTopBoundary; _boundsAnim.TopBoundary = _targetTopBoundary; _boundsAnim.UseBottomBoundary = UseBottomBoundary; _boundsAnim.BottomBoundary = _targetBottomBoundary; _boundsAnim.UseLeftBoundary = UseLeftBoundary; _boundsAnim.LeftBoundary = _targetLeftBoundary; _boundsAnim.UseRightBoundary = UseRightBoundary; _boundsAnim.RightBoundary = _targetRightBoundary; _boundsAnim.TransitionDuration = TransitionDuration; _boundsAnim.TransitionEaseType = TransitionEaseType; // Zoom if (ChangeZoom && _initialCamSize / TargetZoom != ProCamera2D.ScreenSizeInWorldCoordinates.y * .5f) { ProCamera2D.UpdateScreenSize(_initialCamSize / TargetZoom, ZoomSmoothness, TransitionEaseType); } // Move camera "manually" if (_boundsAnim.GetAnimsCount() > 1) { if (NumericBoundaries.MoveCameraToTargetRoutine != null) { NumericBoundaries.StopCoroutine(NumericBoundaries.MoveCameraToTargetRoutine); } NumericBoundaries.MoveCameraToTargetRoutine = NumericBoundaries.StartCoroutine(MoveCameraToTarget()); } // Start bounds animation yield return(new WaitForEndOfFrame()); _boundsAnim.Transition(); //if (CameraController.instance.setBoudariesLeft) //{ // CameraController.instance.setBoudariesLeft = false; // GameController.instance.currentMap.BeginAutoSpawn(GameController.instance.currentMap.autoSpawnEnemys[CameraController.instance.currentCamBoidaries].autoSpawnEnemy); //} }