1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- using System;
- using UnityEngine;
- namespace Xft
- {
- [Serializable]
- public class XCurveParam
- {
- public float Evaluate(float time, EffectNode node)
- {
- float num = this.TimeLen;
- if (num < 0f)
- {
- num = node.GetLifeTime();
- }
- float num2 = time / num;
- if (num2 > 1f)
- {
- if (this.WrapType == WRAP_TYPE.CLAMP)
- {
- num2 = 1f;
- }
- else if (this.WrapType == WRAP_TYPE.LOOP)
- {
- int num3 = Mathf.FloorToInt(num2);
- num2 -= (float)num3;
- }
- else
- {
- int num4 = Mathf.CeilToInt(num2);
- int num5 = Mathf.FloorToInt(num2);
- if (num4 % 2 == 0)
- {
- num2 = (float)num4 - num2;
- }
- else
- {
- num2 -= (float)num5;
- }
- }
- }
- return this.Curve01.Evaluate(num2) * this.MaxValue;
- }
- public float Evaluate(float time)
- {
- float num = time / this.TimeLen;
- if (num > 1f)
- {
- if (this.WrapType == WRAP_TYPE.CLAMP)
- {
- num = 1f;
- }
- else if (this.WrapType == WRAP_TYPE.LOOP)
- {
- int num2 = Mathf.FloorToInt(num);
- num -= (float)num2;
- }
- else
- {
- int num3 = Mathf.CeilToInt(num);
- int num4 = Mathf.FloorToInt(num);
- if (num3 % 2 == 0)
- {
- num = (float)num3 - num;
- }
- else
- {
- num -= (float)num4;
- }
- }
- }
- return this.Curve01.Evaluate(num) * this.MaxValue;
- }
- [SerializeField]
- public float MaxValue = 1f;
- [SerializeField]
- public float TimeLen = 1f;
- [SerializeField]
- public WRAP_TYPE WrapType;
- [SerializeField]
- public AnimationCurve Curve01 = new AnimationCurve(new Keyframe[]
- {
- new Keyframe(0f, 0f),
- new Keyframe(1f, 1f)
- });
- }
- }
|