132 lines
4.5 KiB
C#
132 lines
4.5 KiB
C#
using System.Collections;
|
|
using UnityEngine;
|
|
using Yarn.Unity;
|
|
|
|
namespace AibisDream
|
|
{
|
|
public static class Day2SleepYarnCommand
|
|
{
|
|
private static Day2SleepPresentationController Resolve()
|
|
{
|
|
if (Day2SleepPresentationController.Instance != null)
|
|
return Day2SleepPresentationController.Instance;
|
|
var controller = Object.FindObjectOfType<Day2SleepPresentationController>(true);
|
|
if (controller == null)
|
|
Debug.LogError("[Day2SleepYarnCommand] 当前场景缺少 Day2SleepPresentationController。");
|
|
return controller;
|
|
}
|
|
|
|
[YarnCommand("show_sprite_motion")]
|
|
public static IEnumerator ShowSpriteMotion(
|
|
string picName,
|
|
string motionProfile,
|
|
float duration = 0.35f)
|
|
{
|
|
var controller = Resolve();
|
|
if (controller == null) yield break;
|
|
yield return controller.ShowSpriteMotion(picName, motionProfile, duration);
|
|
}
|
|
|
|
[YarnCommand("sprite_motion")]
|
|
public static IEnumerator SpriteMotion(string motionProfile, float leadDuration = 0.18f)
|
|
{
|
|
var controller = Resolve();
|
|
if (controller == null) yield break;
|
|
controller.PlayCurrentMotion(motionProfile);
|
|
if (leadDuration > 0f)
|
|
yield return new WaitForSeconds(leadDuration);
|
|
}
|
|
|
|
[YarnCommand("kite_show")]
|
|
public static IEnumerator KiteShow(float height = 0f, int wind = 0, float duration = 0.35f)
|
|
{
|
|
var controller = Resolve();
|
|
if (controller == null) yield break;
|
|
yield return controller.ShowKite(height, wind, duration);
|
|
}
|
|
|
|
[YarnCommand("kite_state")]
|
|
public static IEnumerator KiteState(
|
|
float height,
|
|
int wind,
|
|
float duration = 0.9f,
|
|
float leadDuration = 0.35f)
|
|
{
|
|
var controller = Resolve();
|
|
if (controller == null) yield break;
|
|
controller.SetKiteState(height, wind, duration);
|
|
if (leadDuration > 0f)
|
|
yield return new WaitForSeconds(Mathf.Min(leadDuration, duration));
|
|
}
|
|
|
|
[YarnCommand("kite_wind")]
|
|
public static void KiteWind(int wind, float turbulence = -1f)
|
|
{
|
|
Resolve()?.SetKiteWind(wind, turbulence);
|
|
}
|
|
|
|
[YarnCommand("kite_accent")]
|
|
public static IEnumerator KiteAccent(string profile, float leadDuration = 0.18f)
|
|
{
|
|
var controller = Resolve();
|
|
if (controller == null) yield break;
|
|
controller.PlayKiteAccent(profile);
|
|
if (leadDuration > 0f)
|
|
yield return new WaitForSeconds(leadDuration);
|
|
}
|
|
|
|
[YarnCommand("kite_hide")]
|
|
public static IEnumerator KiteHide(float duration = 1f)
|
|
{
|
|
var controller = Resolve();
|
|
if (controller == null) yield break;
|
|
yield return controller.HideKite(duration);
|
|
}
|
|
|
|
[YarnCommand("show_large_sprite_animation")]
|
|
public static IEnumerator ShowLargeSpriteAnimation(
|
|
string picNamePrefix,
|
|
int frameCount,
|
|
float secondsPerFrame = 0.2f,
|
|
float duration = 1f)
|
|
{
|
|
var controller = Resolve();
|
|
if (controller == null) yield break;
|
|
yield return controller.ShowLargeSpriteAnimation(
|
|
picNamePrefix,
|
|
frameCount,
|
|
secondsPerFrame,
|
|
duration);
|
|
}
|
|
|
|
[YarnCommand("set_large_sprite_blur")]
|
|
public static void SetLargeSpriteBlur(float amount, float blurSize = 0.012f)
|
|
{
|
|
Resolve()?.SetLargeSpriteBlur(amount, blurSize);
|
|
}
|
|
|
|
[YarnCommand("tween_large_sprite_blur")]
|
|
public static IEnumerator TweenLargeSpriteBlur(
|
|
float targetAmount,
|
|
float duration,
|
|
float blurSize = 0.012f)
|
|
{
|
|
var controller = Resolve();
|
|
if (controller == null) yield break;
|
|
yield return controller.TweenLargeSpriteBlur(targetAmount, duration, blurSize);
|
|
}
|
|
|
|
[YarnCommand("tween_large_sprite_blur_async")]
|
|
public static void TweenLargeSpriteBlurAsync(
|
|
float targetAmount,
|
|
float duration,
|
|
float blurSize = 0.012f)
|
|
{
|
|
var controller = Resolve();
|
|
if (controller == null) return;
|
|
controller.StartCoroutine(
|
|
controller.TweenLargeSpriteBlur(targetAmount, duration, blurSize));
|
|
}
|
|
}
|
|
}
|