64 lines
2.0 KiB
C#
64 lines
2.0 KiB
C#
using System.Collections;
|
|
using DG.Tweening;
|
|
using UnityEngine;
|
|
using AibisDream.FixSystem;
|
|
using UnityEngine.UI;
|
|
using AibisDream.Kit;
|
|
|
|
public class PunchTapeSystem : MonoBehaviour
|
|
{
|
|
public RectTransform punchTapeMachine;
|
|
public RectTransform punchTape;
|
|
|
|
public GameObject blackPanel;
|
|
|
|
private void Awake()
|
|
{
|
|
FixSystemCenter.SystemDic.Register(this);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
FixSystemCenter.SystemDic.Unregister<PunchTapeSystem>();
|
|
}
|
|
|
|
public IEnumerator PrintPunchTapes(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);
|
|
}
|
|
} |