104 lines
3.0 KiB
C#
104 lines
3.0 KiB
C#
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using Yarn.Unity;
|
|
using AibisDream;
|
|
|
|
public class ClueSlot : MonoBehaviour, IDropHandler
|
|
{
|
|
public ClueType expectedClueType;
|
|
|
|
private MemoryProcess memoryManager;
|
|
|
|
private PunchTape punchTape;
|
|
|
|
private ClueInteraction interaction;
|
|
|
|
[HideInInspector]
|
|
public bool isOccupied=false;
|
|
//public string memoryIndex; // 存储的memory string
|
|
|
|
|
|
void Start()
|
|
{
|
|
memoryManager=FindObjectOfType<MemoryProcess>();
|
|
interaction=null;
|
|
punchTape=null;
|
|
|
|
}
|
|
|
|
public void OnDrop(PointerEventData eventData)
|
|
{
|
|
if(isOccupied)
|
|
{
|
|
Debug.Log("is using");
|
|
return;
|
|
}
|
|
isOccupied=true;
|
|
ClueItem clueItem = eventData.pointerDrag.GetComponent<ClueItem>();
|
|
if (clueItem != null)
|
|
{
|
|
Clue clue = clueItem.GetClueData();
|
|
interaction=clueItem.GetComponent<ClueInteraction>();
|
|
Debug.Log(clue.ClueType+" "+expectedClueType);
|
|
if (clue!=null && clue.ClueType == expectedClueType&&interaction!=null)
|
|
{
|
|
FavoritesManager.Instance.RemoveClue(clue);
|
|
Debug.Log("success");
|
|
// 插入成功
|
|
// 将线索项放置到插槽中
|
|
|
|
interaction.SetClueParentAndPosition(transform);
|
|
|
|
|
|
//clueItem.transform.SetParent(transform);
|
|
//clueItem.transform.position = transform.position;
|
|
|
|
if (clue is PunchTape)
|
|
{
|
|
punchTape= clue as PunchTape;
|
|
PlayMemory(punchTape);
|
|
}
|
|
// 播放记忆
|
|
|
|
|
|
// 从收藏夹移除线索
|
|
//FavoritesManager.Instance.RemoveClue(clue);
|
|
|
|
// 销毁线索项
|
|
//Destroy(clueItem.gameObject, 1f); // 延迟销毁,方便展示动画
|
|
}
|
|
else
|
|
{
|
|
interaction.ReturnToOriginalPosition();
|
|
// 类型不匹配,返回原位
|
|
// clueItem.transform.SetParent(clueItem.OriginalParent);
|
|
// clueItem.transform.position = clueItem.OriginalParent.position;
|
|
}
|
|
}
|
|
}
|
|
private void PlayMemory(Clue clue)
|
|
{
|
|
// 根据线索的记忆索引播放对应的记忆
|
|
if (clue is PunchTape)
|
|
{
|
|
PunchTape punchTape = clue as PunchTape;
|
|
string memoryIndex = punchTape.MemoryIndex;
|
|
// 播放对应的记忆内容
|
|
Debug.Log("播放记忆:" + memoryIndex);
|
|
StartCoroutine(memoryManager.SearchMemory(punchTape));
|
|
//DialogController.Instance.StartDialogNode(memoryIndex);
|
|
// 您可以在这里实现播放记忆的具体逻辑
|
|
}
|
|
}
|
|
|
|
// [YarnCommand("Release_Slot")]
|
|
public void ReleaseSlot()
|
|
{
|
|
isOccupied=false;
|
|
interaction.ReturnToOriginalPosition();
|
|
interaction=null;
|
|
punchTape=null;
|
|
}
|
|
}
|