feat(peipei-eye): UF 效果迁移到 unified sprite 权重
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using AibisDream;
|
||||
using AibisDream.FixSystem;
|
||||
@@ -7,12 +7,10 @@ using UnityEngine.Rendering;
|
||||
using Yarn.Unity;
|
||||
using DG.Tweening;
|
||||
using VolFx;
|
||||
using System;
|
||||
using AibisDream.Kit;
|
||||
|
||||
public class UFSystem : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
private GameObject _UFCover;
|
||||
private GameObject _UAudioule;
|
||||
|
||||
@@ -22,17 +20,18 @@ public class UFSystem : MonoBehaviour
|
||||
|
||||
public SpriteRenderer face;
|
||||
|
||||
private bool isLoopImage = false;
|
||||
private bool isLoopImage;
|
||||
|
||||
[Header("Global UF Cover")]
|
||||
[SerializeField] private Volume FullAscillVolume;
|
||||
|
||||
[Header("Legacy Volumes (unused; kept for scene refs)")]
|
||||
[SerializeField] private Volume imageAscillVolume;
|
||||
[SerializeField] private Volume imageVolume;
|
||||
[SerializeField] private Volume finalVolume;
|
||||
|
||||
|
||||
private AsciiVol ascii;
|
||||
|
||||
private Tween scaleTween; // 存储 Tween 动画
|
||||
private Tween scaleTween;
|
||||
|
||||
public enum UFState
|
||||
{
|
||||
@@ -45,12 +44,14 @@ public class UFSystem : MonoBehaviour
|
||||
{
|
||||
FixSystemCenter.SystemDic.Register(this);
|
||||
eyeSystem = FindObjectOfType<EyeSystem>();
|
||||
ResetLegacyTargetVolumes();
|
||||
}
|
||||
|
||||
public void TweenWeight(Volume postProcessingVolume, float targetWeight, float duration)
|
||||
private void ResetLegacyTargetVolumes()
|
||||
{
|
||||
// 动态调整权重
|
||||
DOTween.To(() => postProcessingVolume.weight, x => postProcessingVolume.weight = x, targetWeight, duration);
|
||||
if (imageAscillVolume != null) imageAscillVolume.weight = 0f;
|
||||
if (imageVolume != null) imageVolume.weight = 0f;
|
||||
if (finalVolume != null) finalVolume.weight = 0f;
|
||||
}
|
||||
|
||||
[YarnCommand("UF_spriteIn")]
|
||||
@@ -119,59 +120,60 @@ public class UFSystem : MonoBehaviour
|
||||
public IEnumerator UF_ImaginationEffectIn(float duration = 1.5f)
|
||||
{
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine");
|
||||
TweenWeight(imageVolume, 1, duration);
|
||||
yield return new WaitForSeconds(0);
|
||||
eyeSystem?.TweenUnifiedUfWeights(0f, 1f, 0f, duration);
|
||||
yield return new WaitForSeconds(duration);
|
||||
}
|
||||
|
||||
[YarnCommand("UF_ImaginationEffectOut")]
|
||||
public IEnumerator UF_ImaginationEffectOut(float duration = 1.5f)
|
||||
{
|
||||
TweenWeight(imageVolume, 0, duration);
|
||||
eyeSystem?.TweenUnifiedUfWeights(0f, 0f, 0f, duration);
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine");
|
||||
yield return new WaitForSeconds(0);
|
||||
yield return new WaitForSeconds(duration);
|
||||
}
|
||||
|
||||
[YarnCommand("UF_MemoryEffectIn")]
|
||||
public IEnumerator UF_MemoryEffectIn(float duration = 1.5f)
|
||||
{
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine");
|
||||
TweenWeight(finalVolume, 1, duration);
|
||||
yield return new WaitForSeconds(0);
|
||||
eyeSystem?.TweenUnifiedUfWeights(0f, 0f, 1f, duration);
|
||||
yield return new WaitForSeconds(duration);
|
||||
}
|
||||
|
||||
[YarnCommand("UF_MemoryEffectOut")]
|
||||
public IEnumerator UF_MemoryEffectOut(float duration = 1.5f)
|
||||
{
|
||||
TweenWeight(finalVolume, 0, duration);
|
||||
eyeSystem?.TweenUnifiedUfWeights(0f, 0f, 0f, duration);
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine");
|
||||
yield return new WaitForSeconds(0);
|
||||
yield return new WaitForSeconds(duration);
|
||||
}
|
||||
|
||||
[YarnCommand("UF_EyeTargetAscillIn")]
|
||||
public IEnumerator UF_EyeTargetAscillIn(float duration = 1.5f)
|
||||
{
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine");
|
||||
TweenWeight(imageAscillVolume, 1, duration);
|
||||
yield return new WaitForSeconds(0);
|
||||
eyeSystem?.TweenUnifiedUfWeights(1f, 0f, 0f, duration);
|
||||
yield return new WaitForSeconds(duration);
|
||||
}
|
||||
|
||||
[YarnCommand("UF_EyeTargetAscillOut")]
|
||||
public IEnumerator UF_EyeTargetAscillOut(float duration = 1.5f)
|
||||
{
|
||||
TweenWeight(imageAscillVolume, 0, duration);
|
||||
eyeSystem?.TweenUnifiedUfWeights(0f, 0f, 0f, duration);
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine");
|
||||
yield return new WaitForSeconds(0);
|
||||
yield return new WaitForSeconds(duration);
|
||||
}
|
||||
|
||||
[YarnCommand("UF_SetBorkenValue")]
|
||||
public void UF_Borken(int value)
|
||||
{
|
||||
FullAscillVolume.profile.TryGet<AsciiVol>(out ascii);
|
||||
ascii.m_Depth.value = value;
|
||||
ascii.m_Ascii.value = Color.red;
|
||||
if (FullAscillVolume != null && FullAscillVolume.profile.TryGet(out ascii))
|
||||
{
|
||||
ascii.m_Depth.value = value;
|
||||
ascii.m_Ascii.value = Color.red;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[YarnCommand("StartUFEffect_loop")]
|
||||
public void UFImageLoop()
|
||||
{
|
||||
@@ -189,69 +191,64 @@ public class UFSystem : MonoBehaviour
|
||||
{
|
||||
scaleTween = DOTween.To(() => 0f, t =>
|
||||
{
|
||||
// 根据 t(0 到 1 的变化)更新多个值
|
||||
imageVolume.weight = Mathf.Lerp(0f, 1f, t); // 例如:imageVolume 的 weight
|
||||
imageAscillVolume.weight = Mathf.Lerp(0f, 1f, t); // 假设 saturation 是另一个值
|
||||
finalVolume.weight = Mathf.Lerp(1f, 0f, t); // 假设 contrast 是另一个值
|
||||
float dreamWeight = Mathf.Lerp(0f, 1f, t);
|
||||
float asciiWeight = Mathf.Lerp(0f, 1f, t);
|
||||
float memoryWeight = Mathf.Lerp(1f, 0f, t);
|
||||
eyeSystem?.SetUnifiedUfWeights(asciiWeight, dreamWeight, memoryWeight);
|
||||
}, 1f, 1f)
|
||||
.SetEase(Ease.InOutSine) // 平滑缓动
|
||||
.SetLoops(-1, LoopType.Yoyo); // 无限循环
|
||||
.SetEase(Ease.InOutSine)
|
||||
.SetLoops(-1, LoopType.Yoyo);
|
||||
}
|
||||
|
||||
[YarnCommand("UF_StopfightEffect")]
|
||||
public void UF_StopfightEffect()
|
||||
{
|
||||
scaleTween.Kill();
|
||||
scaleTween?.Kill();
|
||||
}
|
||||
|
||||
public IEnumerator UFImageLoopProcess()
|
||||
{
|
||||
int index = 0;
|
||||
isLoopImage = true;
|
||||
while (isLoopImage) // 无限循环
|
||||
while (isLoopImage)
|
||||
{
|
||||
eyeSystem.StartCoroutine(eyeSystem.SetTargetCoroutine(eyeSystem.Targets[index].name, false));
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
StartCoroutine(UF_spriteIn(0.5f));
|
||||
StartCoroutine(UF_ImaginationEffectIn(0.5f));
|
||||
eyeSystem.Targets[index].ImageIn(0.5f);
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
StartCoroutine(UF_ImaginationEffectOut(0.5f));
|
||||
StartCoroutine(UF_MemoryEffectIn(0.5f));
|
||||
yield return new WaitForSeconds(1f);
|
||||
eyeSystem.Targets[index].ImageOut(0.5f);
|
||||
StartCoroutine(UF_MemoryEffectOut(0.5f));
|
||||
index++;
|
||||
// 如果到达列表末尾,则回到开头
|
||||
if (index >= eyeSystem.Targets.Count - 2)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
//yield return new WaitForSeconds(1f); // 每隔1秒打印一次
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenUFView()
|
||||
{
|
||||
if (!FullAscillVolume.gameObject.activeInHierarchy)
|
||||
if (FullAscillVolume != null && !FullAscillVolume.gameObject.activeInHierarchy)
|
||||
{
|
||||
FullAscillVolume.gameObject.SetActive(true);
|
||||
imageAscillVolume.weight = 1;
|
||||
imageVolume.weight = 0;
|
||||
finalVolume.weight = 0;
|
||||
}
|
||||
|
||||
ResetLegacyTargetVolumes();
|
||||
eyeSystem?.SetUnifiedUfWeights(1f, 0f, 0f);
|
||||
}
|
||||
|
||||
public void CloseUFView()
|
||||
{
|
||||
if (FullAscillVolume.gameObject.activeInHierarchy)
|
||||
if (FullAscillVolume != null && FullAscillVolume.gameObject.activeInHierarchy)
|
||||
{
|
||||
FullAscillVolume.gameObject.SetActive(false);
|
||||
imageAscillVolume.weight = 1;
|
||||
imageVolume.weight = 0;
|
||||
finalVolume.weight = 0;
|
||||
//scaleTween.Kill();
|
||||
}
|
||||
|
||||
ResetLegacyTargetVolumes();
|
||||
eyeSystem?.SetUnifiedUfWeights(0f, 0f, 0f);
|
||||
}
|
||||
|
||||
public void OpenCover()
|
||||
@@ -277,36 +274,24 @@ public class UFSystem : MonoBehaviour
|
||||
[YarnCommand("UF_SwitchState")]
|
||||
public IEnumerator SwitchState(string stateName, float duration)
|
||||
{
|
||||
UFState state;
|
||||
if (!Enum.TryParse(stateName, true, out state))
|
||||
if (!Enum.TryParse(stateName, true, out UFState state))
|
||||
{
|
||||
Debug.LogError($"Invalid state name: {stateName}");
|
||||
yield break;
|
||||
}
|
||||
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine");
|
||||
switch (state)
|
||||
{
|
||||
case UFState.UF:
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine");
|
||||
TweenWeight(imageAscillVolume, 1, duration);
|
||||
TweenWeight(imageVolume, 0, duration);
|
||||
TweenWeight(finalVolume, 0, duration);
|
||||
eyeSystem?.TweenUnifiedUfWeights(1f, 0f, 0f, duration);
|
||||
break;
|
||||
|
||||
case UFState.imagination:
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine");
|
||||
TweenWeight(imageAscillVolume, 0, duration);
|
||||
TweenWeight(imageVolume, 1, duration);
|
||||
TweenWeight(finalVolume, 0, duration);
|
||||
eyeSystem?.TweenUnifiedUfWeights(0f, 1f, 0f, duration);
|
||||
break;
|
||||
|
||||
case UFState.memory:
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine");
|
||||
TweenWeight(imageAscillVolume, 0, duration);
|
||||
TweenWeight(imageVolume, 0, duration);
|
||||
TweenWeight(finalVolume, 1, duration);
|
||||
eyeSystem?.TweenUnifiedUfWeights(0f, 0f, 1f, duration);
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.LogError($"Unhandled state: {state}");
|
||||
yield break;
|
||||
@@ -314,4 +299,4 @@ public class UFSystem : MonoBehaviour
|
||||
|
||||
yield return new WaitForSeconds(duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user