|
| 1 | +using System.Collections; |
| 2 | +using UnityEngine; |
| 3 | + |
| 4 | +namespace COTL_API.Utility; |
| 5 | + |
| 6 | +public class CinematicCameraManager |
| 7 | +{ |
| 8 | + |
| 9 | + public static List<IEnumerator> ActiveFocusPoints = []; |
| 10 | + public static void Zoom(float targetZoom) |
| 11 | + { |
| 12 | + GameManager.GetInstance().CameraSetTargetZoom(targetZoom); |
| 13 | + } |
| 14 | + |
| 15 | + public static void ZoomReset() |
| 16 | + { |
| 17 | + GameManager.GetInstance().CameraResetTargetZoom(); |
| 18 | + } |
| 19 | + |
| 20 | + public static SimpleSetCamera CreateAndActivateFocusPoint(Vector3 position) |
| 21 | + { |
| 22 | + var cam = CreateFocusPoint(position); |
| 23 | + cam.Play(); |
| 24 | + return cam; |
| 25 | + } |
| 26 | + |
| 27 | + public static void CreateAndPrepareTimedFocusPoint(Vector3 position, float duration) |
| 28 | + { |
| 29 | + ActiveFocusPoints.Add(CreateTimedFocusPoint(position, duration)); |
| 30 | + } |
| 31 | + |
| 32 | + private static IEnumerator CreateTimedFocusPoint(Vector3 position, float duration) |
| 33 | + { |
| 34 | + var cam = CreateFocusPoint(position); |
| 35 | + cam.Play(); |
| 36 | + yield return new WaitForSeconds(duration); |
| 37 | + } |
| 38 | + |
| 39 | + private static SimpleSetCamera CreateFocusPoint(Vector3 position) |
| 40 | + { |
| 41 | + var cam = new GameObject("CinematicCameraFocusPoint"); |
| 42 | + cam.transform.position = position; |
| 43 | + var ssc = cam.AddComponent<SimpleSetCamera>(); |
| 44 | + ssc.AutomaticallyActivate = false; |
| 45 | + return ssc; |
| 46 | + } |
| 47 | + |
| 48 | + public static IEnumerator ActivateAllCreatedFocusPoints() |
| 49 | + { |
| 50 | + foreach (var cam in ActiveFocusPoints) |
| 51 | + { |
| 52 | + yield return cam; |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + public static void ResetAllFocusPoints(float speed = 1f) |
| 57 | + { |
| 58 | + GameManager.GetInstance().CamFollowTarget.ResetTargetCamera(speed); |
| 59 | + ActiveFocusPoints.Clear(); |
| 60 | + } |
| 61 | + |
| 62 | + public static void AddFollowTarget(GameObject target, float weight = 1f) |
| 63 | + { |
| 64 | + CameraFollowTarget.Instance?.AddTarget(target, weight); |
| 65 | + } |
| 66 | + |
| 67 | + public static void RemoveFollowTarget(GameObject target) |
| 68 | + { |
| 69 | + CameraFollowTarget.Instance?.RemoveTarget(target); |
| 70 | + } |
| 71 | + |
| 72 | + public static void SetCameraLimits(bool enabled, Bounds limits) |
| 73 | + { |
| 74 | + if (!enabled) |
| 75 | + CameraFollowTarget.Instance?.DisableCameraLimits(); |
| 76 | + else |
| 77 | + CameraFollowTarget.Instance?.SetCameraLimits(limits); |
| 78 | + } |
| 79 | + |
| 80 | + public static void ShowLetterbox(bool show, bool showHudAfterHide = true, string subtitle = "") |
| 81 | + { |
| 82 | + if (show) |
| 83 | + { |
| 84 | + LetterBox.Show(false); |
| 85 | + if (subtitle != "") |
| 86 | + LetterBox.Instance?.ShowSubtitle(subtitle); |
| 87 | + } |
| 88 | + |
| 89 | + else |
| 90 | + LetterBox.Hide(showHudAfterHide); |
| 91 | + } |
| 92 | + |
| 93 | + public static void ShowHUD(bool show, int delay = 1) |
| 94 | + { |
| 95 | + if (show) |
| 96 | + HUD_Manager.Instance?.Show(delay); |
| 97 | + else |
| 98 | + HUD_Manager.Instance?.Hide(false); |
| 99 | + } |
| 100 | +} |
0 commit comments