Files
aibis-dream/Assets/Scripts/MiniGame/HuoShan/EmotionWave/EmotionWaveYarnCommand.cs
T
2026-02-25 16:19:28 +08:00

160 lines
4.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections;
using AibisDream.FixSystem;
using UnityEngine;
using Yarn.Unity;
namespace AibisDream.MiniGame.HuoShan.EmotionWave
{
/// <summary>
/// 情绪波形系统的 Yarn 命令接口
///
/// 功能:
/// - 显示/隐藏:show_emotion_wave, hide_emotion_wave
/// - 进度控制:emotion_wave_to(动画到指定进度),set_emotion_wave(立即设置)
/// - 状态查询:is_emotion_wave_shown()
/// </summary>
public static class EmotionWaveYarnCommand
{
private static EmotionWaveManager GetManager()
{
return FixSystemCenter.SystemDic.Get<EmotionWaveManager>();
}
#region 显示/隐藏
/// <summary>
/// 显示情绪波形
/// 用法: <<show_emotion_wave>>
/// <<show_emotion_wave 0.8>>
/// </summary>
[YarnCommand("show_emotion_wave")]
public static IEnumerator ShowEmotionWave(float duration = -1f)
{
var manager = GetManager();
if (manager != null)
{
yield return manager.Show(duration);
}
}
/// <summary>
/// 隐藏情绪波形
/// 用法: <<hide_emotion_wave>>
/// <<hide_emotion_wave 0.5>>
/// </summary>
[YarnCommand("hide_emotion_wave")]
public static IEnumerator HideEmotionWave(float duration = -1f)
{
var manager = GetManager();
if (manager != null)
{
yield return manager.Hide(duration);
}
}
#endregion
#region 进度控制
/// <summary>
/// 动画到指定进度(以指定时间动画到指定进度值,完成后返回给 Yarn)
/// 用法: <<emotion_wave_to 0.5 2>> -- 2秒内动画到进度0.5
/// <<emotion_wave_to 1.0>> -- 默认1秒内动画到进度1.0
/// </summary>
[YarnCommand("emotion_wave_to")]
public static IEnumerator EmotionWaveTo(float progress, float duration = 1f)
{
var manager = GetManager();
if (manager != null)
{
yield return manager.AnimateToProgress(progress, duration);
}
}
/// <summary>
/// 立即设置进度(不等待)
/// 用法: <<set_emotion_wave 0.5>>
/// </summary>
[YarnCommand("set_emotion_wave")]
public static void SetEmotionWave(float progress)
{
var manager = GetManager();
if (manager != null)
{
manager.SetProgress(progress);
}
}
#endregion
#region 状态查询
/// <summary>
/// 检查情绪波形是否已显示
/// 用法: <<if is_emotion_wave_shown()>>
/// </summary>
[YarnFunction("is_emotion_wave_shown")]
public static bool IsEmotionWaveShown()
{
var manager = GetManager();
return manager != null && manager.IsShown;
}
/// <summary>
/// 获取当前进度
/// 用法: <<set $progress to get_emotion_wave_progress()>>
/// </summary>
[YarnFunction("get_emotion_wave_progress")]
public static float GetEmotionWaveProgress()
{
var manager = GetManager();
return manager != null ? manager.CurrentProgress : 0f;
}
/// <summary>
/// 获取目标进度
/// 用法: <<set $target to get_emotion_wave_target()>>
/// </summary>
[YarnFunction("get_emotion_wave_target")]
public static float GetEmotionWaveTarget()
{
var manager = GetManager();
return manager != null ? manager.TargetProgress : 0f;
}
#endregion
#region Slider 同步控制
/// <summary>
/// 启用滑片同步(情绪波形进度跟随 SliderController
/// 用法: <<enable_emotion_wave_slider_sync>>
/// </summary>
[YarnCommand("enable_emotion_wave_slider_sync")]
public static void EnableSliderSync()
{
var manager = GetManager();
if (manager != null)
{
manager.SetSliderSyncEnabled(true);
}
}
/// <summary>
/// 禁用滑片同步(情绪波形进度由 Yarn 命令控制)
/// 用法: <<disable_emotion_wave_slider_sync>>
/// </summary>
[YarnCommand("disable_emotion_wave_slider_sync")]
public static void DisableSliderSync()
{
var manager = GetManager();
if (manager != null)
{
manager.SetSliderSyncEnabled(false);
}
}
#endregion
}
}