184 lines
4.7 KiB
C#
184 lines
4.7 KiB
C#
using AibisDream.FixSystem;
|
|
using UnityEngine;
|
|
using UnityEngine.Playables;
|
|
using Yarn.Unity;
|
|
using System.Collections;
|
|
using DG.Tweening;
|
|
using AibisDream.Utility;
|
|
|
|
namespace AibisDream
|
|
{
|
|
public class OpenSystem : MonoBehaviour
|
|
{
|
|
public PlayableDirector openPlayable;
|
|
public PlayableDirector breakPlayable;
|
|
public PlayableDirector bubblePlayable;
|
|
|
|
public SpriteRenderer dreamSprite;
|
|
|
|
private void Awake()
|
|
{
|
|
FixSystemCenter.SystemDic.Register(this);
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
dreamSprite.gameObject.SetActive(true);
|
|
dreamSprite.SetAlpha(0);
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
}
|
|
|
|
public IEnumerator PlayOpenTimeline()
|
|
{
|
|
openPlayable.Play();
|
|
while (openPlayable.state == PlayState.Playing)
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
|
|
public void PlayOpenTimelineNoWait()
|
|
{
|
|
openPlayable.Play();
|
|
}
|
|
|
|
public IEnumerator PlayBreakTimeline()
|
|
{
|
|
breakPlayable.Play();
|
|
while (breakPlayable.state == PlayState.Playing)
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
|
|
public void PlayBreakTimelineNoWait()
|
|
{
|
|
breakPlayable.Play();
|
|
}
|
|
|
|
public IEnumerator PlayBubbleTimeline()
|
|
{
|
|
bubblePlayable.Play();
|
|
while (bubblePlayable.state == PlayState.Playing)
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
|
|
public void PlayBubbleTimelineNoWait()
|
|
{
|
|
bubblePlayable.Play();
|
|
}
|
|
|
|
public IEnumerator ResumeBubbleTimeline()
|
|
{
|
|
if (bubblePlayable != null && bubblePlayable.state == PlayState.Paused)
|
|
{
|
|
bubblePlayable.Resume();
|
|
while (bubblePlayable.state == PlayState.Playing)
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void PauseTimeline()
|
|
{
|
|
if (openPlayable != null && openPlayable.state == PlayState.Playing)
|
|
{
|
|
openPlayable.Pause();
|
|
}
|
|
if (breakPlayable != null && breakPlayable.state == PlayState.Playing)
|
|
{
|
|
breakPlayable.Pause();
|
|
}
|
|
if (bubblePlayable != null && bubblePlayable.state == PlayState.Playing)
|
|
{
|
|
bubblePlayable.Pause();
|
|
}
|
|
}
|
|
|
|
public void DreamFadeIn(float time, float targetAlpha)
|
|
{
|
|
dreamSprite.DOFade(targetAlpha, time).SetEase(Ease.InOutSine);
|
|
}
|
|
|
|
public void DreamDisappear()
|
|
{
|
|
dreamSprite.gameObject.SetActive(false);
|
|
}
|
|
|
|
public void FinishCut()
|
|
{
|
|
DialogController.Instance.StartDialogNode("Cut_End");
|
|
}
|
|
}
|
|
|
|
public static class OpenYarnCommand
|
|
{
|
|
private static OpenSystem OpenSystem => FixSystemCenter.SystemDic.Get<OpenSystem>();
|
|
|
|
[YarnCommand("play_open_timeline")]
|
|
public static IEnumerator PlayOpenTimeline()
|
|
{
|
|
yield return OpenSystem.PlayOpenTimeline();
|
|
}
|
|
|
|
[YarnCommand("play_open_timeline_no_wait")]
|
|
public static void PlayOpenTimelineNoWait()
|
|
{
|
|
OpenSystem.PlayOpenTimelineNoWait();
|
|
}
|
|
|
|
[YarnCommand("play_break_timeline")]
|
|
public static IEnumerator PlayBreakTimeline()
|
|
{
|
|
yield return OpenSystem.PlayBreakTimeline();
|
|
}
|
|
|
|
[YarnCommand("play_break_timeline_no_wait")]
|
|
public static void PlayBreakTimelineNoWait()
|
|
{
|
|
OpenSystem.PlayBreakTimelineNoWait();
|
|
}
|
|
|
|
[YarnCommand("play_bubble_timeline")]
|
|
public static IEnumerator PlayBubbleTimeline()
|
|
{
|
|
yield return OpenSystem.PlayBubbleTimeline();
|
|
}
|
|
|
|
[YarnCommand("play_bubble_timeline_no_wait")]
|
|
public static void PlayBubbleTimelineNoWait()
|
|
{
|
|
OpenSystem.PlayBubbleTimelineNoWait();
|
|
}
|
|
|
|
[YarnCommand("resume_bubble_timeline")]
|
|
public static IEnumerator ResumeBubbleTimeline()
|
|
{
|
|
yield return OpenSystem.ResumeBubbleTimeline();
|
|
}
|
|
|
|
[YarnCommand("pause_timeline")]
|
|
public static void PauseTimeline()
|
|
{
|
|
OpenSystem.PauseTimeline();
|
|
}
|
|
|
|
[YarnCommand("dream_fade_in")]
|
|
public static void DreamFadeIn(float time, float targetAlpha)
|
|
{
|
|
OpenSystem.DreamFadeIn(time, targetAlpha);
|
|
}
|
|
|
|
[YarnCommand("dream_disappear")]
|
|
public static void DreamDisappear()
|
|
{
|
|
OpenSystem.DreamDisappear();
|
|
}
|
|
}
|
|
} |