예제 #1
0
 public NormalEdge( Factories.Factories factories, IRouteElement parent, Vector2 location )
     : base( factories, Styles.NormalStyle, parent )
 {
     this._parent = parent;
     this.StartPoint.SetLocation( location - new Vector2( 0, Constans.RoadHeight / 2 ) );
     this.EndPoint.SetLocation( location + new Vector2( 0, Constans.RoadHeight / 2 ) );
 }
예제 #2
0
        public IEnumerable<RouteElement> Add( IRouteElement routeElement )
        {
            var last = this._route.LastOrDefault();
            if ( last == null )
            {
                var pathFromOwner = this.GetPath( ( IRouteElement ) this.Owner, routeElement ).Select( r => new RouteElement( r, PriorityType.None ) ).ToArray();
                this._route.AddRange( pathFromOwner );
                return pathFromOwner;
            }

            var destinationPoint = last.Control as IRouteElement;
            if ( destinationPoint == null ) { throw new ArgumentException(); }

            var path = this.GetPath( ( IRouteElement ) last.Control, routeElement ).Select( r => new RouteElement( r, PriorityType.None ) ).ToArray();

            this._route.AddRange( path );
            return path;
        }
예제 #3
0
 private IEnumerable<IRouteElement> GetPath( IRouteElement from, IRouteElement to )
 {
     return new PathFinder().GetPath( from, to );
 }
예제 #4
0
        private SearchResult Check( IRouteElement routeElement, List<IRouteElement> vistedControls, List<IRouteElement> currentPath, IRouteElement destination )
        {
            if ( routeElement == destination )
            {
                return new SearchResult( true, currentPath );
            }

            if ( currentPath.Count >= 3 )
            {
                return new SearchResult( false, Enumerable.Empty<IRouteElement>() );
            }


            if ( vistedControls.Contains( routeElement ) ) { return new SearchResult( false, Enumerable.Empty<IRouteElement>() ); }
            vistedControls.Add( routeElement );


            foreach ( var connectedControl in routeElement.GetConnectedControls() )
            {
                var newPaht = new List<IRouteElement>( currentPath ) { connectedControl };
                var found = this.Check( connectedControl, vistedControls, newPaht, destination );
                if ( found.Found ) { return found; }
            }

            return new SearchResult( false, Enumerable.Empty<IRouteElement>() );
        }
예제 #5
0
        public IEnumerable<IRouteElement> GetPath( IRouteElement from, IRouteElement to )
        {

            var visitedControls = new List<IRouteElement>();

            var found = this.Check( from, visitedControls, new List<IRouteElement>(), to );
            return found.Path;
        }
 public InvertedEdgeAdapter( IEdge edge, IRouteElement parent )
 {
     this._edge = edge;
     this._parent = parent;
 }
 public InvertPointEdgeAdapter( IEdgeLine edgeLine, IEdge edge, IRouteElement parent )
 {
     this._edgeLine = edgeLine;
     this._edge = edge;
     this._parent = parent;
 }