예제 #1
0
 private IEnumerator MoveCamera_Coro(CameraManager.Direction Dir)
 {
     cameraMove = true;
     // Start moving
     yield return StartCoroutine(MoveCameraFadeIn_Coro(Dir));
     // Stop move
     cameraMove = false;
 }
예제 #2
0
        private IEnumerator MoveCameraFadeOut_Coro(CameraManager.Direction StartDirection)
        {
            float ratio = 1;
            float time = 0;
            while (true)
            {
                time += Time.fixedDeltaTime * 2;
                ratio = Mathf.Lerp(1, 0, time);
                float ratio_time = Mathf.Clamp01(ratio) * Time.fixedDeltaTime;
                // No place to move
                if (!CheckDirection(StartDirection, ratio_time))
                    yield break;

                if (ratio > 0.1)
                    Move(StartDirection, ratio_time);
                // End of fade
                else
                    break;

                yield return new WaitForFixedUpdate();
            }
        }
예제 #3
0
        private IEnumerator MoveCameraLinear_CoRo(CameraManager.Direction Direction)
        {
            while (true)
            {
                // Can continue to move
                if (CameraMoveDirection() == Direction)
                {
                    // No place to move
                    if (!CheckDirection(Direction, Time.fixedDeltaTime))
                        yield break;
                    // Move
                    Move(Direction, Time.fixedDeltaTime);
                }
                // Stop move
                else
                {
                    // No place to move
                    if (!CheckDirection(Direction, 1))
                        yield break;
                    // Continue with Fade out
                    yield return StartCoroutine(MoveCameraFadeOut_Coro(Direction));

                    break;
                }

                yield return new WaitForFixedUpdate();
            }
        }
예제 #4
0
        private IEnumerator MoveCameraFadeIn_Coro(CameraManager.Direction StartDirection)
        {
            float ratio = 0;
            float time = 0;
            while (true)
            {
                // Can continue fade
                if (CameraMoveDirection() == StartDirection)
                {
                    time += Time.fixedDeltaTime;
                    ratio = Mathf.Lerp(0, 1.1f, time);
                    float ratio_time = Mathf.Clamp01(ratio) * Time.fixedDeltaTime;
                    // No place to move
                    if (!CheckDirection(StartDirection, ratio_time))
                        yield break;
                    // Still need to fade
                    if (ratio < 1)
                        Move(StartDirection, ratio_time);
                    // Fade in finished
                    else
                    {
                        yield return StartCoroutine(MoveCameraLinear_CoRo(StartDirection));
                        break;
                    }
                }
                // Fade interrupted, fade out
                else
                {
                    yield return StartCoroutine(MoveCameraFadeOut_Coro(StartDirection));

                    break;
                }
                yield return new WaitForFixedUpdate();
            }
        }