diff --git a/Assets/Scenes/ExpressFixScene.unity b/Assets/Scenes/ExpressFixScene.unity index a46b7f2e5..fe43e433f 100644 --- a/Assets/Scenes/ExpressFixScene.unity +++ b/Assets/Scenes/ExpressFixScene.unity @@ -520,6 +520,26 @@ PrefabInstance: propertyPath: m_Name value: Body Module System objectReference: {fileID: 0} + - target: {fileID: 7908307127668400731, guid: 92aec29b557d59a4ca5363aadd06c7bb, type: 3} + propertyPath: m_Delegates.Array.size + value: 5 + objectReference: {fileID: 0} + - target: {fileID: 7908307127668400731, guid: 92aec29b557d59a4ca5363aadd06c7bb, type: 3} + propertyPath: m_Delegates.Array.data[0].eventID + value: 5 + objectReference: {fileID: 0} + - target: {fileID: 7908307127668400731, guid: 92aec29b557d59a4ca5363aadd06c7bb, type: 3} + propertyPath: m_Delegates.Array.data[2].eventID + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7908307127668400731, guid: 92aec29b557d59a4ca5363aadd06c7bb, type: 3} + propertyPath: m_Delegates.Array.data[3].eventID + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 7908307127668400731, guid: 92aec29b557d59a4ca5363aadd06c7bb, type: 3} + propertyPath: m_Delegates.Array.data[4].eventID + value: 3 + objectReference: {fileID: 0} - target: {fileID: 8209014069305634267, guid: 92aec29b557d59a4ca5363aadd06c7bb, type: 3} propertyPath: m_Materials.Array.data[0] value: @@ -882,6 +902,8 @@ MonoBehaviour: y: -0.011 z: 0 cantStopRunning: 0 + showPicPath: + checkPoints: [] --- !u!1 &244839600 GameObject: m_ObjectHideFlags: 0 @@ -1318,6 +1340,8 @@ MonoBehaviour: y: -0.011 z: 0 cantStopRunning: 0 + showPicPath: + checkPoints: [] --- !u!1 &396819324 GameObject: m_ObjectHideFlags: 0 @@ -1377,6 +1401,8 @@ MonoBehaviour: y: -0.011 z: 0 cantStopRunning: 0 + showPicPath: + checkPoints: [] --- !u!1 &448946530 GameObject: m_ObjectHideFlags: 0 @@ -2941,6 +2967,8 @@ MonoBehaviour: y: -0.011 z: 0 cantStopRunning: 0 + showPicPath: + checkPoints: [] --- !u!1 &750333137 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/Persistence.unity b/Assets/Scenes/Persistence.unity index 1f24e65ca..5b1303713 100644 --- a/Assets/Scenes/Persistence.unity +++ b/Assets/Scenes/Persistence.unity @@ -1084,7 +1084,6 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1584263514} - - {fileID: 494300779} - {fileID: 1936621685} m_Father: {fileID: 1009826577} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -5535,50 +5534,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 492978121} m_CullTransparentMesh: 1 ---- !u!1 &494300778 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 494300779} - - component: {fileID: 494300780} - m_Layer: 0 - m_Name: Command Option View - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &494300779 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 494300778} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 72512886} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &494300780 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 494300778} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4e61040b961ba1446ad453ee17f4a737, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!1001 &500438199 PrefabInstance: m_ObjectHideFlags: 0 @@ -8107,7 +8062,7 @@ MonoBehaviour: runMode: 2 firstTalkSo: {fileID: 11400000, guid: 6d49b124127007b48b6881ce33350263, type: 2} testTalkSo: {fileID: 11400000, guid: ff82a99e791be3e41acf40232f908eb3, type: 2} - saveFileName: "PeipeiDay2_\u7B2C\u4E00\u6B21\u53D1\u70ED" + saveFileName: StoneDay1_2 --- !u!4 &719228339 Transform: m_ObjectHideFlags: 0 @@ -8117,7 +8072,7 @@ Transform: m_GameObject: {fileID: 719228336} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 11.807568} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -11176,73 +11131,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1090155682} m_CullTransparentMesh: 1 ---- !u!1 &1095691305 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1095691306} - - component: {fileID: 1095691307} - - component: {fileID: 1095691308} - m_Layer: 0 - m_Name: Advance Input - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1095691306 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1095691305} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 1936621685} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1095691307 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1095691305} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 097b95c9f69f04f2d8c08a817e7786af, type: 3} - m_Name: - m_EditorClassIdentifier: - dialogueView: {fileID: 1584263515} - continueActionType: 1 - continueActionKeyCode: 32 - continueActionButtonName: Jump - continueActionOnButtonRelease: 0 ---- !u!114 &1095691308 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1095691305} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 097b95c9f69f04f2d8c08a817e7786af, type: 3} - m_Name: - m_EditorClassIdentifier: - dialogueView: {fileID: 1584263515} - continueActionType: 1 - continueActionKeyCode: 323 - continueActionButtonName: Jump - continueActionOnButtonRelease: 0 --- !u!1 &1108164745 GameObject: m_ObjectHideFlags: 0 @@ -15860,10 +15748,10 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1794129319} - - {fileID: 1108164746} - {fileID: 1990871919} - {fileID: 1302630844} - {fileID: 50234111} + - {fileID: 1108164746} m_Father: {fileID: 1343879457} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -18400,7 +18288,6 @@ Transform: m_Children: - {fileID: 331068879} - {fileID: 667130562} - - {fileID: 1095691306} m_Father: {fileID: 72512886} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1936621686 diff --git a/Assets/Scripts/Dialog System/CommandOptionView.cs b/Assets/Scripts/Dialog System/CommandOptionView.cs deleted file mode 100644 index aba19bdd5..000000000 --- a/Assets/Scripts/Dialog System/CommandOptionView.cs +++ /dev/null @@ -1,83 +0,0 @@ - using System; -using AibisDream.Utility; -using Yarn.Unity; - -namespace AibisDream -{ - public class CommandOptionView : DialogueViewBase - { - // 进入指令选项模式 - private bool _waitCommandOptions; - private string _commandName; - - public override void RunLine(LocalizedLine dialogueLine, Action onDialogueLineFinished) - { - ProcessCommandLine(dialogueLine, onDialogueLineFinished); - } - - public override void RunOptions(DialogueOption[] dialogueOptions, Action onOptionSelected) - { - // 非指令直接跳过 - if (!_waitCommandOptions) - { - base.RunOptions(dialogueOptions, onOptionSelected); - return; - } - - DialogController.Instance.IsTalking = false; - // 传输选项 - YarnOption[] options = YarnOption.GeneOptions(dialogueOptions, onOptionSelected); - DialogController.Instance.InvokeOptionCommand(_commandName, options); - } - - public override void InterruptLine(LocalizedLine dialogueLine, Action onDialogueLineFinished) - { - base.InterruptLine(dialogueLine, onDialogueLineFinished); - } - - public override void DismissLine(Action onDismissalComplete) - { - base.DismissLine(onDismissalComplete); - } - - public override void UserRequestedViewAdvancement() - { - base.UserRequestedViewAdvancement(); - } - - private void ProcessCommandLine(LocalizedLine dialogueLine, Action onDialogueLineFinished) - { - // 判断当前行是否是Command行,否则直接跳过 - CommandLineType commandLineType = dialogueLine.Text.MatchCommandType(); - - // 分情况处理 - switch (commandLineType) - { - case CommandLineType.Pause: - // 获取选项名称 - dialogueLine.Text.TryGetPauseCommandAttr(out var pauseCommandName); - // 传递暂停指令 - var step = YarnContinueStep.GeneContinueStep(onDialogueLineFinished); - DialogController.Instance.InvokePauseCommand(pauseCommandName, step); - break; - case CommandLineType.OptionCommand: - // 选项指令 - _waitCommandOptions = true; - - dialogueLine.Text.TryGetOptionCommandAttr(out var curCommandName); - // 保存指令 - _commandName = curCommandName; - // 进入下一步 - onDialogueLineFinished.Invoke(); - break; - case CommandLineType.NonCommand: - default: - // 非Command直接跳过 - _waitCommandOptions = false; - base.RunLine(dialogueLine, onDialogueLineFinished); - break; - } - } - } -} - diff --git a/Assets/Scripts/Dialog System/CommandOptionView.cs.meta b/Assets/Scripts/Dialog System/CommandOptionView.cs.meta deleted file mode 100644 index 1532c96a6..000000000 --- a/Assets/Scripts/Dialog System/CommandOptionView.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4e61040b961ba1446ad453ee17f4a737 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Dialog System/DialogController.cs b/Assets/Scripts/Dialog System/DialogController.cs index 51e73a49a..9d398db03 100644 --- a/Assets/Scripts/Dialog System/DialogController.cs +++ b/Assets/Scripts/Dialog System/DialogController.cs @@ -1,6 +1,5 @@ using System; using System.Collections; -using System.Collections.Generic; using AibisDream.Framework; using AibisDream.Kit; using UnityEngine; @@ -14,9 +13,6 @@ namespace AibisDream private DialogueRunner _dialogueRunner; private VariableStorageBehaviour _variableStorage; - private readonly Dictionary> _commandMap = new(); - private readonly Dictionary> _pauseCommandMap = new(); - # region controller状态标识 private bool _isTalking; @@ -41,9 +37,6 @@ namespace AibisDream get => _isTalking; } - // 对话框被阻塞时不能继续对话框交互 - public bool IsBlock { get; private set; } - public bool quickRunMode; # endregion @@ -58,11 +51,13 @@ namespace AibisDream _dialogueRunner.onDialogueStart.AddListener(() => { + EnumEventSystem.Global.Send(InteractionEventEnum.End); OnDialogueStart?.Invoke(); IsTalking = true; }); _dialogueRunner.onDialogueComplete.AddListener(() => { + EnumEventSystem.Global.Send(InteractionEventEnum.Start); OnDialogueComplete?.Invoke(); IsTalking = false; }); @@ -141,123 +136,6 @@ namespace AibisDream } } - #region 选项指令 - - /// - /// 调用命令 - /// - /// 命令名 - /// 选项 - public void InvokeOptionCommand(string commandName, YarnOption[] options) - { - if (commandName == null) - { - Debug.Log("命令名为空"); - return; - } - - if (_commandMap.TryGetValue(commandName, out var action)) - { - action(options); - } - else - { - Debug.LogWarning($"命令 {commandName} 不存在"); - } - } - - /// - /// 注册命令 - /// - /// 命令名称 - /// 注册名称 - public void RegisterOptionCommand(string commandName, Action commandAction) - { - if (_commandMap.ContainsKey(commandName)) - { - Debug.Log($"命令 {commandName} 已经存在,将被替换"); - } - - _commandMap[commandName] = commandAction; - } - - /// - /// 移除命令 - /// - /// 命令名称 - public void RemoveOptionCommand(string commandName) - { - if (_commandMap.ContainsKey(commandName)) - { - _commandMap.Remove(commandName); - } - else - { - Debug.Log($"命令 {commandName} 不存在"); - } - } - - #endregion - - #region 暂停选项指令 - - /// - /// 执行暂停命令 - /// - /// 命令名 - /// 参数 - public void InvokePauseCommand(string commandName, YarnContinueStep pauseCommand) - { - if (string.IsNullOrEmpty(commandName)) - { - Debug.Log("命令名为空"); - return; - } - - if (_pauseCommandMap.TryGetValue(commandName, out var action)) - { - action(pauseCommand); - } - else - { - Debug.LogWarning($"命令 {commandName} 不存在"); - } - } - - /// - /// 注册暂停命令 - /// - /// 命令名 - /// 注册命令函数 - public void RegisterPauseCommand(string commandName, Action commandAction) - { - if (_pauseCommandMap.ContainsKey(commandName)) - { - Debug.Log($"命令 {commandName} 已经存在,将被替换"); - } - - _pauseCommandMap[commandName] = commandAction; - } - - /// - /// 移除命令 - /// - /// 命令名称 - public void RemovePauseCommand(string commandName) - { - if (_pauseCommandMap.ContainsKey(commandName)) - { - _pauseCommandMap.Remove(commandName); - } - else - { - Debug.Log($"命令 {commandName} 不存在"); - } - } - - #endregion - - #region 命令名 [YarnCommand("NextYarn")] @@ -284,8 +162,6 @@ namespace AibisDream public static IEnumerator LoadScene(string sceneName, float duration = 1) { HideDialog(); - Camera.main.orthographicSize = 5; - Camera.main.transform.position = new Vector3(0, 0, -10); yield return SceneLoader.Instance.LoadSceneAsync(sceneName); DialogCanvasManager.Instance.SwitchDialogView(sceneName == "ClinicScene" ? DialogViewType.Bubble diff --git a/Assets/Scripts/Dialog System/LineView.cs b/Assets/Scripts/Dialog System/LineView.cs index c70f1e206..559ccd58c 100644 --- a/Assets/Scripts/Dialog System/LineView.cs +++ b/Assets/Scripts/Dialog System/LineView.cs @@ -68,26 +68,7 @@ namespace AibisDream var options = DialogOption.GeneOptions(dialogueOptions, onOptionSelected); DialogCanvasManager.GetCurView().ShowOptions(options); } - - public override void UserRequestedViewAdvancement() - { - if (_isInCommand) - { - return; - } - - if (DialogController.Instance.IsBlock) - { - return; - } - - if (!DialogCanvasManager.GetCurView().TrySkipLine()) - { - AudioManager.Instance.StopVoice(); - requestInterrupt?.Invoke(); - } - } - + private void Update() { if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Space)) @@ -106,11 +87,6 @@ namespace AibisDream return; } - if (DialogController.Instance.IsBlock) - { - return; - } - if (!DialogCanvasManager.GetCurView().TrySkipLine()) { AudioManager.Instance.StopVoice(); diff --git a/Assets/Scripts/FixSystemNew/BodyModule/Plug.cs b/Assets/Scripts/FixSystemNew/BodyModule/Plug.cs index ca99b9c1b..a270b1c88 100644 --- a/Assets/Scripts/FixSystemNew/BodyModule/Plug.cs +++ b/Assets/Scripts/FixSystemNew/BodyModule/Plug.cs @@ -6,7 +6,8 @@ using UnityEngine.EventSystems; namespace AibisDream.FixSystem { - public class Plug : MonoBehaviour, IDragHandler, IPointerDownHandler, IPointerUpHandler + [RequireComponent(typeof(EventTriggerEx))] + public class Plug : MonoBehaviour { #region 插头当前信息 @@ -22,6 +23,7 @@ namespace AibisDream.FixSystem private CableSystem _cableSystem; private SpriteRenderer _sprite; private Transform _plugRootPos; + private EventTriggerEx _trigger; #endregion @@ -30,6 +32,7 @@ namespace AibisDream.FixSystem private void Awake() { InitComponentRef(); + EventRegister(); } private void InitComponentRef() @@ -37,6 +40,14 @@ namespace AibisDream.FixSystem _cableSystem = transform.parent.GetComponent(); _sprite = GetComponent(); _plugRootPos = transform.Find("Plug Root Pos"); + _trigger = GetComponent(); + } + + private void EventRegister() + { + _trigger.Register(EventTriggerType.Drag, OnDrag); + _trigger.Register(EventTriggerType.PointerDown, OnPointerDown); + _trigger.Register(EventTriggerType.PointerUp, OnPointerUp); } public void InitPlug(ISocket initSocket) @@ -90,18 +101,21 @@ namespace AibisDream.FixSystem _cableSystem.curSocket = null; } - public void OnDrag(PointerEventData eventData) + private void OnDrag(BaseEventData eventData) { // 系统被锁定就返回 if (!_cableSystem.IsPlugAvailable()) return; - + // 未被拖拽也返回 if (!_isDragging) return; - - transform.position = CommonUtil.GetMouseWorldPos(eventData.position, transform); + + if (eventData is PointerEventData pointerData) + { + transform.position = CommonUtil.GetMouseWorldPos(pointerData.position, transform); + } } - public void OnPointerDown(PointerEventData eventData) + private void OnPointerDown(BaseEventData eventData) { // 系统被锁定就返回 if (!_cableSystem.IsPlugAvailable()) return; @@ -115,7 +129,7 @@ namespace AibisDream.FixSystem AdjustPlugPos(); } - public void OnPointerUp(PointerEventData eventData) + private void OnPointerUp(BaseEventData eventData) { // 停止拖拽 _isDragging = false; diff --git a/Assets/Scripts/Framework/EventSystemKit/EventSystemEx.cs b/Assets/Scripts/Framework/EventSystemKit/EventSystemEx.cs index f0d04ae81..56dca5910 100644 --- a/Assets/Scripts/Framework/EventSystemKit/EventSystemEx.cs +++ b/Assets/Scripts/Framework/EventSystemKit/EventSystemEx.cs @@ -19,9 +19,9 @@ namespace AibisDream.Framework public void OnPointerExit(GameObject gameObject) { - EnumEventSystem.Global.Send(TriggerEnum.PointerExit, gameObject); if (pointerOverObj == gameObject) { + EnumEventSystem.Global.Send(TriggerEnum.PointerExit, gameObject); pointerOverObj = null; } } @@ -34,9 +34,9 @@ namespace AibisDream.Framework public void OnPointerUp(GameObject gameObject) { - EnumEventSystem.Global.Send(TriggerEnum.PointerUp, gameObject); if (holdingObj == gameObject) { + EnumEventSystem.Global.Send(TriggerEnum.PointerUp, gameObject); holdingObj = null; } } diff --git a/Assets/Scripts/Framework/EventSystemKit/EventTriggerEx.cs b/Assets/Scripts/Framework/EventSystemKit/EventTriggerEx.cs index d80982acb..12f328d1c 100644 --- a/Assets/Scripts/Framework/EventSystemKit/EventTriggerEx.cs +++ b/Assets/Scripts/Framework/EventSystemKit/EventTriggerEx.cs @@ -80,7 +80,14 @@ namespace AibisDream.Framework public override void OnPointerDown(PointerEventData eventData) { - + EventSystemEx.Instance.OnPointerDown(gameObject); + base.OnPointerDown(eventData); + } + + public override void OnPointerUp(PointerEventData eventData) + { + EventSystemEx.Instance.OnPointerUp(gameObject); + base.OnPointerUp(eventData); } } } \ No newline at end of file diff --git a/Assets/Scripts/Game Loop/GameLoopManager.cs b/Assets/Scripts/Game Loop/GameLoopManager.cs index 609339cf0..b112bac91 100644 --- a/Assets/Scripts/Game Loop/GameLoopManager.cs +++ b/Assets/Scripts/Game Loop/GameLoopManager.cs @@ -192,7 +192,7 @@ namespace AibisDream _dialogStorage.TryGetValue("$gameStage", out float gameStage); gameStageStr = gameStage.ToString(CultureInfo.InvariantCulture); } - catch (Exception e) + catch (Exception) { _dialogStorage.TryGetValue("$gameStage", out string gameStage); gameStageStr = gameStage; diff --git a/Assets/Scripts/UI/Cursor/CursorManager.cs b/Assets/Scripts/UI/Cursor/CursorManager.cs index 04dece934..9b3b411d3 100644 --- a/Assets/Scripts/UI/Cursor/CursorManager.cs +++ b/Assets/Scripts/UI/Cursor/CursorManager.cs @@ -9,7 +9,7 @@ namespace AibisDream { public class CursorManager : MonoBehaviour { - private const float DelayTime = 0.2f; + private const float DelayTime = 0.1f; [Header("指针图片")] public Sprite defaultCursor; public Sprite nextTalk, talking, option, interactive, holding, disable, eye; @@ -21,12 +21,12 @@ namespace AibisDream private Coroutine _switchCoroutine; private CursorState _curState = CursorState.Default; - private bool _isTalking = false; + private bool _isTalking; #endregion // 卸载时注销事件 - private List _unRegisters = new(); + private readonly List _unRegisters = new(); public void Awake() { @@ -69,12 +69,11 @@ namespace AibisDream _unRegisters.Add(EnumEventSystem.Global.Register(DialogEventEnum.LineStart, OnLineStart)); _unRegisters.Add(EnumEventSystem.Global.Register(DialogEventEnum.LineShowed, () => SwitchCursor(nextTalk))); - _unRegisters.Add(EnumEventSystem.Global.Register(DialogEventEnum.LineEnd, - () => SwitchCursorDelay(defaultCursor))); - _unRegisters.Add(EnumEventSystem.Global.Register(DialogEventEnum.OptionShow, () => SwitchCursor(option))); + _unRegisters.Add(EnumEventSystem.Global.Register(DialogEventEnum.LineEnd, OnLineEnd)); + _unRegisters.Add(EnumEventSystem.Global.Register(DialogEventEnum.OptionShow, OnOptionShow)); _unRegisters.Add( EnumEventSystem.Global.Register(DialogEventEnum.OptionSelected, - _ => SwitchCursorDelay(defaultCursor))); + OnOptionSelect)); // 交互相关 _unRegisters.Add(EnumEventSystem.Global.Register(InteractionEventEnum.Start, OnInteractiveStart)); @@ -82,6 +81,12 @@ namespace AibisDream _unRegisters.Add( EnumEventSystem.Global.Register(TriggerEnum.PointerEnter, OnPointerEnter)); + _unRegisters.Add( + EnumEventSystem.Global.Register(TriggerEnum.PointerExit, OnPointerExit)); + _unRegisters.Add( + EnumEventSystem.Global.Register(TriggerEnum.PointerDown, OnPointerDown)); + _unRegisters.Add( + EnumEventSystem.Global.Register(TriggerEnum.PointerUp, OnPointerUp)); } private void LateUpdate() @@ -105,7 +110,28 @@ namespace AibisDream private void OnLineEnd() { - + StopDelayCursor(); + _switchCoroutine = StartCoroutine(DelayAction(() => + { + _isTalking = false; + _cursor.sprite = defaultCursor; + })); + } + + private void OnOptionShow() + { + _isTalking = true; + SwitchCursor(option); + } + + private void OnOptionSelect(DialogLine line) + { + StopDelayCursor(); + StartCoroutine(DelayAction(() => + { + _isTalking = false; + _cursor.sprite = defaultCursor; + })); } #endregion @@ -115,6 +141,10 @@ namespace AibisDream private void OnInteractiveStart() { _curState = CursorState.Interactive; + if (EventSystemEx.Instance.pointerOverObj) + { + SwitchCursor(interactive); + } } private void OnInteractiveEnd() @@ -126,7 +156,7 @@ namespace AibisDream private void OnPointerEnter(GameObject target) { - if (_curState == CursorState.Interactive) + if (_curState == CursorState.Interactive && !_isTalking) { SwitchCursor(interactive); } @@ -134,12 +164,29 @@ namespace AibisDream private void OnPointerExit(GameObject target) { - if (_curState == CursorState.Interactive) + if (_curState == CursorState.Interactive && !_isTalking) { SwitchCursor(defaultCursor); } } + private void OnPointerDown(GameObject target) + { + if (_curState == CursorState.Interactive && !_isTalking) + { + SwitchCursor(holding); + } + } + + private void OnPointerUp(GameObject target) + { + if (_curState == CursorState.Interactive && !_isTalking) + { + // 如果松手时还在物体之上 + SwitchCursor(EventSystemEx.Instance.holdingObj == target ? interactive : defaultCursor); + } + } + #endregion #region 指针切换 @@ -154,22 +201,6 @@ namespace AibisDream _cursor.sprite = sprite; } - /// - /// 延迟切换指针。如果后面有其他切换状态,就直接打断 - /// - /// 指针图片 - private void SwitchCursorDelay(Sprite sprite) - { - StopDelayCursor(); - _switchCoroutine = StartCoroutine(SwitchCursorAsync(sprite)); - } - - private IEnumerator SwitchCursorAsync(Sprite sprite) - { - yield return new WaitForSeconds(DelayTime); - _cursor.sprite = sprite; - } - private void StopDelayCursor() { if (_switchCoroutine != null)