using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using DG.Tweening; public class ConversationHelper : MonoBehaviour { public string CharacterName; public bool DontAllowTalkingAgain; public bool AllowEndEventsAgain = false; bool EndEventsFired = false; public UnityEvent ConvEndEvent; public GameObject ConvoCamera; public GameObject MainCamera; [ContextMenu("Awaker")] private void Awake() { if (MainCamera == null) { MainCamera = Camera.main.gameObject; } } private void OnEnable() { gameObject.name = CharacterName; } public void EnableConvoCamera() { ConvoCamera.transform.rotation = MainCamera.transform.rotation; ConvoCamera.transform.position = MainCamera.transform.position; ConvoCamera.SetActive(true); ConvoCamera.transform.DOLocalMove(Vector3.zero, 0.3f); ConvoCamera.transform.DOLocalRotate(Vector3.zero, 0.3f); MainCamera.SetActive(false); } public void EnableMainCamera() { Vector3 pos = MainCamera.transform.position; Vector3 rot = MainCamera.transform.eulerAngles; ConvoCamera.transform.DOMove(pos, 0.3f); ConvoCamera.transform.DORotate(rot, 0.3f).OnComplete(() => { MainCamera.SetActive(true); ConvoCamera.SetActive(false); }); } public void ConvEndEventInvoker() { EnableMainCamera(); if (!EndEventsFired || AllowEndEventsAgain) { ConvEndEvent?.Invoke(); ActivatorManager.Instance.TimeLineEvents.Add(ConvEndEvent); EndEventsFired = true; } if (DontAllowTalkingAgain) Destroy(gameObject); } }