79 lines
2.4 KiB
C#
79 lines
2.4 KiB
C#
using System.Collections;
|
|
using UnityEngine;
|
|
using Yarn.Unity;
|
|
using AibisDream.FixSystem;
|
|
using AibisDream.Framework;
|
|
|
|
namespace AibisDream.MiniGame.Language
|
|
{
|
|
/// <summary>
|
|
/// 语言分析系统 Yarn 命令
|
|
/// </summary>
|
|
public static class LanguageAnalysisYarnCommands
|
|
{
|
|
private static FixStateMachine FixStateMachine => FixSystemCenter.SystemDic.Get<FixStateMachine>();
|
|
|
|
/// <summary>
|
|
/// 进入语言分析系统状态
|
|
/// <<enter_language_analysis>>
|
|
/// </summary>
|
|
[YarnCommand("enter_language_analysis")]
|
|
public static void EnterLanguageAnalysis()
|
|
{
|
|
if (FixStateMachine == null)
|
|
{
|
|
Debug.LogError("[LanguageAnalysis] FixStateMachine 未找到!");
|
|
return;
|
|
}
|
|
|
|
// 通过协程切换状态
|
|
MonoBehaviourHelper.Instance.StartCoroutine(SwitchToLanguageAnalysisState());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 退出语言分析系统状态
|
|
/// <<exit_language_analysis>>
|
|
/// </summary>
|
|
[YarnCommand("exit_language_analysis")]
|
|
public static void ExitLanguageAnalysis()
|
|
{
|
|
if (FixStateMachine == null)
|
|
{
|
|
Debug.LogError("[LanguageAnalysis] FixStateMachine 未找到!");
|
|
return;
|
|
}
|
|
|
|
// 切换回诊所状态或其他默认状态
|
|
MonoBehaviourHelper.Instance.StartCoroutine(FixStateMachine.SwitchState(FixState.Clinic));
|
|
}
|
|
|
|
private static IEnumerator SwitchToLanguageAnalysisState()
|
|
{
|
|
yield return FixStateMachine.SwitchState(FixState.LanguageAnalysis);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// MonoBehaviour 辅助类,用于启动协程
|
|
/// </summary>
|
|
public class MonoBehaviourHelper : MonoBehaviour
|
|
{
|
|
private static MonoBehaviourHelper _instance;
|
|
|
|
public static MonoBehaviourHelper Instance
|
|
{
|
|
get
|
|
{
|
|
if (_instance == null)
|
|
{
|
|
GameObject go = new GameObject("MonoBehaviourHelper");
|
|
_instance = go.AddComponent<MonoBehaviourHelper>();
|
|
DontDestroyOnLoad(go);
|
|
}
|
|
return _instance;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|