public MovingPlatofrm(Layer layer, Vector2 position, float width, bool looped, float pathSpeed, List <Vector2> pathPoints) : base(layer) { Width = width; var cPosition = new PositionComponent(position); var cSolid = new SolidComponent(); var collider = new PlatformCollider(); collider.Size = new Vector2(width * BaseSize, BaseSize / HeightDivider); cSolid.Collider = collider; var cPath = new PathComponent(); cPath.Position = cPosition.Position; cPath.Points = pathPoints; cPath.Speed = pathSpeed; cPath.Looped = looped; AddComponent(cPosition); AddComponent(cSolid); AddComponent(cPath); }
/// <summary> /// Returns next point of the path. /// </summary> public static Vector2 GetNextPoint(PathComponent path) => GetNextPoint(path, path.PointID);
public void ResetPath(PathComponent path) { path.PointProgress = 0; path.PointID = 0; }
public float BoneLength(PathComponent path, int index) => (path.Points[index] - GetNextPoint(path, index)).Length();