public List <WalkPath_Dot> GetPath(WalkPath_Dot fromThisDot, WalkPath_Dot toThatDot, bool onlyDisponibleDot)
    {
        List <WalkPath_Dot> res = new List <WalkPath_Dot>();

        res.Clear();

        if (fromThisDot == toThatDot)
        {
            res.Add(fromThisDot);
        }
        else
        {
            dotVisite.Add(fromThisDot);
            foreach (WalkPath_Dot.nextDot nextPoint in fromThisDot.dotsLink)
            {
                if (!dotVisite.Contains(nextPoint.dot) && (dotDisponible.Contains(nextPoint.dot) || !onlyDisponibleDot) && !res.Contains(toThatDot))
                {
                    res.InsertRange(0, GetPath(nextPoint.dot, toThatDot, onlyDisponibleDot));
                }
            }
            if (res.Contains(toThatDot))
            {
                res.Insert(0, fromThisDot);
            }
        }

        return(res);
    }
示例#2
0
    void MakeNextStep(List <WalkPath_Dot> path)
    {
        if (path.Count == 0)
        {
            Debug.Log("Finish !");
            EndMovement();
            return;
        }
        currentTween.Clear();

        WalkPath_Dot dot = path[0];

        //prepare next step
        path.RemoveAt(0);

        //Fill sequence
        Vector3 direction = (dot.transform.position - this.transform.position);
        float   distance  = direction.magnitude;
        float   duration  = distance / speedMove.x;

        duration /= (speedDependOnScale ? dot.scale : 1f);
        //maybe a speed = move.x and move.y depending on the direction of movement ?
        ChangeAnimDirection(direction);
        currentTween.Add(transform.DOMove(dot.transform.position, duration)
                         .SetEase(Ease.Linear)
                         .OnComplete(() => MakeNextStep(path)));
        currentTween.Add(transform.DOScale(dot.scale, duration)
                         .SetEase(Ease.Linear));
    }
示例#3
0
    public void GoesFromLastToFirst()
    {
        WalkPath     wp    = GameManager.Instance.scenario.currentRoom.walkPath;
        WalkPath_Dot first = wp.wholePath_Dots[wp.wholePath_Dots.Count - 1];
        WalkPath_Dot last  = wp.wholePath_Dots[0];

        GoesFromThisPointToThatPoint(first, last);
    }
示例#4
0
    public void GoesFromHereToLast()
    {
        WalkPath wp = GameManager.Instance.scenario.currentRoom.walkPath;

        WalkPath.closestPointResult first = wp.ClosestDot(this.transform.position);
        WalkPath_Dot last = wp.wholePath_Dots[wp.wholePath_Dots.Count - 1];

        GoesFromThisPointToThatPoint(first.firstPoint, last);///TOD OOOOO
    }
    public List <WalkPath_Dot> StartPath(WalkPath_Dot fromThisDot, WalkPath_Dot toThatDot)
    {
        dotDisponible.Clear();
        dotVisite.Clear();

        bool allInDisponible = (dotDisponible.Contains(fromThisDot) && dotDisponible.Contains(toThatDot));

        return(GetPath(fromThisDot, toThatDot, allInDisponible));
    }
示例#6
0
    public void GoesFromThisPointToThatPoint(WalkPath_Dot fromThisDot, WalkPath_Dot toThatDot)
    {
        walking         = true;
        currentGoal_Dot = toThatDot;
        WalkPath            wp   = GameManager.Instance.scenario.currentRoom.walkPath;
        List <WalkPath_Dot> path = wp.StartPath(fromThisDot, toThatDot);

        //s.SetEase(Ease.Linear);
        MakeNextStep(path);
        //s.AppendCallback(() => ChangeAnimDirection(Vector3.zero));
    }
 public List <WalkPath_Dot> StartPath(closestPointResult fromThisDot, WalkPath_Dot toThatDot)
 {
     //TO DO : treat  that
     return(StartPath(fromThisDot.firstPoint, toThatDot));
 }