53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
using System.Drawing;
|
|
using UnityEngine;
|
|
using DG.Tweening;
|
|
|
|
public class MemoryClueSlot : ClueSlotBase
|
|
{
|
|
private MemoryProcess memoryManager;
|
|
[HideInInspector] public PunchTape punchTape;
|
|
|
|
|
|
protected override void Start()
|
|
{
|
|
base.Start(); // 初始化基类中的内容
|
|
memoryManager = FindObjectOfType<MemoryProcess>();
|
|
expectedClueType = ClueType.PunchTape;
|
|
}
|
|
|
|
// 重写基类的 OnClueInserted 方法,处理播放记忆的逻辑
|
|
protected override void OnClueInserted(Clue clue)
|
|
{
|
|
punchTape = clue as PunchTape;
|
|
coverClose.enabled = true;
|
|
coverOpen.enabled = false;
|
|
PlayMemory(punchTape);
|
|
FavoritesManager.Instance.RemoveClue(clue);
|
|
}
|
|
|
|
private void PlayMemory(PunchTape punchTape)
|
|
{
|
|
if (punchTape != null)
|
|
{
|
|
string memoryIndex = punchTape.MemoryIndex;
|
|
Debug.Log("播放记忆:" + memoryIndex);
|
|
StartCoroutine(memoryManager.SearchMemory(punchTape));
|
|
}
|
|
}
|
|
|
|
private void StartFilmAnimation()
|
|
{
|
|
// 使用 DOTween 实现胶片的循环移动
|
|
filmImage.rectTransform.DOLocalMoveX(-1256f, 1f)
|
|
.SetLoops(-1, LoopType.Restart)
|
|
.SetEase(Ease.Linear);
|
|
}
|
|
|
|
private void StopFilmAnimation()
|
|
{
|
|
// 停止胶片动画
|
|
filmImage.rectTransform.DOKill();
|
|
// 重置胶片位置
|
|
filmImage.rectTransform.localPosition = Vector3.zero;
|
|
}
|
|
} |