diff --git a/Assets/Prototype/佩佩/Scripts/EyeManager.cs b/Assets/Prototype/佩佩/Scripts/EyeManager.cs index 11d478bb7..03fb44f96 100644 --- a/Assets/Prototype/佩佩/Scripts/EyeManager.cs +++ b/Assets/Prototype/佩佩/Scripts/EyeManager.cs @@ -5,6 +5,10 @@ using UnityEngine; using DG.Tweening; using Yarn.Unity; using System.Linq; +using UnityEngine.UI; +using JetBrains.Annotations; +using UnityEditor.Build.Pipeline; +using UnityEditor.Localization.Plugins.XLIFF.V12; public class EyeManager : MonoBehaviour { @@ -16,12 +20,15 @@ public class EyeManager : MonoBehaviour private EyeTarget currentTarget; // 当前选中的目标 public EyeTarget CurrentTarget => currentTarget; // 提供当前目标的公共访问 + + public RawImage eyeImage; public enum EyeState { CanImagineColor, CannotImagineColor, - EyeDisorder + EyeDisorder, + CanSeeColor } public ViewCameraManager cameraManager; @@ -62,6 +69,8 @@ public class EyeManager : MonoBehaviour SetInitialTargetState(targets[0]); } SetEyeState(currentState); + //LostColor(); + } public void SetInitialTargetState(EyeTarget target) @@ -161,21 +170,28 @@ public class EyeManager : MonoBehaviour switch (state) { case EyeState.CanImagineColor: - eyeStateEffect = new CanImagineColorEffect(); + eyeStateEffect = new CanImagineColorEffect(); + isFirstSetTargetAfterStateChange = true; break; case EyeState.CannotImagineColor: eyeStateEffect = new CannotImagineColorEffect(); + isFirstSetTargetAfterStateChange = true; break; case EyeState.EyeDisorder: eyeStateEffect = new EyeDisorderEffect(); + isFirstSetTargetAfterStateChange = true; + break; + case EyeState.CanSeeColor: + eyeStateEffect = new CanSeeColorEffect(); + isFirstSetTargetAfterStateChange = false; break; default: throw new ArgumentException("Unknown eye state: " + state.ToString(), nameof(state)); } + colorTransitionDuration = eyeStateEffect.TransitionDuration; // Update transition duration - colorTransitionDuration = eyeStateEffect.TransitionDuration; - isFirstSetTargetAfterStateChange = true; + } public void InitializeEyeEffect() { @@ -183,5 +199,86 @@ public class EyeManager : MonoBehaviour eyeStateEffect.InitializeEffect(currentTarget, cameraManager); } +[YarnCommand("set_EyeColor")] +public IEnumerator SetEyeColor(string color) +{ + if(eyeImage==null) + { + Debug.Log("No eyeImage"); + yield break; + } + + // 获取你要修改的 image 的 material + Material material = eyeImage.material; + + // 创建一个新的 DOTween 序列 + Sequence sequence = DOTween.Sequence(); + + // 添加一个 tween 来改变 _RoundWaveStrength 的值 + sequence.Append(material.DOFloat(1, "_RoundWaveStrength", 2)); + + // 根据颜色改变 _ColorChangeTolerance 的值 + switch (color.ToLower()) + { + case "blue": + sequence.Append(material.DOFloat(0, "_ColorChangeTolerance", 2)); + sequence.Join(material.DOFloat(1, "_ColorChangeTolerance3", 2)); + sequence.Join(material.DOFloat(1, "_ColorChangeTolerance2", 2)); + break; + case "red": + sequence.Append(material.DOFloat(0, "_ColorChangeTolerance3", 2)); + sequence.Join(material.DOFloat(1, "_ColorChangeTolerance", 2)); + sequence.Join(material.DOFloat(1, "_ColorChangeTolerance2", 2)); + break; + case "yellow": + sequence.Append(material.DOFloat(0, "_ColorChangeTolerance2", 2)); + sequence.Join(material.DOFloat(1, "_ColorChangeTolerance", 2)); + sequence.Join(material.DOFloat(1, "_ColorChangeTolerance3", 2)); + break; + case "all": + sequence.Append(material.DOFloat(1, "_ColorChangeTolerance2", 2)); + sequence.Join(material.DOFloat(1, "_ColorChangeTolerance", 2)); + sequence.Join(material.DOFloat(1, "_ColorChangeTolerance3", 2)); + break; + default: + Debug.LogWarning("Unknown color: " + color); + break; + } + + // 添加一个 tween 来将 _RoundWaveStrength 的值回复为 0 + sequence.Join(material.DOFloat(0, "_RoundWaveStrength", 2)); + + // 开始这个序列 + sequence.Play(); + + // 等待序列完成 + yield return sequence.WaitForCompletion(); +} + + +[YarnCommand("EyeGetColor")] +public void GetColor() +{ + // 对目标列表中的每个目标执行 ColorBack 方法 + foreach (EyeTarget target in targets) + { + target.ColorBack(); + } + + // 切换到 CanImagineColorEffect 状态 + SetEyeState(EyeState.CanImagineColor); +} +public void LostColor() +{ + // 对目标列表中的每个目标执行 ColorBack 方法 + foreach (EyeTarget target in targets) + { + target.ColorLost(); + } + + // 切换到 CanImagineColorEffect 状态 + //SetEyeState(EyeState.CanImagineColor); +} + } diff --git a/Assets/Prototype/佩佩/Scripts/EyeTarget.cs b/Assets/Prototype/佩佩/Scripts/EyeTarget.cs index 57f574329..6824021ac 100644 --- a/Assets/Prototype/佩佩/Scripts/EyeTarget.cs +++ b/Assets/Prototype/佩佩/Scripts/EyeTarget.cs @@ -93,22 +93,28 @@ public class EyeTarget : MonoBehaviour wrongColorMaterial.DOFloat(0f, "_Alpha", duration).SetEase(Ease.InOutSine); } - public void BlurIn(float duration) + public void BlurIn(float duration,bool isForwardMaterial = true) { - wrongColorMaterial.DOFloat(0f, "General Alpha", duration).SetEase(Ease.InOutSine); + Material targetMaterial = isForwardMaterial ? forwardMaterial : backMaterial; + targetMaterial.DOFloat(1f, "_GaussianBlurFade", duration).SetEase(Ease.InOutSine); } - public void BlurOut(float duration) + public void BlurOut(float duration,bool isForwardMaterial = true) { - backMaterial.DOFloat(0f, "_GaussianBlurFade", duration).SetEase(Ease.InOutSine); + Material targetMaterial = isForwardMaterial ? forwardMaterial : backMaterial; + targetMaterial.DOFloat(0f, "_GaussianBlurFade", duration).SetEase(Ease.InOutSine); } - public void AddDisorderEffect(float duration) + public void ColorBack() { - // 这里添加错乱效果的具体实现 + SetToMaxBurnRadius(); + SetToNoWrongColor(); + SetToMaxBlur(); + } + public void ColorLost() + { + SetToMinBurnRadius(); + //SetToNoWrongColor(); + SetToMaxBlur(); } - public void RemoveDisorderEffect(float duration) - { - // 这里移除错乱效果的具体实现 - } } diff --git a/Assets/Prototype/佩佩/Scripts/EyeTransitionManager.cs b/Assets/Prototype/佩佩/Scripts/EyeTransitionManager.cs index 33513e359..46ee2eb2d 100644 --- a/Assets/Prototype/佩佩/Scripts/EyeTransitionManager.cs +++ b/Assets/Prototype/佩佩/Scripts/EyeTransitionManager.cs @@ -70,7 +70,7 @@ public class EyeTransitionManager : MonoBehaviour EyeView, UFView, MemoryView, - ColorView + //ColorView // 为未来的视图添加更多状态 diff --git a/Assets/Prototype/佩佩/Scripts/IEyeStateEffect.cs b/Assets/Prototype/佩佩/Scripts/IEyeStateEffect.cs index 668a05fbb..62b69bc7a 100644 --- a/Assets/Prototype/佩佩/Scripts/IEyeStateEffect.cs +++ b/Assets/Prototype/佩佩/Scripts/IEyeStateEffect.cs @@ -54,12 +54,12 @@ public class CannotImagineColorEffect : IEyeStateEffect public void ApplyFocusedEffect(EyeTarget target) { - target.BlurOut(TransitionDuration); + target.BlurOut(TransitionDuration,false); } public void ApplyUnfocusedEffect(EyeTarget target) { - target.BlurIn(TransitionDuration); + target.BlurIn(TransitionDuration,false); } } @@ -72,6 +72,7 @@ public class EyeDisorderEffect : IEyeStateEffect // Add initialization logic here cameraManager.SetCameraPosition(target.targetTransform); target.SetToWrongColor(); + //target.SetToMinBlur(false); } public void CleanupEffect(EyeTarget target) @@ -90,3 +91,34 @@ public class EyeDisorderEffect : IEyeStateEffect target.WrongColorOut(TransitionDuration); } } + + + + public class CanSeeColorEffect : IEyeStateEffect +{ + public float TransitionDuration { get; } = 1f; + + public void InitializeEffect(EyeTarget target, ViewCameraManager cameraManager) + { + target.SetToMaxBurnRadius(); + cameraManager.SetCameraPosition(target.targetTransform); + target.SetToMinBlur(); + } + + public void CleanupEffect(EyeTarget target) + { + // Add cleanup logic here + target.SetToMaxBlur(); + } + + public void ApplyFocusedEffect(EyeTarget target) + { + target.BlurOut(TransitionDuration); + } + + public void ApplyUnfocusedEffect(EyeTarget target) + { + target.BlurIn(TransitionDuration); + } +} + diff --git a/Assets/Prototype/佩佩/佩佩视觉模块.unity b/Assets/Prototype/佩佩/佩佩视觉模块.unity index 1d5699f14..286d3bc77 100644 --- a/Assets/Prototype/佩佩/佩佩视觉模块.unity +++ b/Assets/Prototype/佩佩/佩佩视觉模块.unity @@ -3303,6 +3303,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: targets: [] + eyeImage: {fileID: 1497904376} cameraManager: {fileID: 147706103} currentState: 2 --- !u!4 &271919488 @@ -3748,7 +3749,7 @@ GameObject: - component: {fileID: 325563564} - component: {fileID: 325563565} m_Layer: 0 - m_Name: dark + m_Name: noColor m_TagString: EyeTarget m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -9689,7 +9690,10 @@ Material: m_Parent: {fileID: 0} m_ModifiedSerializedProperties: 0 m_ValidKeywords: - - FISHEYE_ON + - CHANGECOLOR2_ON + - CHANGECOLOR3_ON + - CHANGECOLOR_ON + - ROUNDWAVEUV_ON m_InvalidKeywords: [] m_LightmapFlags: 4 m_EnableInstancingVariants: 0 @@ -9769,16 +9773,16 @@ Material: - _ClipUvRight: 0 - _ClipUvUp: 0 - _ColorChangeLuminosity: 0 - - _ColorChangeTolerance: 0.25 - - _ColorChangeTolerance2: 0.25 - - _ColorChangeTolerance3: 0.25 + - _ColorChangeTolerance: 1 + - _ColorChangeTolerance2: 1 + - _ColorChangeTolerance3: 1 - _ColorRampBlend: 1 - _ColorRampLuminosity: 0 - _ColorRampOutline: 0 - _ColorSwapBlend: 1 - _ColorSwapBlueLuminosity: 0.5 - _ColorSwapGreenLuminosity: 0.5 - - _ColorSwapRedLuminosity: 0.5 + - _ColorSwapRedLuminosity: -0.64 - _Contrast: 1 - _CullingOption: 0 - _DistortAmount: 0.5 @@ -9794,7 +9798,7 @@ Material: - _FlickerFreq: 0.2 - _FlickerPercent: 0.05 - _GhostBlend: 1 - - _GhostColorBoost: 1 + - _GhostColorBoost: 0 - _GhostTransparency: 0 - _GlitchAmount: 3 - _GlitchSize: 1 @@ -9824,7 +9828,7 @@ Material: - _HologramUnmodAmount: 0 - _HsvBright: 1 - _HsvSaturation: 1 - - _HsvShift: 180 + - _HsvShift: 183 - _InnerOutlineAlpha: 1 - _InnerOutlineGlow: 4 - _InnerOutlineThickness: 1 @@ -9886,7 +9890,7 @@ Material: - _WarpScale: 0.5 - _WarpSpeed: 8 - _WarpStrength: 0.025 - - _WaveAmount: 7 + - _WaveAmount: 12.9 - _WaveSpeed: 10 - _WaveStrength: 7.5 - _WaveX: 0 @@ -9897,12 +9901,12 @@ Material: m_Colors: - _AlphaOutlineColor: {r: 1, g: 1, b: 1, a: 1} - _Color: {r: 1, g: 1, b: 1, a: 1} - - _ColorChangeNewCol: {r: 1, g: 1, b: 0, a: 1} + - _ColorChangeNewCol: {r: 0, g: 0.68719935, b: 1, a: 1} - _ColorChangeNewCol2: {r: 1, g: 1, b: 0, a: 1} - - _ColorChangeNewCol3: {r: 1, g: 1, b: 0, a: 1} - - _ColorChangeTarget: {r: 1, g: 0, b: 0, a: 1} - - _ColorChangeTarget2: {r: 1, g: 0, b: 0, a: 1} - - _ColorChangeTarget3: {r: 1, g: 0, b: 0, a: 1} + - _ColorChangeNewCol3: {r: 1, g: 0, b: 0.011703491, a: 1} + - _ColorChangeTarget: {r: 0.3490566, g: 0.3490566, b: 0.3490566, a: 1} + - _ColorChangeTarget2: {r: 0.41509432, g: 0.41509432, b: 0.41509432, a: 1} + - _ColorChangeTarget3: {r: 0.4433962, g: 0.4433962, b: 0.4433962, a: 1} - _ColorSwapBlue: {r: 1, g: 1, b: 1, a: 1} - _ColorSwapGreen: {r: 1, g: 1, b: 1, a: 1} - _ColorSwapRed: {r: 1, g: 1, b: 1, a: 1} @@ -10430,7 +10434,7 @@ GameObject: - component: {fileID: 1193121550} - component: {fileID: 1193121551} m_Layer: 0 - m_Name: dark2 + m_Name: error m_TagString: EyeTarget m_Icon: {fileID: 0} m_NavMeshLayer: 0 diff --git a/Assets/Resources/Yarn/ChunTest.meta b/Assets/Resources/Yarn/ChunTest.meta new file mode 100644 index 000000000..14969a07f --- /dev/null +++ b/Assets/Resources/Yarn/ChunTest.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3a4125b203b1b074ab5fe04b6ff468da +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Yarn/ChunTest/ChunTest.yarnproject b/Assets/Resources/Yarn/ChunTest/ChunTest.yarnproject new file mode 100644 index 000000000..52e28fbc3 --- /dev/null +++ b/Assets/Resources/Yarn/ChunTest/ChunTest.yarnproject @@ -0,0 +1,12 @@ +{ + "projectFileVersion": 2, + "sourceFiles": [ + "**/*.yarn" + ], + "excludeFiles": [ + "**/*~/*" + ], + "localisation": {}, + "baseLanguage": "zh-CHS", + "compilerOptions": {} +} \ No newline at end of file diff --git a/Assets/Resources/Yarn/ChunTest/ChunTest.yarnproject.meta b/Assets/Resources/Yarn/ChunTest/ChunTest.yarnproject.meta new file mode 100644 index 000000000..f727dd584 --- /dev/null +++ b/Assets/Resources/Yarn/ChunTest/ChunTest.yarnproject.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 847e16eb764d7a64c8efae785cc407b6 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 053561912b1654d80a424bb0696a74ae, type: 3} + useAddressableAssets: 0 + UseUnityLocalisationSystem: 0 + unityLocalisationStringTableCollection: {instanceID: 0} diff --git a/Assets/Resources/Yarn/ChunTest/ChunTest1.yarn b/Assets/Resources/Yarn/ChunTest/ChunTest1.yarn new file mode 100644 index 000000000..c0eaf25ca --- /dev/null +++ b/Assets/Resources/Yarn/ChunTest/ChunTest1.yarn @@ -0,0 +1,32 @@ +title: Start +tags: +--- +<> +//<> +//<> +<> +<> +->滴入红色 +<> +->滴入黄色 +<> +->滴入蓝色 +<> +->混合 +<> +<> +<> + +// 我: 不可思议 +// <> +// ->进入视觉模块 +// <> +// ->指示佩佩观察背景 +// <> +// 我: 不可思议 +// ->指示佩佩观察机器 +// <> +// 我: 不可思议 +// ->指示佩佩观察角色 +// <> +=== diff --git a/Assets/Resources/Yarn/ChunTest/ChunTest1.yarn.meta b/Assets/Resources/Yarn/ChunTest/ChunTest1.yarn.meta new file mode 100644 index 000000000..59db8ee9d --- /dev/null +++ b/Assets/Resources/Yarn/ChunTest/ChunTest1.yarn.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 4f44a4bafe146d04d8360b9edecd212e +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 94073015eacc34c1d8fc6786e43d60ca, type: 3}