60 lines
2.4 KiB
C#
60 lines
2.4 KiB
C#
using System.Collections;
|
|
using DG.Tweening;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using AibisDream.Kit;
|
|
|
|
namespace AibisDream.FixSystem
|
|
{
|
|
/// <summary>
|
|
/// 躯体维修界面中的「打孔纸带打印机」纯 UI 动画(与叙事侧 <see cref="PunchTapeManager"/> 无关)。
|
|
/// 注册到 <see cref="FixSystemCenter.SystemDic"/>,由 Yarn <<PrintPunchTapes>> 经 <see cref="AibisDream.BodyModuleYarnCommand"/> 驱动。
|
|
/// </summary>
|
|
public class PunchTapePrinter : MonoBehaviour
|
|
{
|
|
public RectTransform punchTapeMachine;
|
|
public RectTransform punchTape;
|
|
public GameObject blackPanel;
|
|
|
|
/// <summary>打印机位移动画序列,可重复调用次数由 <paramref name="tapeCount"/> 决定。</summary>
|
|
public IEnumerator RunPrintAnimation(int tapeCount)
|
|
{
|
|
blackPanel.SetActive(true);
|
|
Vector3 tapeStartPos = punchTape.anchoredPosition;
|
|
Color tapeStartColor = punchTape.GetComponent<Image>().color;
|
|
|
|
while (tapeCount > 0)
|
|
{
|
|
// 0-0.7秒:打印机移动到指定位置
|
|
AudioManager.Instance.PlaySfx("event:/Scriptal/typing");
|
|
yield return punchTapeMachine.DOAnchorPos(new Vector2(-1252f, punchTapeMachine.anchoredPosition.y), 0.7f)
|
|
.WaitForCompletion();
|
|
|
|
// 0.7-1秒:停顿
|
|
yield return new WaitForSeconds(0.3f);
|
|
|
|
// 1-1.6秒:纸带匀速弹出
|
|
Vector2 targetPosition = new Vector2(796f, punchTape.anchoredPosition.y);
|
|
yield return punchTape.DOAnchorPos(targetPosition, 0.6f).WaitForCompletion();
|
|
|
|
// 1.6-2.3秒:停顿
|
|
yield return new WaitForSeconds(0.7f);
|
|
|
|
// 2.3-2.7秒:纸带淡出
|
|
yield return punchTape.GetComponent<Image>().DOFade(0f, 0.4f).WaitForCompletion();
|
|
|
|
// 重置纸带位置和透明度
|
|
punchTape.anchoredPosition = tapeStartPos;
|
|
punchTape.GetComponent<Image>().color = tapeStartColor;
|
|
|
|
tapeCount--;
|
|
}
|
|
|
|
// 打印机返回原位
|
|
yield return punchTapeMachine.DOAnchorPos(new Vector2(-1428.186f, punchTapeMachine.anchoredPosition.y), 1f)
|
|
.WaitForCompletion();
|
|
blackPanel.SetActive(false);
|
|
}
|
|
}
|
|
}
|