You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
965 B
C#
37 lines
965 B
C#
2 months ago
|
using UnityEngine;
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Linq;
|
||
|
using D2D.Utilities;
|
||
|
using D2D;
|
||
|
using D2D.Gameplay;
|
||
|
using static D2D.Utilities.SettingsFacade;
|
||
|
using static D2D.Utilities.CommonLazyFacade;
|
||
|
using static D2D.Utilities.CommonGameplayFacade;
|
||
|
|
||
|
namespace D2D.Utilities
|
||
|
{
|
||
|
[Serializable]
|
||
|
public class RangeCurve
|
||
|
{
|
||
|
[SerializeField] private float factor;
|
||
|
[SerializeField] private AnimationCurve curve;
|
||
|
[SerializeField] private Vector2 range;
|
||
|
|
||
|
public float Min => Mathf.Min(range.x, range.y);
|
||
|
public float Max => Mathf.Max(range.x, range.y);
|
||
|
|
||
|
public float Compute(float value)
|
||
|
{
|
||
|
var dist = Max - Min;
|
||
|
|
||
|
if (value < Min)
|
||
|
return curve.Evaluate(0) * factor;
|
||
|
|
||
|
if (value > Max)
|
||
|
return curve.Evaluate(1) * factor;
|
||
|
|
||
|
return curve.Evaluate((value - Min) / dist * factor);
|
||
|
}
|
||
|
}
|
||
|
}
|