133 lines
4.3 KiB
C#
133 lines
4.3 KiB
C#
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<TarotManager>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Show the tarot deck in stacked form(淡入出现;时长在 TarotDeck 的 fadeInDuration)。
|
|
/// Usage: <<show_tarot_deck>> or <<show_tarot_deck 5>>
|
|
/// </summary>
|
|
[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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Spread cards into a fan. Waits for the spread animation to finish.
|
|
/// Usage: <<spread_tarot>> or <<spread_tarot 5>>
|
|
/// </summary>
|
|
[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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Block Yarn until the player selects a card(点击即解除等待;牌组 fade / 移至检视位在后台继续播放)。
|
|
/// Writes $tarotSelectedIndex after selection.
|
|
/// Usage: <<wait_tarot_select>>
|
|
/// </summary>
|
|
[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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Flip the selected card to reveal its front with a given orientation.
|
|
/// Usage: <<flip_tarot "normal">> or <<flip_tarot "inverted">>
|
|
/// </summary>
|
|
[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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Rotate the selected card to change its orientation (without flipping).
|
|
/// Usage: <<rotate_tarot "normal">> or <<rotate_tarot "inverted">>
|
|
/// </summary>
|
|
[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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Fade out and hide all tarot elements.
|
|
/// Usage: <<hide_tarot>>
|
|
/// </summary>
|
|
[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;
|
|
}
|
|
}
|
|
}
|