public static WayPoints FromPath(Path path) { WayPoints points = new WayPoints(); while (path != null && !path.Finished) { IGridCell current = path.GetNextWaypoint(); if (current != null) { points.Push(new HexPoint(current.X, current.Y)); points._goal = new HexPoint(current.X, current.Y); } } return points; }
public void Move(HexPoint target) { if (Moved != null) Moved(this, Point, target); _point = target; if (_path.Finished) { _path = null; UpdatePathMesh(); } UpdateSpotting(); UpdateUnitAction(); }
public void SetTarget(HexPoint target) { _path = WayPoints.FromPath( Map.FindPath(this, target) ); if (_path.Peek == null) return; Assert.AreEqual(Point, _path.Peek); Assert.AreEqual(target, _path.Goal); UpdatePathMesh(); UpdateUnitAction(); // remove the current position _path.Pop(); }