Bezi回来了
This commit is contained in:
@@ -12,29 +12,21 @@ namespace Cielonos.MainGame.Effects.Feedback
|
||||
[Serializable]
|
||||
public struct FloatCurveChannel
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否启用此通道。
|
||||
/// </summary>
|
||||
public bool active;
|
||||
|
||||
/// <summary>
|
||||
/// 震动曲线,X轴为归一化时间[0,1],Y轴为强度[0,1]。
|
||||
/// </summary>
|
||||
[ShowIf("active")]
|
||||
[ShakeCurvePreset]
|
||||
public AnimationCurve curve;
|
||||
|
||||
/// <summary>
|
||||
/// 曲线值0对应的实际数值。
|
||||
/// </summary>
|
||||
[ShowIf("active")]
|
||||
[LabelText("Remap Min")]
|
||||
public float remapMin;
|
||||
|
||||
/// <summary>
|
||||
/// 曲线值1对应的实际数值。
|
||||
/// </summary>
|
||||
[ShowIf("active")]
|
||||
[LabelText("Remap Max")]
|
||||
public float remapMax;
|
||||
|
||||
@@ -47,11 +39,10 @@ namespace Cielonos.MainGame.Effects.Feedback
|
||||
/// <summary>
|
||||
/// 创建默认的曲线通道。
|
||||
/// </summary>
|
||||
public static FloatCurveChannel CreateDefault(bool active = true, float remapMin = 0f, float remapMax = 1f, bool relativeToInitial = true)
|
||||
public static FloatCurveChannel CreateDefault(float remapMin = 0f, float remapMax = 1f, bool relativeToInitial = true)
|
||||
{
|
||||
return new FloatCurveChannel
|
||||
{
|
||||
active = active,
|
||||
curve = new AnimationCurve(
|
||||
new Keyframe(0f, 0f),
|
||||
new Keyframe(0.5f, 1f),
|
||||
@@ -68,7 +59,7 @@ namespace Cielonos.MainGame.Effects.Feedback
|
||||
/// </summary>
|
||||
public readonly float Evaluate(float normalizedTime)
|
||||
{
|
||||
if (!active || curve == null) return 0f;
|
||||
if (curve == null) return 0f;
|
||||
float t = Mathf.Clamp01(normalizedTime);
|
||||
float curveValue = curve.Evaluate(t);
|
||||
return Mathf.LerpUnclamped(remapMin, remapMax, curveValue);
|
||||
@@ -81,15 +72,9 @@ namespace Cielonos.MainGame.Effects.Feedback
|
||||
[Serializable]
|
||||
public struct ColorCurveChannel
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否启用此通道。
|
||||
/// </summary>
|
||||
public bool active;
|
||||
|
||||
/// <summary>
|
||||
/// 颜色渐变。
|
||||
/// </summary>
|
||||
[ShowIf("active")]
|
||||
[LabelText("颜色渐变")]
|
||||
public Gradient gradient;
|
||||
|
||||
@@ -100,7 +85,6 @@ namespace Cielonos.MainGame.Effects.Feedback
|
||||
{
|
||||
return new ColorCurveChannel
|
||||
{
|
||||
active = true,
|
||||
gradient = new Gradient()
|
||||
};
|
||||
}
|
||||
@@ -110,7 +94,7 @@ namespace Cielonos.MainGame.Effects.Feedback
|
||||
/// </summary>
|
||||
public Color Evaluate(float normalizedTime)
|
||||
{
|
||||
if (!active || gradient == null) return Color.white;
|
||||
if (gradient == null) return Color.white;
|
||||
return gradient.Evaluate(Mathf.Clamp01(normalizedTime));
|
||||
}
|
||||
}
|
||||
@@ -121,23 +105,17 @@ namespace Cielonos.MainGame.Effects.Feedback
|
||||
[Serializable]
|
||||
public struct Vector2CurveChannel
|
||||
{
|
||||
public bool active;
|
||||
|
||||
[ShowIf("active")]
|
||||
[LabelText("曲线 X")]
|
||||
[ShakeCurvePreset]
|
||||
public AnimationCurve curveX;
|
||||
|
||||
[ShowIf("active")]
|
||||
|
||||
[LabelText("曲线 Y")]
|
||||
[ShakeCurvePreset]
|
||||
public AnimationCurve curveY;
|
||||
|
||||
[ShowIf("active")]
|
||||
|
||||
[LabelText("Remap Min")]
|
||||
public Vector2 remapMin;
|
||||
|
||||
[ShowIf("active")]
|
||||
|
||||
[LabelText("Remap Max")]
|
||||
public Vector2 remapMax;
|
||||
|
||||
@@ -153,7 +131,6 @@ namespace Cielonos.MainGame.Effects.Feedback
|
||||
{
|
||||
return new Vector2CurveChannel
|
||||
{
|
||||
active = true,
|
||||
curveX = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(1f, 1f)),
|
||||
curveY = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(1f, 1f)),
|
||||
remapMin = Vector2.zero,
|
||||
@@ -164,9 +141,8 @@ namespace Cielonos.MainGame.Effects.Feedback
|
||||
/// <summary>
|
||||
/// 根据归一化时间计算Vector2值。
|
||||
/// </summary>
|
||||
public Vector2 Evaluate(float normalizedTime, Vector2 initialValue)
|
||||
public readonly Vector2 Evaluate(float normalizedTime, Vector2 initialValue)
|
||||
{
|
||||
if (!active) return Vector2.zero;
|
||||
float t = Mathf.Clamp01(normalizedTime);
|
||||
float x = curveX?.Evaluate(t) ?? 0f;
|
||||
float y = curveY?.Evaluate(t) ?? 0f;
|
||||
|
||||
Reference in New Issue
Block a user