Changed class names to be more understandable. Separate some initializes from Character class to CharacterFluidSystem
This commit is contained in:
77
2DGAMELIB/_2DGAMELIB/Motion.cs
Normal file
77
2DGAMELIB/_2DGAMELIB/Motion.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
|
||||
namespace _2DGAMELIB
|
||||
{
|
||||
public class Motion : MotV
|
||||
{
|
||||
public Action<Motion> OnStart;
|
||||
|
||||
public Action<Motion> OnUpdate;
|
||||
|
||||
public Action<Motion> OnReach;
|
||||
|
||||
public Action<Motion> OnLoop;
|
||||
|
||||
public Action<Motion> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user