Import 2D Level

This commit is contained in:
2026-04-30 00:53:30 +02:00
parent c67979c7cf
commit 5797038baf
479 changed files with 430785 additions and 0 deletions
@@ -0,0 +1,38 @@
using UnityEngine;
namespace Platformer.Mechanics
{
public partial class PatrolPath
{
/// <summary>
/// The Mover class oscillates between start and end points of a path at a defined speed.
/// </summary>
public class Mover
{
PatrolPath path;
float p = 0;
float duration;
float startTime;
public Mover(PatrolPath path, float speed)
{
this.path = path;
this.duration = (path.endPosition - path.startPosition).magnitude / speed;
this.startTime = Time.time;
}
/// <summary>
/// Get the position of the mover for the current frame.
/// </summary>
/// <value></value>
public Vector2 Position
{
get
{
p = Mathf.InverseLerp(0, duration, Mathf.PingPong(Time.time - startTime, duration));
return path.transform.TransformPoint(Vector2.Lerp(path.startPosition, path.endPosition, p));
}
}
}
}
}