102 lines
2.9 KiB
C#
102 lines
2.9 KiB
C#
using AibisDream.FixSystem;
|
|
using AibisDream.Framework;
|
|
using AibisDream.Kit;
|
|
using Cinemachine;
|
|
using UnityEngine;
|
|
using UnityEngine.Playables;
|
|
using Yarn.Unity;
|
|
|
|
namespace AibisDream
|
|
{
|
|
public class OpenSystem : MonoBehaviour
|
|
{
|
|
public DeepInClock deepInClock;
|
|
public PlayableDirector fadeInPlayable;
|
|
public GameObject fadeInAnima;
|
|
public SpriteDeepIn deepIn;
|
|
public LightRoom lightRoom;
|
|
public GameObject screen;
|
|
|
|
private void Awake()
|
|
{
|
|
// 注册
|
|
FixSystemCenter.SystemDic.Register(this);
|
|
var virtualCam = transform.Find("Op Camera").GetComponent<ICinemachineCamera>();
|
|
CameraKit.Instance.RegisterCamera(CameraEnum.Op, virtualCam);
|
|
var virtualCam1 = transform.Find("Cut Emo Camera").GetComponent<ICinemachineCamera>();
|
|
var virtualCam2 = transform.Find("Cut Memory Camera").GetComponent<ICinemachineCamera>();
|
|
var virtualCam3 = transform.Find("Cut Logic Camera").GetComponent<ICinemachineCamera>();
|
|
CameraKit.Instance.RegisterCamera(CameraEnum.CutEmo, virtualCam1);
|
|
CameraKit.Instance.RegisterCamera(CameraEnum.CutMemory, virtualCam2);
|
|
CameraKit.Instance.RegisterCamera(CameraEnum.CutLogic, virtualCam3);
|
|
|
|
// 组装
|
|
deepInClock.OnClockReached += PlayFadeIn;
|
|
fadeInPlayable.stopped += PlayDeepIn;
|
|
deepIn.OnFinished += Finished;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.K))
|
|
{
|
|
EnableClock();
|
|
}
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
deepInClock.OnClockReached -= PlayFadeIn;
|
|
fadeInPlayable.stopped -= PlayDeepIn;
|
|
deepIn.OnFinished -= Finished;
|
|
}
|
|
|
|
public void OpenLightRoom()
|
|
{
|
|
screen.SetActive(false);
|
|
lightRoom.gameObject.SetActive(true);
|
|
}
|
|
|
|
public void EnableClock()
|
|
{
|
|
lightRoom.gameObject.SetActive(false);
|
|
deepInClock.Enable();
|
|
}
|
|
|
|
private void PlayFadeIn()
|
|
{
|
|
fadeInAnima.SetActive(true);
|
|
fadeInPlayable.Play();
|
|
}
|
|
|
|
private void PlayDeepIn(PlayableDirector director)
|
|
{
|
|
fadeInAnima.SetActive(false);
|
|
deepIn.gameObject.SetActive(true);
|
|
deepIn.Play();
|
|
}
|
|
|
|
private void Finished()
|
|
{
|
|
DialogController.Instance.StartDialogNode("DeepInEnd");
|
|
}
|
|
}
|
|
|
|
public static class OpenYarnCommand
|
|
{
|
|
private static OpenSystem OpenSystem => FixSystemCenter.SystemDic.Get<OpenSystem>();
|
|
|
|
[YarnCommand("enable_clock")]
|
|
public static void EnableClock()
|
|
{
|
|
OpenSystem.EnableClock();
|
|
}
|
|
|
|
[YarnCommand("open_light_room")]
|
|
public static void OpenLightRoom()
|
|
{
|
|
OpenSystem.OpenLightRoom();
|
|
}
|
|
}
|
|
}
|