2025-10-03 20:00:05 +05:00
|
|
|
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;
|
2025-10-08 01:03:39 +05:00
|
|
|
[ContextMenu("Awaker")]
|
2025-10-03 20:00:05 +05:00
|
|
|
private void Awake()
|
|
|
|
{
|
2025-10-08 01:03:39 +05:00
|
|
|
if (MainCamera == null)
|
|
|
|
{
|
|
|
|
MainCamera = Camera.main.gameObject;
|
|
|
|
}
|
2025-10-03 20:00:05 +05:00
|
|
|
}
|
|
|
|
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();
|
2025-10-08 01:03:39 +05:00
|
|
|
ActivatorManager.Instance.TimeLineEvents.Add(ConvEndEvent);
|
2025-10-03 20:00:05 +05:00
|
|
|
EndEventsFired = true;
|
|
|
|
}
|
|
|
|
if (DontAllowTalkingAgain) Destroy(gameObject);
|
|
|
|
}
|
|
|
|
}
|