117 lines
3.0 KiB
C#
117 lines
3.0 KiB
C#
using System.Linq.Expressions;
|
|
using AibisDream.FixSystem;
|
|
using AibisDream.Framework;
|
|
using AibisDream.Kit;
|
|
using Cinemachine;
|
|
using UnityEngine;
|
|
using UnityEngine.Playables;
|
|
using Yarn.Unity;
|
|
using System.Collections;
|
|
|
|
namespace AibisDream
|
|
{
|
|
public class OpenSystem : MonoBehaviour
|
|
{
|
|
public DeepInClock deepInClock;
|
|
public PlayableDirector OpenPlayable;
|
|
public GameObject OpenAnima;
|
|
public SpriteDeepIn deepIn;
|
|
public LightRoom lightRoom;
|
|
public GameObject screen;
|
|
private bool isCuttingMode = false;
|
|
|
|
private void Awake()
|
|
{
|
|
// 注册
|
|
FixSystemCenter.SystemDic.Register(this);
|
|
var virtualCam = transform.Find("Op Camera").GetComponent<ICinemachineCamera>();
|
|
CameraKit.Instance.RegisterCamera(CameraEnum.Op, virtualCam);
|
|
|
|
// 组装
|
|
// deepInClock.OnClockReached += PlayFadeIn;
|
|
// fadeInPlayable.stopped += PlayDeepIn;
|
|
// deepIn.OnFinished += Finished;
|
|
}
|
|
|
|
public 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();
|
|
}
|
|
|
|
// public void PlayFadeIn()
|
|
// {
|
|
// fadeInAnima.SetActive(true);
|
|
// fadeInPlayable.Play();
|
|
// }
|
|
public void PlayOpenTimeline()
|
|
{
|
|
OpenAnima.SetActive(true);
|
|
OpenPlayable.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();
|
|
}
|
|
[YarnCommand("play_open_timeline")]
|
|
public static IEnumerator RunTimeline()
|
|
{
|
|
OpenSystem.PlayOpenTimeline();
|
|
|
|
if (true)
|
|
{
|
|
while (OpenSystem.OpenPlayable.state == PlayState.Playing)
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|