using System; namespace _2DGAMELIB { public class Motion : MotV { public Action OnStart; public Action OnUpdate; public Action OnReach; public Action OnLoop; public Action OnEnd; private bool run; //OnUpdate private bool rou; //OnLoop public bool Run => run; public Motion(double Min, double Max) : base(Min, Max) { } public new void GetValue(FPS FPS) { if (!run) { return; } base.GetValue(FPS); if (OnUpdate != null) { OnUpdate(this); } if (Value == min) { if (rou && OnLoop != null) { OnLoop(this); } rou = false; } else if (Value == max) { if (OnReach != null) { OnReach(this); } rou = true; } } public void Start() { if (OnStart != null) { OnStart(this); } run = true; } public void End() { run = false; if (OnEnd != null) { OnEnd(this); } ResetValue(); rou = false; } } }