修复音粒子效果符触发器
This commit is contained in:
Submodule Assets/Convention updated: 172b2af3ea...48965decbb
@@ -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<IInteraction.JudgementLevel, string> AssetBundles = new();
|
||||
[Content, SerializeField] private Dictionary<IInteraction.JudgementLevel, GameObject> Prefabs = new();
|
||||
[Content, SerializeField] private Dictionary<IInteraction.JudgementLevel, float> 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user