diff --git a/Assets/Resources/Yarn/OptionTest/OptionTest1.yarn b/Assets/Resources/Yarn/OptionTest/OptionTest1.yarn index f36738f6d..d87c28384 100644 --- a/Assets/Resources/Yarn/OptionTest/OptionTest1.yarn +++ b/Assets/Resources/Yarn/OptionTest/OptionTest1.yarn @@ -1,5 +1,12 @@ title: Start --- -<> -[wait name="for_engine"] +me: test1. +me: test2. +me: test3. +=== + +title: New +--- +me: inter1. +me: inter2. === diff --git a/Assets/Scenes/ExpressFixScene.unity b/Assets/Scenes/ExpressFixScene.unity index 6397eaed7..0c4e1ace9 100644 --- a/Assets/Scenes/ExpressFixScene.unity +++ b/Assets/Scenes/ExpressFixScene.unity @@ -898,155 +898,6 @@ LineRenderer: m_UseWorldSpace: 1 m_Loop: 0 m_ApplyActiveColorSpace: 1 ---- !u!1 &289367982 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 289367983} - - component: {fileID: 289367985} - - component: {fileID: 289367984} - m_Layer: 0 - m_Name: Err Wave - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &289367983 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 289367982} - 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: 650606350} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &289367984 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 289367982} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 252307b91ef91c648b65b4cdf9ae497b, type: 3} - m_Name: - m_EditorClassIdentifier: ---- !u!120 &289367985 -LineRenderer: - serializedVersion: 2 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 289367982} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 0 - m_LightProbeUsage: 0 - m_ReflectionProbeUsage: 0 - m_RayTracingMode: 0 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 2100000, guid: 51099a9679b002c46b76c25f9ac139e3, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 7 - m_Positions: - - {x: 0, y: 0, z: 0} - - {x: 0, y: 1.2, z: 0} - m_Parameters: - serializedVersion: 3 - widthMultiplier: 0.5 - widthCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0.052879333 - value: 0.019999973 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - colorGradient: - serializedVersion: 2 - key0: {r: 1, g: 1, b: 1, a: 1} - key1: {r: 1, g: 1, b: 1, a: 1} - key2: {r: 0, g: 0, b: 0, a: 0} - key3: {r: 0, g: 0, b: 0, a: 0} - key4: {r: 0, g: 0, b: 0, a: 0} - key5: {r: 0, g: 0, b: 0, a: 0} - key6: {r: 0, g: 0, b: 0, a: 0} - key7: {r: 0, g: 0, b: 0, a: 0} - ctime0: 0 - ctime1: 65535 - ctime2: 0 - ctime3: 0 - ctime4: 0 - ctime5: 0 - ctime6: 0 - ctime7: 0 - atime0: 0 - atime1: 65535 - atime2: 0 - atime3: 0 - atime4: 0 - atime5: 0 - atime6: 0 - atime7: 0 - m_Mode: 0 - m_ColorSpace: -1 - m_NumColorKeys: 2 - m_NumAlphaKeys: 2 - numCornerVertices: 1 - numCapVertices: 1 - alignment: 0 - textureMode: 0 - textureScale: {x: 1, y: 1} - shadowBias: 0.5 - generateLightingData: 0 - m_MaskInteraction: 1 - m_UseWorldSpace: 0 - m_Loop: 0 - m_ApplyActiveColorSpace: 1 --- !u!1 &307041274 GameObject: m_ObjectHideFlags: 0 @@ -1146,7 +997,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &360323325 Transform: m_ObjectHideFlags: 0 @@ -1712,7 +1563,6 @@ GameObject: - component: {fileID: 650606352} - component: {fileID: 650606351} - component: {fileID: 650606353} - - component: {fileID: 650606354} m_Layer: 0 m_Name: Screen m_TagString: Untagged @@ -1734,9 +1584,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1735764836} - - {fileID: 289367983} - {fileID: 1864728083} - - {fileID: 1895751250} m_Father: {fileID: 1301816245} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!331 &650606351 @@ -1858,18 +1706,6 @@ MonoBehaviour: normalStrength: 5 normalSmoothing: 1 computingNormal: 0 ---- !u!114 &650606354 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 650606349} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d3e8630f1e6849dd82fa2df4def283da, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!1 &657112468 GameObject: m_ObjectHideFlags: 0 @@ -3075,7 +2911,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &1104267851 Transform: m_ObjectHideFlags: 0 @@ -3320,6 +3156,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: + - {fileID: 1895751250} - {fileID: 650606350} - {fileID: 511870641} m_Father: {fileID: 0} @@ -3875,7 +3712,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &1732205055 Transform: m_ObjectHideFlags: 0 @@ -3917,7 +3754,6 @@ GameObject: m_Component: - component: {fileID: 1735764836} - component: {fileID: 1735764838} - - component: {fileID: 1735764837} m_Layer: 0 m_Name: Waveform Visualizer m_TagString: Untagged @@ -3933,42 +3769,13 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1735764835} serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + 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: 650606350} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1735764837 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1735764835} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: cc37ef954feb9fa449d9a9bc1c28f118, type: 3} - m_Name: - m_EditorClassIdentifier: - samples: 1024 - spatialFrequency: 1.5 - temporalFrequency: 4 - noiseAmplitude: 0.2 - clarity: 0 - noiseColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} - clearColor: {r: 0, g: 1, b: 0, a: 1} - spriteWidth: 0 - spriteHeight: 0 - waveformData: [] - displayData: [] - waveformType: 0 - amplitudeModulationFrequency: 0 - amplitudeModulationDepth: 0 - phaseShift: 0 - isErrorFind: 0 - scanSpeed: 1 --- !u!120 &1735764838 LineRenderer: serializedVersion: 2 @@ -4088,7 +3895,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &1814664091 Transform: m_ObjectHideFlags: 0 @@ -4322,7 +4129,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1864728082} serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + 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 @@ -4492,12 +4299,12 @@ RectTransform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1895751249} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + 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: 650606350} + m_Father: {fileID: 1301816245} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -5218,5 +5025,5 @@ SceneRoots: - {fileID: 1732205055} - {fileID: 1301816245} - {fileID: 1814664091} - - {fileID: 1874453573} - {fileID: 1104267851} + - {fileID: 1874453573} diff --git a/Assets/ScriptObject.meta b/Assets/ScriptObject.meta deleted file mode 100644 index f59be5920..000000000 --- a/Assets/ScriptObject.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: fb2457202a3d3b842a1ffde799439396 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ScriptObject/MiniGame.meta b/Assets/ScriptObject/MiniGame.meta deleted file mode 100644 index b64f47de7..000000000 --- a/Assets/ScriptObject/MiniGame.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2b2ac8efd2a958e4a84e623a950332e3 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ScriptObject/MiniGame/Gear1.asset b/Assets/ScriptObject/MiniGame/Gear1.asset deleted file mode 100644 index 46573e750..000000000 --- a/Assets/ScriptObject/MiniGame/Gear1.asset +++ /dev/null @@ -1,17 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!114 &11400000 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 119dddf8c44ac744998ce02562a75416, type: 3} - m_Name: Gear1 - m_EditorClassIdentifier: - radius: 1.2 - id: 1 - spriteName: Art/Obj/gear diff --git a/Assets/ScriptObject/MiniGame/Gear1.asset.meta b/Assets/ScriptObject/MiniGame/Gear1.asset.meta deleted file mode 100644 index 1bc4922a5..000000000 --- a/Assets/ScriptObject/MiniGame/Gear1.asset.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 0b31f7a5b65969146ace2f70ffebf57e -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 11400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/FixSystem/Scope/OscilloscopeController.cs b/Assets/Scripts/FixSystem/Scope/OscilloscopeController.cs index fd63fa722..6ad3ba911 100644 --- a/Assets/Scripts/FixSystem/Scope/OscilloscopeController.cs +++ b/Assets/Scripts/FixSystem/Scope/OscilloscopeController.cs @@ -1,14 +1,9 @@ using UnityEngine; -using System.Collections.Generic; using System.Collections; using RainbowArt.CleanFlatUI; using UnityEngine.UI; -using System.Text.RegularExpressions; -using DG.Tweening; using TMPro; -using UnityEditor.Localization.Plugins.XLIFF.V20; using AibisDream; -using Yarn.Unity; public class OscilloscopeController : MonoBehaviour { @@ -151,14 +146,6 @@ public class OscilloscopeController : MonoBehaviour } } - void HandleExternalError() - { - scanLine.gameObject.SetActive(false); - phaseSlider.interactable = false; - waveformVisualizer.gameObject.SetActive(false); - screenText.text = "外部错误已关联,可以直接深入"; - } - private IEnumerator ScanForError(string trimmedString) { phaseSlider.interactable = false; diff --git a/Assets/Scripts/FixSystem/Scope/WaveformVisualizer.cs b/Assets/Scripts/FixSystem/Scope/WaveformVisualizer.cs index d0aa594ee..9210641b9 100644 --- a/Assets/Scripts/FixSystem/Scope/WaveformVisualizer.cs +++ b/Assets/Scripts/FixSystem/Scope/WaveformVisualizer.cs @@ -252,7 +252,6 @@ public class WaveformVisualizer : MonoBehaviour attenuation *= 0.9f; // 降低扰动强度 float baseAmplitude = displayData[index] * amplitudeScale * (spriteHeight / 2f); float randomRange = (Mathf.Abs(baseAmplitude) - amplitude / 3f) * attenuation; - //isErrorFind = Mathf.Abs(baseAmplitude) < amplitude / 3; if (Mathf.Abs(baseAmplitude) < amplitude / 3) { float randomOffset = Random.Range(-randomRange, randomRange); @@ -268,8 +267,7 @@ public class WaveformVisualizer : MonoBehaviour { isErrorFind = displayData[spikeIndex] < amplitude / 3f; } - - + void GenerateAntiWaveformData() { for (int i = 0; i < samples; i++) @@ -319,4 +317,13 @@ public class WaveformVisualizer : MonoBehaviour targetdata = null; isErrorFind = false; } + + /// + /// 尖峰位置 + /// + /// + public float CalcSpikeX() + { + return SpikeIndex / (float)samples * spriteWidth - spriteWidth / 2; + } } \ No newline at end of file diff --git a/Assets/Scripts/FixSystemNew/BodyModuleSystem.cs b/Assets/Scripts/FixSystemNew/BodyModuleSystem.cs index 2cbf5ffeb..642c53533 100644 --- a/Assets/Scripts/FixSystemNew/BodyModuleSystem.cs +++ b/Assets/Scripts/FixSystemNew/BodyModuleSystem.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using AibisDream.Framework; using UnityEngine; using UnityEngine.Events; @@ -8,9 +9,13 @@ namespace AibisDream.FixSystem { public class BodyModuleSystem : MonoBehaviour { + #region 内部索引 + public BodyModule[] BodyModules { get; private set; } public CableSystem CableSystem { get; private set; } + #endregion + #region 对外暴露事件 public UnityEvent PlugInEvent => CableSystem.plugInEvent; @@ -31,6 +36,7 @@ namespace AibisDream.FixSystem private void InitComponentRefs() { + // 处理内部索引 BodyModules = transform.GetComponentsInChildren(); CableSystem = transform.Find("Cable System").GetComponent(); } diff --git a/Assets/Scripts/FixSystemNew/OscilloscopeScreen.cs b/Assets/Scripts/FixSystemNew/OscilloscopeScreen.cs new file mode 100644 index 000000000..2e440170d --- /dev/null +++ b/Assets/Scripts/FixSystemNew/OscilloscopeScreen.cs @@ -0,0 +1,14 @@ +using UnityEngine; + +namespace AibisDream.FixSystem +{ + public class OscilloscopeScreen : MonoBehaviour + { + #region 组件索引 + + private WaveformLine _waveformLine; + + #endregion + } +} + diff --git a/Assets/Scripts/FixSystemNew/OscilloscopeScreen.cs.meta b/Assets/Scripts/FixSystemNew/OscilloscopeScreen.cs.meta new file mode 100644 index 000000000..9b2496e2d --- /dev/null +++ b/Assets/Scripts/FixSystemNew/OscilloscopeScreen.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d3e8630f1e6849dd82fa2df4def283da +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/FixSystemNew/OscilloscopeSystem.cs b/Assets/Scripts/FixSystemNew/OscilloscopeSystem.cs index c515b295e..d89c8358f 100644 --- a/Assets/Scripts/FixSystemNew/OscilloscopeSystem.cs +++ b/Assets/Scripts/FixSystemNew/OscilloscopeSystem.cs @@ -1,4 +1,5 @@ -using UnityEngine; +using TMPro; +using UnityEngine; namespace AibisDream.FixSystem { @@ -6,26 +7,42 @@ namespace AibisDream.FixSystem { #region 组件索引 - private OscilloscopeViewer _oscilloscopeViewer; private BodyModuleSystem _bodyModuleSystem; + + private TMP_Text _screenText; #endregion - - public void InitComponentRefs() + + private void Awake() { - _oscilloscopeViewer = transform.Find("Oscilloscope Viewer").GetComponent(); + InitComponentRefs(); } - public void DeepIn() + private void InitComponentRefs() { - // 插线系统不正常就返回 - if (!_bodyModuleSystem.IsPlugInSocket()) - { - _oscilloscopeViewer.ShowScreenMessage("未插入任何目标模块"); - return; - } + _screenText = transform.Find("Screen Text").GetComponent(); - // + // TODO 回头找个IOC容器一起管 + _bodyModuleSystem = FindObjectOfType(); + + _screenText.text = ""; + } + + /// + /// 显示消息 + /// + /// + public void ShowScreenMessage(string message) + { + _screenText.text = message; + } + + /// + /// 清除消息 + /// + public void ClearScreenMessage() + { + _screenText.text = ""; } } } \ No newline at end of file diff --git a/Assets/Scripts/FixSystemNew/OscilloscopeViewer.cs b/Assets/Scripts/FixSystemNew/OscilloscopeViewer.cs deleted file mode 100644 index 8c54eb759..000000000 --- a/Assets/Scripts/FixSystemNew/OscilloscopeViewer.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System; -using TMPro; -using UnityEngine; - -namespace AibisDream.FixSystem -{ - public class OscilloscopeViewer : MonoBehaviour - { - private const float PhaseShiftMax = Mathf.PI * 1.5f; - private const float ScanSpeed = 2f; - - #region 组件索引 - - private WaveformVisualizer _waveformVisualizerRef; - private LineRenderer _scanLineRef; - private TMP_Text _screenText; - - private BodyModuleSystem _bodyModuleSystem; - - #endregion - - private void Awake() - { - InitComponentRefs(); - } - - /// - /// 初始化组件索引 - /// - private void InitComponentRefs() - { - _waveformVisualizerRef = transform.Find("Waveform Visualizer").GetComponent(); - _scanLineRef = transform.Find("Scan Line").GetComponent(); - _screenText = transform.Find("Screen Message").GetComponent(); - - // TODO System这种组件可以搞一个IOC容器来访问 - _bodyModuleSystem = FindObjectOfType(); - - // 对部分值进行初始化 - _scanLineRef.startWidth = 0.05f; - _scanLineRef.endWidth = 0.05f; - _scanLineRef.gameObject.SetActive(false); - - _screenText.text = ""; - } - - /// - /// 显示消息 - /// - /// - public void ShowScreenMessage(string message) - { - _screenText.text = message; - } - - /// - /// 清除消息 - /// - public void ClearScreenMessage() - { - _screenText.text = ""; - } - - #region 事件注册 - - private void OnEnable() - { - RegisterEvent(); - } - - private void OnDisable() - { - UnregisterEvent(); - } - - private void RegisterEvent() - { - // TODO 当前是靠Plug触发事件的,但我觉得应该由Socket触发 - // _bodyModuleSystem.PlugInEvent.AddListener(OnPlugInEvent); - // _bodyModuleSystem.PlugOutEvent.AddListener(OnPlugOutEvent); - } - - private void UnregisterEvent() - { - // TODO 当前是靠Plug触发事件的,但我觉得应该由Socket触发 - // _bodyModuleSystem.PlugInEvent.RemoveListener(OnPlugInEvent); - // _bodyModuleSystem.PlugOutEvent.RemoveListener(OnPlugOutEvent); - } - - #endregion - } -} \ No newline at end of file diff --git a/Assets/Scripts/FixSystemNew/OscilloscopeViewer.cs.meta b/Assets/Scripts/FixSystemNew/OscilloscopeViewer.cs.meta deleted file mode 100644 index 22709ecbc..000000000 --- a/Assets/Scripts/FixSystemNew/OscilloscopeViewer.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: d3e8630f1e6849dd82fa2df4def283da -timeCreated: 1731314656 \ No newline at end of file diff --git a/Assets/Scripts/FixSystemNew/ScanLine.cs b/Assets/Scripts/FixSystemNew/ScanLine.cs new file mode 100644 index 000000000..66c21deb0 --- /dev/null +++ b/Assets/Scripts/FixSystemNew/ScanLine.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections; +using UnityEngine; + +namespace AibisDream.FixSystem +{ + public class ScanLine : MonoBehaviour + { + #region 组件索引 + + private OscilloscopeScreen _screen; + private LineRenderer _line; + + #endregion + + #region 扫描线状态 + + private bool _isScanning; + + #endregion + + #region 部分参数(后面改成从screen获取) + + private float _screenHeight; + private float _screenWidth; + + private float _screenLeftX; + private float _screenRightX; + + private float _topY; + private float _bottomY; + + private float _spikeX; + + private float _scanSpeed; + + private event Action ScanErrorEvent; + + #endregion + + private void Awake() + { + InitComponentRefs(); + } + + private void InitComponentRefs() + { + _screen = transform.parent.GetComponent(); + _line = GetComponent(); + } + + public IEnumerator ScanForError() + { + // 初始化扫描线 + InitStartLine(); + // 扫描线右移 + var currentX = _screenLeftX; + var lastX = currentX; + bool isSpikeFound = false; + while (currentX <= _screenRightX) + { + // 横坐标右移 + currentX += Time.deltaTime * _scanSpeed; + SetLinePos(currentX); + + // 检查是否扫到尖峰 + if (CheckSpikeInRange(lastX, currentX)) + { + isSpikeFound = true; + // 修改线条 + MarkLineAsError(); + // 触发扫描事件 + yield return new WaitForSeconds(1f); + ScanErrorEvent?.Invoke(); + } + } + } + + private void InitStartLine() + { + // 初始状态是一根靠左的竖线 + SetLinePos(_screenLeftX); + + _line.enabled = true; + } + + private void SetLinePos(float posX) + { + var topPosition = new Vector3(posX, _topY, 0); + var bottomPosition = new Vector3(posX, _bottomY, 0); + _line.SetPosition(0, topPosition); + _line.SetPosition(1, bottomPosition); + } + + private bool CheckSpikeInRange(float x1, float x2) + { + var left = Mathf.Min(x1, x2); + var right = Mathf.Max(x1, x2); + return _spikeX >= left && _spikeX <= right; + } + + private void MarkLineAsError() + { + SetLinePos(_spikeX); + _line.startColor = Color.red; + _line.endColor = Color.red; + } + + public void CloseScan() + { + _line.enabled = false; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/FixSystemNew/ScanLine.cs.meta b/Assets/Scripts/FixSystemNew/ScanLine.cs.meta new file mode 100644 index 000000000..c5c76525e --- /dev/null +++ b/Assets/Scripts/FixSystemNew/ScanLine.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d539f4fdddef410c9df21320f69fe38f +timeCreated: 1731586860 \ No newline at end of file diff --git a/Assets/Scripts/FixSystemNew/WaveformLine.cs b/Assets/Scripts/FixSystemNew/WaveformLine.cs new file mode 100644 index 000000000..adefe9242 --- /dev/null +++ b/Assets/Scripts/FixSystemNew/WaveformLine.cs @@ -0,0 +1,303 @@ +using System; +using UnityEngine; +using Random = UnityEngine.Random; + +namespace AibisDream.FixSystem +{ + public class WaveformLine : MonoBehaviour + { + #region 组件索引 + + private LineRenderer _waveformLine; + + #endregion + + private float _screenWidth; + private float _screenHeight; + + #region 状态 + + private bool _isWavePlaying; + + #endregion + + private WaveParam _waveParam; + + #region Line数据 + + private float[] _waveformData; + private float[] _noiseData; + private float[] _spikeData; + + private float[] _displayData; // 最后展示数据 + + #endregion + + [SerializeField] private WaveformConfig config; + + private void Awake() + { + InitComponentRefs(); + InitValues(); + } + + private void InitValues() + { + _waveformData = new float[config.samples]; + _noiseData = new float[config.samples]; + _spikeData = new float[config.samples]; + + _displayData = new float[config.samples]; + } + + private void InitComponentRefs() + { + _waveformLine = GetComponent(); + } + + private void Update() + { + if (_isWavePlaying) + { + // 绘制线条 + DrawWaveform(); + } + } + + private void DrawWaveform() + { + // 计算当前线条的点数据 + CalcLinePointsData(); + // 计算结束,绘制线条 + DrawLine(); + } + + #region 波形数据计算 + + private void CalcLinePointsData() + { + // 分组计算: + var noiseData = GenerateNoiseData(); // 生成噪声 + var waveformData = GenerateWaveformData(); // 波形数据 + var spikeData = GenerateSpikeData(); // 错误尖峰数据 + + // 合成最终结果 + for (int i = 0; i < config.samples; i++) + { + // 正常线条加错误尖峰 + var lineValue = (_waveParam.isClarity ? waveformData[i] : noiseData[i]) + spikeData[i]; + _displayData[i] = Mathf.Clamp(lineValue, -_screenHeight / 1.8f, _screenHeight / 1.8f); + } + } + + private float[] GenerateNoiseData() + { + for (var i = 0; i < config.samples; i++) + { + _noiseData[i] = Random.Range(-config.AdjustedNoiseAmplitude, config.AdjustedNoiseAmplitude); + } + + return _noiseData; + } + + private float[] GenerateWaveformData() + { + if (_waveParam.isClarity) + { + // 计算波形 + for (int i = 0; i < config.samples; i++) + { + float basicAngle = TransIndexToAngle(i); + // 正波形 + float wavePoint = CalcLineValueByAngle(basicAngle); + // 如果有相位偏移 + if (_waveParam.phaseShift > 0) + { + wavePoint -= CalcLineValueByAngle(basicAngle + _waveParam.phaseShift); + } + + _waveformData[i] = wavePoint; + } + } + else + { + // 此时没有波形,数组置为0 + Array.Clear(_waveformData, 0, _waveformData.Length); + } + + return _waveformData; + } + + private float TransIndexToAngle(int idx) + { + return (float)idx / config.samples * Mathf.PI * 2f * config.spatialFrequency; + } + + private float CalcLineValueByAngle(float angle) + { + // 计算波形值 + var value = _waveParam.waveformType switch + { + WaveformType.Sine => Mathf.Sin(angle), + WaveformType.Square => Mathf.Sign(Mathf.Sin(angle)), + WaveformType.Triangle => Mathf.PingPong(angle / Mathf.PI, 1f) * 2f - 1f, + WaveformType.Sawtooth => angle / (Mathf.PI * 2f) % 1f * 2f - 1f, // 统一周期为 2π + WaveformType.Pulse => Mathf.PingPong(angle / (Mathf.PI * 2f), 1f) > 0.5f ? 1f : -1f, // 统一周期为 2π + WaveformType.Noise => Mathf.PerlinNoise(angle / (Mathf.PI * 2f), Time.time * config.temporalFrequency) * + 2f - 1f, // 统一周期为 2π + WaveformType.Composite => Mathf.Sin(angle) + Mathf.Sin(angle * 2f) * 0.5f, // 组合波形也统一周期 + _ => 0f + }; + + return value * config.amplitude; // 最终返回角度对应波形 + } + + private float[] GenerateSpikeData() + { + if (_waveParam.isSpikeShowed) + { + // 错误点可以显示 + for (var i = 0; i < config.samples; i++) + { + _spikeData[i] = CalcSpikeValueByIdx(i); + } + } + else + { + // 错误点尚不可显示,全部置为0 + Array.Clear(_spikeData, 0, _spikeData.Length); + } + + return _spikeData; + } + + private float CalcSpikeValueByIdx(int idx) + { + var distanceToSpike = Mathf.Abs(_waveParam.spikeIdx - idx); + // 尖峰范围外直接数据为0 + if (distanceToSpike > config.spikeRange) return 0f; + + // 尖峰范围内计算 + // 计算随机范围 + var attenuation = (1f - distanceToSpike / 20f) * 0.9f; + var baseAmplitude = _displayData[idx] * config.AmplitudeScale * (_screenHeight / 2f); + var randomRange = (Mathf.Abs(baseAmplitude) - config.amplitude / 3f) * attenuation; + // 得出结果 + if (Mathf.Abs(baseAmplitude) < config.amplitude / 3) + { + return Random.Range(-randomRange, randomRange); // 对 Y 值进行随机扰动 + } + + return 0; + } + + #endregion + + /// + /// 根据计算出的点数绘制线条 + /// + private void DrawLine() + { + for (int i = 0; i < config.samples; i++) + { + // 计算线上每个点的位置 + float x = (float)i / (config.samples - 1) * _screenWidth - _screenWidth / 2f; // x轴数据 + float y = _displayData[i] * config.AmplitudeScale * (_screenHeight / 2f); + Vector3 position = new Vector3(x, y, 0); + // 设置 + _waveformLine.SetPosition(i, position); + } + + // 设置颜色和宽度 + _waveformLine.startColor = config.LineColor; + _waveformLine.endColor = config.LineColor; + _waveformLine.startWidth = config.LineWidth; + _waveformLine.endWidth = config.LineWidth; + } + + #region 对外暴露 + + /// + /// 设置屏幕尺寸作为参数 + /// + /// 宽 + /// 高 + public void SetLineSize(float width, float height) + { + _screenHeight = height; + _screenWidth = width; + } + + /// + /// 设置波形参数 + /// + /// + public void SetWaveParam(WaveParam waveData) + { + _waveParam = waveData; + config.isClarity = waveData.isClarity; + } + + /// + /// 显示波形 + /// + public void PlayWave() + { + _isWavePlaying = true; + } + + /// + /// 停止显示波形 + /// + public void StopWave() + { + _isWavePlaying = false; + } + + #endregion + } + + [Serializable] + public class WaveformConfig + { + public int samples = 1024; + public float amplitude = 0.6f; + public int spikeRange = 20; + + public float spatialFrequency = 1f; + public float temporalFrequency = 0.1f; + public float targetWaveformNoiseAmplitude = 0.1f; + public float noiseAmplitude = 0.5f; + + public Color noiseColor = Color.gray; + public Color clearColor = Color.green; + + public bool isClarity; + + public Color LineColor => isClarity ? clearColor : noiseColor; + public float LineWidth => isClarity ? 0.05f : 0.02f; + public float AmplitudeScale => isClarity ? 1f : 0.2f; + public float AdjustedNoiseAmplitude => isClarity ? targetWaveformNoiseAmplitude : noiseAmplitude; + } + + public struct WaveParam + { + public WaveformType waveformType; + public float phaseShift; + public bool isClarity; + public bool isSpikeShowed; + public int spikeIdx; + } + + public enum WaveformType + { + Default, + Sine, + Square, + Triangle, + Sawtooth, + Noise, + Composite, + Pulse + } +} \ No newline at end of file diff --git a/Assets/Scripts/FixSystemNew/WaveformLine.cs.meta b/Assets/Scripts/FixSystemNew/WaveformLine.cs.meta new file mode 100644 index 000000000..7a4bfda95 --- /dev/null +++ b/Assets/Scripts/FixSystemNew/WaveformLine.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: fd4bf97f1c7d4f559fe7ce23a64bff87 +timeCreated: 1731495781 \ No newline at end of file diff --git a/Assets/Scripts/Framework/IocContainer.cs b/Assets/Scripts/Framework/IocContainer.cs new file mode 100644 index 000000000..5b87951b2 --- /dev/null +++ b/Assets/Scripts/Framework/IocContainer.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace AibisDream.Framework +{ + public class IocContainer + { + private readonly Dictionary _container = new(); + + public void Register(T instance) + { + var key = typeof(T); + + if (_container.ContainsKey(key)) + { + _container[key] = instance; + } + else + { + _container.Add(key, instance); + } + } + + public T Get() where T : class + { + var key = typeof(T); + + if (_container.TryGetValue(key, out var retInstance)) + { + return retInstance as T; + } + + return null; + } + + public IEnumerable GetInstancesByType() + { + var type = typeof(T); + return _container.Values.Where(instance => type.IsInstanceOfType(instance)).Cast(); + } + + public void Clear() => _container.Clear(); + } + + public static class IocTools + { + private static readonly IocContainer IocContainer = new(); + + public static void RegisterIoc(this object self, T instance) + { + IocContainer.Register(instance); + } + + public static T GetIoc(this object self) where T : class + { + return IocContainer.Get(); + } + + public static IEnumerable GetIocInstancesByType() + { + return IocContainer.GetInstancesByType(); + } + + public static void ClearIoc() + { + IocContainer.Clear(); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Framework/IocContainer.cs.meta b/Assets/Scripts/Framework/IocContainer.cs.meta new file mode 100644 index 000000000..b29e68f1a --- /dev/null +++ b/Assets/Scripts/Framework/IocContainer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e3900bea9d184aa0b42e5a151b931571 +timeCreated: 1731417783 \ No newline at end of file diff --git a/Assets/Scripts/MiniGame/Gear/GearModel.cs b/Assets/Scripts/MiniGame/Gear/GearModel.cs index fb1334c34..89806d358 100644 --- a/Assets/Scripts/MiniGame/Gear/GearModel.cs +++ b/Assets/Scripts/MiniGame/Gear/GearModel.cs @@ -1,22 +1,23 @@ -using System.Collections; -using System.Collections.Generic; +using System; using UnityEngine; -[CreateAssetMenu(menuName = "MiniGame/GearModel")] -public class GearModel : ScriptableObject +namespace AibisDream { - public float radius; - - public int id; - - public string spriteName; - - /// - /// 读取齿轮图片 - /// - /// 齿轮Sprite - public Sprite getSprite() + [Serializable] + public class GearModel { - return Resources.Load(spriteName); + public int id; + public float radius; + public string spriteName; + + /// + /// 读取齿轮图片 + /// + /// 齿轮Sprite + public Sprite GetSprite() + { + return Resources.Load(spriteName); + } } } + diff --git a/Assets/Scripts/MiniGame/Gear/Shaft.cs b/Assets/Scripts/MiniGame/Gear/Shaft.cs index 4abef0329..57fd98f2a 100644 --- a/Assets/Scripts/MiniGame/Gear/Shaft.cs +++ b/Assets/Scripts/MiniGame/Gear/Shaft.cs @@ -1,6 +1,5 @@ using AibisDream.Utility; using DG.Tweening; -using Unity.VisualScripting; using UnityEngine; namespace AibisDream @@ -68,16 +67,7 @@ namespace AibisDream } // 如果带齿轮,要根据齿轮类型生成 - if (shaftType == ShaftType.Pluggable) - { - // 初始化可插拔齿轮 - childGear = InitPluggableGear(); - } - else - { - // 初始化固定齿轮 - childGear = InitStaticGear(); - } + childGear = shaftType == ShaftType.Pluggable ? InitPluggableGear() : InitStaticGear(); speed = initialSpeed; UpdateSpeed(); @@ -143,7 +133,7 @@ namespace AibisDream childGear.transform.DORotate(new Vector3(0, 0, 360), 1 / speed, RotateMode.LocalAxisAdd) .SetEase(Ease.Linear).SetLoops(-1, LoopType.Incremental); } - + private void CheckGameState() { if (shaftType == ShaftType.Target) diff --git a/Assets/Scripts/MiniGame/Gear/ShaftGraph.cs b/Assets/Scripts/MiniGame/Gear/ShaftGraph.cs index af8b17044..33bc8746e 100644 --- a/Assets/Scripts/MiniGame/Gear/ShaftGraph.cs +++ b/Assets/Scripts/MiniGame/Gear/ShaftGraph.cs @@ -165,7 +165,7 @@ namespace AibisDream } // 更新速度 - vertexArray[i].speed = currentSpeed * edgeTable[idx, i]; + vertexArray[i].speed = - currentSpeed * edgeTable[idx, i]; // 已遍历的轴加上标记 vertexRecordArray[i] = true; // 继续寻找相邻齿轮