132 lines
4.3 KiB
C#
132 lines
4.3 KiB
C#
using System.Collections;
|
|
using UnityEngine;
|
|
using Yarn.Unity;
|
|
|
|
namespace AibisDream
|
|
{
|
|
public static class DreamDoorYarnCommand
|
|
{
|
|
private static DreamDoorSystem ResolveSystem()
|
|
{
|
|
if (DreamDoorSystem.Instance != null)
|
|
return DreamDoorSystem.Instance;
|
|
|
|
var system = Object.FindObjectOfType<DreamDoorSystem>(includeInactive: true);
|
|
if (system == null)
|
|
{
|
|
Debug.LogError("[DreamDoorYarnCommand] 当前场景中不存在 DreamDoorSystem,已跳过门演出命令。");
|
|
return null;
|
|
}
|
|
|
|
if (!system.gameObject.activeSelf)
|
|
system.gameObject.SetActive(true);
|
|
|
|
return DreamDoorSystem.Instance != null ? DreamDoorSystem.Instance : system;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 显示整个门(仅 background + Frame)。默认门是隐藏的,需先调用此命令。
|
|
/// </summary>
|
|
[YarnCommand("show_door")]
|
|
public static IEnumerator ShowDoor(float duration = 0f)
|
|
{
|
|
var system = ResolveSystem();
|
|
if (system == null) yield break;
|
|
yield return system.ShowDoor(duration);
|
|
}
|
|
|
|
[YarnCommand("show_door_listen_view")]
|
|
public static IEnumerator ShowDoorListenView(bool showSea = false, float duration = 0f)
|
|
{
|
|
var system = ResolveSystem();
|
|
if (system == null) yield break;
|
|
yield return system.ShowListenView(showSea, duration);
|
|
}
|
|
|
|
[YarnCommand("show_door_glass_sea")]
|
|
public static IEnumerator ShowDoorGlassSea(float duration = 2f)
|
|
{
|
|
var system = ResolveSystem();
|
|
if (system == null) yield break;
|
|
yield return system.ShowGlassSea(duration);
|
|
}
|
|
|
|
[YarnCommand("hide_door_glass_sea")]
|
|
public static IEnumerator HideDoorGlassSea(float duration = 1f)
|
|
{
|
|
var system = ResolveSystem();
|
|
if (system == null) yield break;
|
|
yield return system.HideGlassSea(duration);
|
|
}
|
|
|
|
[YarnCommand("tween_door_closeup")]
|
|
public static IEnumerator TweenDoorCloseup(float scale, float alpha, float duration)
|
|
{
|
|
var system = ResolveSystem();
|
|
if (system == null) yield break;
|
|
yield return system.TweenListenCloseup(scale, alpha, duration);
|
|
}
|
|
|
|
[YarnCommand("tween_door_closeup_async")]
|
|
public static void TweenDoorCloseupAsync(float scale, float alpha, float duration)
|
|
{
|
|
var system = ResolveSystem();
|
|
if (system == null) return;
|
|
// 走系统内可取消入口,避免多个 async closeup 叠跑把 scale 卡在放大态。
|
|
system.TweenListenCloseupAsync(scale, alpha, duration);
|
|
}
|
|
|
|
[YarnCommand("set_door_closeup")]
|
|
public static void SetDoorCloseup(float scale, float alpha)
|
|
{
|
|
ResolveSystem()?.SetListenCloseup(scale, alpha);
|
|
}
|
|
|
|
[YarnCommand("show_door_glass_sea_fullscreen")]
|
|
public static void ShowDoorGlassSeaFullscreen()
|
|
{
|
|
ResolveSystem()?.ShowGlassSeaFullscreen();
|
|
}
|
|
|
|
[YarnCommand("show_door_glass_sea_framed")]
|
|
public static void ShowDoorGlassSeaFramed()
|
|
{
|
|
ResolveSystem()?.ShowGlassSeaFramed();
|
|
}
|
|
|
|
[YarnCommand("show_door_code_sea")]
|
|
public static IEnumerator ShowDoorCodeSea(float duration = 2f)
|
|
{
|
|
var system = ResolveSystem();
|
|
if (system == null) yield break;
|
|
yield return system.ShowCodeSea(duration);
|
|
}
|
|
|
|
[YarnCommand("show_door_code_sea_fullscreen")]
|
|
public static void ShowDoorCodeSeaFullscreen()
|
|
{
|
|
ResolveSystem()?.ShowCodeSeaFullscreen();
|
|
}
|
|
|
|
[YarnCommand("show_door_code_sea_framed")]
|
|
public static void ShowDoorCodeSeaFramed()
|
|
{
|
|
ResolveSystem()?.ShowCodeSeaFramed();
|
|
}
|
|
|
|
[YarnCommand("show_dream_terminal")]
|
|
public static IEnumerator ShowDreamTerminal()
|
|
{
|
|
var system = ResolveSystem();
|
|
if (system == null) yield break;
|
|
yield return system.ShowTerminal();
|
|
}
|
|
|
|
[YarnCommand("hide_dream_door")]
|
|
public static void HideDreamDoor()
|
|
{
|
|
ResolveSystem()?.HideAll();
|
|
}
|
|
}
|
|
}
|