63 lines
1.7 KiB
C#
63 lines
1.7 KiB
C#
using Ichni.RhythmGame.Beatmap;
|
|
using UnityEngine;
|
|
using UnityEngine.Rendering.Universal;
|
|
|
|
namespace Ichni.RhythmGame
|
|
{
|
|
public class BloomEffect : EffectBase
|
|
{
|
|
#region [效果参数] Effect Parameters
|
|
public float duration;
|
|
public float peak;
|
|
public AnimationCurve intensityCurve;
|
|
|
|
private Bloom _bloom;
|
|
#endregion
|
|
|
|
#region [初始化] Initialization
|
|
public BloomEffect(float duration, float peak, AnimationCurve intensityCurve)
|
|
: base(duration) // 激活时间线
|
|
{
|
|
this.duration = duration;
|
|
this.peak = peak;
|
|
this.intensityCurve = intensityCurve;
|
|
}
|
|
|
|
private void PrepareEffectHandle()
|
|
{
|
|
if (_bloom == null && PostProcessingManager.GlobalVolume != null)
|
|
{
|
|
PostProcessingManager.GlobalVolume.profile.TryGet(out _bloom);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region [效果逻辑覆盖] Effect Pattern Overrides
|
|
public override void PreExecute()
|
|
{
|
|
PrepareEffectHandle();
|
|
}
|
|
|
|
public override void Execute()
|
|
{
|
|
if (_bloom != null)
|
|
{
|
|
float currentIntensity = intensityCurve.Evaluate(effectProgressPercent) * peak;
|
|
_bloom.intensity.value = currentIntensity;
|
|
}
|
|
}
|
|
|
|
public override void Adjust() { ResetEffect(); }
|
|
public override void Recover() { ResetEffect(); }
|
|
public override void Disrupt() { ResetEffect(); }
|
|
|
|
private void ResetEffect()
|
|
{
|
|
if (_bloom != null) _bloom.intensity.value = 0f;
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|