public Vector2[] GetPositionsFromObject(GridObject obj) { Vector2Int[] coords = GetCoordsFromObject(obj); if (coords == null) { return(null); } Vector2[] positions = new Vector2[coords.Length]; for (int i = 0; i < coords.Length; ++i) { positions[i] = PlacementGrid.GetCellCentre(coords[i]); } return(positions); }
public void UpdatePath() { SnapGrid snapGrid = SnapGrid.Instance; Vector2Int startCoord = snapGrid.GetCoordFromCentre(transform.position); Vector2Int endCoord = snapGrid.GetCoordFromCentre(_endTarget); CurrentPath = new LinkedList <Vector2>(); List <Vector2Int> coordList = _pathMgr.FindPath(startCoord, endCoord, _enemyAttack.DPS, _movement.MovementSpeed); if (coordList != null && coordList.Count > 0) { for (int i = 0; i < coordList.Count; ++i) { Vector2 newWaypoint = snapGrid.GetCellCentre(coordList[i]); CurrentPath.AddLast(newWaypoint); } } OnWaypointReached(transform.position); }