Exemple #1
0
        public void MoveTo(Vector3[] path, Action endMoveAction = null)
        {
            var moveBesie = new BesieCurve(path);

            Timer.Add(moveBesie.Lenght / moveSpeed, (anim) => {
                if (this == null)
                {
                    return;
                }
                transform.position = moveBesie.GetPositionOnCurve(moveBesie.Lenght * anim);
            }, endMoveAction);
        }
Exemple #2
0
 private void TryFindPath()
 {
     if (startPoint == null)
     {
         return;
     }
     if (endPoint == null)
     {
         return;
     }
     path  = graph.FindPath(startPoint.Id, endPoint.Id);
     curve = new BesieCurve(path.ToArray());
 }
Exemple #3
0
    private List <Vector3> GetBesiePoints(List <Vector3> markersPositions)
    {
        if (markersPositions == null || markersPositions.Count < 2)
        {
            return(null);
        }
        var pathBesie   = new BesieCurve(markersPositions.ToArray());
        var pointsCount = Mathf.CeilToInt(pathBesie.Lenght / markersDistance);
        var curvedPath  = new List <Vector3>(pointsCount);

        for (int i = 0; i < pointsCount; i++)
        {
            curvedPath.Add(pathBesie.GetPositionOnCurve(i * markersDistance));
        }
        return(curvedPath);
    }
Exemple #4
0
        public void MoveTo(Vector3 position)
        {
            var startPosition = Position;

            endPosition = position;
            var startId = planet.Graph.FindNearestId(startPosition);
            var endId   = planet.Graph.FindNearestId(endPosition);
            var path    = planet.Graph.FindPath(startId, endId);

            NormalizePath(path);
            path[0] = endPosition;
            path[path.Count - 1] = startPosition;
            curve = new BesieCurve(path.ToArray());

            float distance = curve.Lenght;

            fullTime  = curve.Lenght / maxSpeed;
            moveTimer = fullTime;
            Debug.Assert(!float.IsNaN(endPosition.x));
            Debug.Assert(!float.IsNaN(endPosition.y));
            Debug.Assert(!float.IsNaN(endPosition.z));
        }