From 6c5dc9cdbec9768d4546dfefb865469d7c8b9f45 Mon Sep 17 00:00:00 2001 From: ninemine <1371605831@qq.com> Date: Tue, 2 Dec 2025 17:18:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9F=B3=E7=B2=92=E5=AD=90?= =?UTF-8?q?=E6=95=88=E6=9E=9C=E7=AC=A6=E8=A7=A6=E5=8F=91=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Convention | 2 +- .../JudgementEffect/ParticleJudgement.cs | 45 ++++++++++++++++--- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/Assets/Convention b/Assets/Convention index 172b2af..48965de 160000 --- a/Assets/Convention +++ b/Assets/Convention @@ -1 +1 @@ -Subproject commit 172b2af3ea5b89cd359e27babba08a7a3a61b485 +Subproject commit 48965decbba06bb4071479ae7f428ee3a89907ce diff --git a/Assets/Scripts/Interaction/JudgementEffect/ParticleJudgement.cs b/Assets/Scripts/Interaction/JudgementEffect/ParticleJudgement.cs index 7177b81..15b095c 100644 --- a/Assets/Scripts/Interaction/JudgementEffect/ParticleJudgement.cs +++ b/Assets/Scripts/Interaction/JudgementEffect/ParticleJudgement.cs @@ -1,6 +1,7 @@ +using Convention; +using NUnit.Framework.Internal; using System.Collections; using System.Collections.Generic; -using Convention; using UnityEngine; namespace Demo.Game @@ -16,6 +17,20 @@ namespace Demo.Game [Content, SerializeField] private Dictionary AssetBundles = new(); [Content, SerializeField] private Dictionary Prefabs = new(); [Content, SerializeField] private Dictionary Durations = new(); + [Setting, SerializeField] private bool IsZooming = true; + [Setting, SerializeField] private MathExtension.EaseCurveType ZoomCurve = MathExtension.EaseCurveType.OutCubic; + + [Convention.RScript.Variable.Attr.Method] + public void SetZooming(bool status) + { + IsZooming = status; + } + + [Convention.RScript.Variable.Attr.Method] + public void SetZoomingCurve(MathExtension.EaseCurveType curve) + { + ZoomCurve = curve; + } protected override IEnumerator DoSomethingDuringApplyScript() { @@ -53,9 +68,10 @@ namespace Demo.Game })); } - private void CreateParticle(GameObject prefab) + private GameObject CreateParticle(GameObject prefab) { prefab.SetActive(true); + return prefab; } private void DestroyParticle(GameObject prefab) @@ -63,14 +79,31 @@ namespace Demo.Game prefab.SetActive(false); } + private IEnumerator DoParticleRuntime(float duration, GameObject effect) + { + CreateParticle(effect); + if (IsZooming) + { + for (float clock = 0f; clock < duration; clock += Time.deltaTime) + { + float scale = MathExtension.Evaluate(clock / duration, ZoomCurve); + effect.transform.localScale = new Vector3(scale, scale, scale); + yield return null; + } + } + else + { + effect.transform.localScale = Vector3.one; + yield return new WaitForSeconds(duration); + } + DestroyParticle(effect); + } + public override void OnJudgement(IInteraction.JudgementLevel level) { if (Prefabs.TryGetValue(level, out var effect)) { - ConventionUtility.CreateSteps() - .Next(() => CreateParticle(effect)) - .Wait(Durations[level], () => DestroyParticle(effect)) - .Invoke(); + ConventionUtility.StartCoroutine(DoParticleRuntime(Durations[level], effect)); } } }