예제 #1
0
 public void ForseStop()
 {
     if (!IsMoving())
     {
         return;
     }
     //_spriteChanger.SetSpeed(0, Vector3.zero);
     _oldDir = Vector3.zero;
     _path   = null;
     _waits  = false;
 }
예제 #2
0
        /*public bool StartMoveToNear(int minPathLength, int pathLength, out PassableObject selection, Func<PassableObject, bool> isCellOk, Action onPathComplete)
         * {
         *      PassableObject underCell = _gridObject.Grid.GetFromCell<PassableObject>(_gridObject.GridPos+Vector3.down);
         *      PassableObject reachableCell = null;
         *      _gridObject.Grid.Utils.PathFinder.GetReachableCells(underCell, pathLength, false, (PassableObject cell) => {
         *              if(isCellOk(cell) && (cell.GridObject.GridPos - underCell.GridObject.GridPos).sqrMagnitude>minPathLength*minPathLength)
         *              {
         *                      reachableCell = cell;
         *                      return true;
         *              }
         *              return false;
         *      });
         *      selection = reachableCell;
         *      if(reachableCell == null)
         *      {
         *              return false;
         *      }
         *      return StartMovingTo(selection.GridObject.GridPos+Vector3.up, onPathComplete);
         * }*/

        public bool StartMovingTo(Vector3 endPoint, Action onPathComplete)
        {
            _onPathComplete = onPathComplete;
            if (IsMoving() || endPoint == _gridObject.GridPos)
            {
                return(false);
            }
            _path = _gridObject.Grid.Utils.PathFinder.CreatePath(
                _gridObject.Grid.Utils.GridPosToWorldPos(_gridObject.GridPos),
                _gridObject.Grid.Utils.GridPosToWorldPos(endPoint), speed);                //FindPath (_gridObject, endPoint, speed);
            if (_path != null)
            {
                return(true);
            }
            return(false);
        }