增加了messagebox显示的命令和功能,另外为对话暂停做了一些事件准备
This commit is contained in:
@@ -4,6 +4,7 @@ using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using System.Linq;
|
||||
using DG.Tweening;
|
||||
using AibisDream;
|
||||
|
||||
public class Plug : MonoBehaviour, IDragHandler, IPointerDownHandler, IPointerUpHandler
|
||||
{
|
||||
@@ -16,6 +17,7 @@ public class Plug : MonoBehaviour, IDragHandler, IPointerDownHandler, IPointerUp
|
||||
private Quaternion pickupRotationOffset = Quaternion.Euler(0, 0, 30);
|
||||
public Socket initialSocket; // new variable
|
||||
public Image plugSprite; // new variable
|
||||
public bool IsInDialogue { get; set; } = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -27,16 +29,38 @@ public class Plug : MonoBehaviour, IDragHandler, IPointerDownHandler, IPointerUp
|
||||
startPosition = initialSocket.GetPosition();
|
||||
|
||||
transform.position = startPosition;
|
||||
//startRotation = initialSocket.GetRotation();
|
||||
|
||||
// Insert the plug into the initial socket and make the sprite disappear.
|
||||
initialSocket.InsertPlug(this);
|
||||
plugSprite.enabled = false;
|
||||
DialogController.OnDialogueStart += HandleDialogueStart;
|
||||
DialogController.OnDialogueComplete += HandleDialogueComplete;
|
||||
}
|
||||
void OnDestroy()
|
||||
{
|
||||
// Unsubscribe from dialogue events
|
||||
DialogController.OnDialogueStart -= HandleDialogueStart;
|
||||
DialogController.OnDialogueComplete -= HandleDialogueComplete;
|
||||
}
|
||||
void HandleDialogueStart()
|
||||
{
|
||||
// Dialogue has started, disable plug interactions
|
||||
IsInDialogue = true;
|
||||
Debug.Log("in dialogue");
|
||||
}
|
||||
|
||||
void HandleDialogueComplete()
|
||||
{
|
||||
// Dialogue has completed, enable plug interactions
|
||||
IsInDialogue = false;
|
||||
Debug.Log("dialoguecompleted");
|
||||
}
|
||||
|
||||
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
if (IsInDialogue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
isDragging = true;
|
||||
image.raycastTarget = false;
|
||||
currentSocket?.RemovePlug(this);
|
||||
@@ -49,6 +73,10 @@ public class Plug : MonoBehaviour, IDragHandler, IPointerDownHandler, IPointerUp
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
if (IsInDialogue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (isDragging)
|
||||
{
|
||||
Vector3 screenPosition = new Vector3(eventData.position.x, eventData.position.y,
|
||||
@@ -61,6 +89,10 @@ public class Plug : MonoBehaviour, IDragHandler, IPointerDownHandler, IPointerUp
|
||||
|
||||
public void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
if (IsInDialogue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
isDragging = false;
|
||||
image.raycastTarget = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user