using System; using System.Collections; using UnityEngine; using Yarn.Unity; using AibisDream.FixSystem; namespace AibisDream.MiniGame.Tarot { public static class TarotYarnCommand { private static TarotManager GetManager() { return FixSystemCenter.SystemDic.Get(); } /// /// Show the tarot deck in stacked form(淡入出现;时长在 TarotDeck 的 fadeInDuration)。 /// Usage: <<show_tarot_deck>> or <<show_tarot_deck 5>> /// [YarnCommand("show_tarot_deck")] public static IEnumerator ShowTarotDeck(int count = 5) { var manager = GetManager(); if (manager == null) { Debug.LogWarning("[TarotYarnCommand] TarotManager not found"); yield break; } yield return manager.ShowDeck(count, 1); } /// /// Spread cards into a fan. Waits for the spread animation to finish. /// Usage: <<spread_tarot>> or <<spread_tarot 5>> /// [YarnCommand("spread_tarot")] public static IEnumerator SpreadTarot() { var manager = GetManager(); if (manager == null) { Debug.LogWarning("[TarotYarnCommand] TarotManager not found"); yield break; } yield return manager.SpreadCards(); } /// /// Block Yarn until the player selects a card(点击即解除等待;牌组 fade / 移至检视位在后台继续播放)。 /// Writes $tarotSelectedIndex after selection. /// Usage: <<wait_tarot_select>> /// [YarnCommand("wait_tarot_select")] public static IEnumerator WaitTarotSelect() { var manager = GetManager(); if (manager == null) { Debug.LogWarning("[TarotYarnCommand] TarotManager not found"); yield break; } yield return manager.WaitForSelection(); } /// /// Flip the selected card to reveal its front with a given orientation. /// Usage: <<flip_tarot "normal">> or <<flip_tarot "inverted">> /// [YarnCommand("flip_tarot")] public static IEnumerator FlipTarot(string orientation = "normal") { var manager = GetManager(); if (manager == null) { Debug.LogWarning("[TarotYarnCommand] TarotManager not found"); yield break; } var orient = ParseOrientation(orientation); yield return manager.FlipSelectedCard(orient); } /// /// Rotate the selected card to change its orientation (without flipping). /// Usage: <<rotate_tarot "normal">> or <<rotate_tarot "inverted">> /// [YarnCommand("rotate_tarot")] public static IEnumerator RotateTarot(string orientation) { var manager = GetManager(); if (manager == null) { Debug.LogWarning("[TarotYarnCommand] TarotManager not found"); yield break; } var orient = ParseOrientation(orientation); yield return manager.RotateSelectedCard(orient); } /// /// Fade out and hide all tarot elements. /// Usage: <<hide_tarot>> /// [YarnCommand("hide_tarot")] public static IEnumerator HideTarot() { var manager = GetManager(); if (manager == null) { Debug.LogWarning("[TarotYarnCommand] TarotManager not found"); yield break; } yield return manager.HideAll(); } private static TarotOrientation ParseOrientation(string value) { if (string.IsNullOrEmpty(value)) return TarotOrientation.Normal; if (value.Equals("inverted", StringComparison.OrdinalIgnoreCase)) return TarotOrientation.Inverted; return TarotOrientation.Normal; } } }