using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Ichni
{
///
/// 自定义曲线预设
///
public static class CustomCurvePresets
{
///
/// 瞬间完成
///
///
public static AnimationCurve Instant()
{
Keyframe[] keys = new Keyframe[2];
keys[0] = new Keyframe(0, 1, 0, 0);
keys[1] = new Keyframe(1, 1, 0, 0);
return new AnimationCurve(keys);
}
///
/// 抛物线曲线,在中间达到最大值,两端为起始值
///
/// 总时间
/// 起始(和结束)值
/// 中点最大值
public static AnimationCurve Parabolic(float totalTime, float startValue, float peakValue)
{
Keyframe[] keys = new Keyframe[3];
keys[0] = new Keyframe(0, startValue, 0, 0);
keys[1] = new Keyframe(totalTime / 2, peakValue, 0, 0);
keys[2] = new Keyframe(totalTime, startValue, 0, 0);
return new AnimationCurve(keys);
}
///
/// 自定义峰值点位置的抛物线曲线,在指定时间点达到最大值,两端为起始值
///
/// 总时间
/// 起始(和结束)值
/// 最大值
/// 最大值的比例点
///
public static AnimationCurve CustomPeakTimeParabolic(float totalTime, float startValue, float peakValue, float peakTimePercent)
{
Keyframe[] keys = new Keyframe[3];
keys[0] = new Keyframe(0, startValue, 0, 0);
keys[1] = new Keyframe(totalTime * peakTimePercent, peakValue, 0, 0);
keys[2] = new Keyframe(totalTime, startValue, 0, 0);
return new AnimationCurve(keys);
}
}
}