Ejemplo n.º 1
0
        private void UpdatePath()
        {
            _path.Clear();

            IEnumerable <RoadSection> path = roadNetwork.GetCrawlerPath(start.RoadIntersection, destination.RoadIntersection);

            if (path.Count() < 1)
            {
                _currentState = State.Blocked;
            }
            else
            {
                _path.Add(start.RoadIntersection);

                // Create path of intersections
                foreach (RoadSection section in path)
                {
                    if (section.Source == _path.Last())
                    {
                        _path.Add(section.Target);
                    }
                    else if (section.Target == _path.Last())
                    {
                        _path.Add(section.Source);
                    }
                    else
                    {
                        _currentState = State.Blocked;
                    }
                }

                if (_currentState != State.Blocked && _currentState != State.NotStarted)
                {
                    ResetToStart();
                    BeginMoveStraight();
                }
            }
        }