Ejemplo n.º 1
0
			public CachedSeeker( Seeker seeker )
			{
				this.start = seeker.Start;
				this.end = seeker.End;
				this.solution = new ArrayList( seeker.Solution );
				
				Restart( seeker.CacheLifespan );
			}
Ejemplo n.º 2
0
        public NetworkNodeAsset NearestNode(Vector3 position, Seeker seeker)
        {
            NetworkNodeAsset nearest;
            Bounds           networkBounds;

            nearest = null;
            foreach (NetworkAsset network in networks)
            {
                if (network is GridNetworkAsset || !network.Enabled || (seeker.ValidateNetworks && !seeker.Valid(network)))
                // Reject disabled networks and invalid ones if we're checking for that
                {
                    continue;
                }

                networkBounds = new Bounds(network.Position + Owner.transform.position, network.Size);
                if (!networkBounds.Contains(position))
                // Reject networks whose bounds do not contain the point
                {
                    continue;
                }

                foreach (NetworkNodeAsset node in network.Nodes)
                // Find the nearest node in this network
                {
                    if (!node.Enabled || !seeker.Valid(node))
                    {
                        continue;
                    }

                    if (nearest == null || (WorldPosition(nearest) - position).sqrMagnitude > (WorldPosition(node) - position).sqrMagnitude)
                    {
                        nearest = node;
                    }
                }
            }

            return(nearest);
        }
Ejemplo n.º 3
0
		public bool StartSeeker( Seeker seeker )
		{
			if( monoBehaviour == null )
			{
				Debug.LogError( "Control failed to add seeker: Not initialized." );
				return false;
			}
			
			monoBehaviour.StartCoroutine( seeker.Seek() );
			
			return true;
		}
Ejemplo n.º 4
0
		public NetworkNodeAsset NearestNode( Vector3 position, Seeker seeker )
		{
			NetworkNodeAsset nearest;
			Bounds networkBounds;
			
			nearest = null;
			foreach( NetworkAsset network in networks )
			{
				if( network is GridNetworkAsset || !network.Enabled || ( seeker.ValidateNetworks && !seeker.Valid( network ) ) )
				// Reject disabled networks and invalid ones if we're checking for that
				{
					continue;
				}
				
				networkBounds = new Bounds( network.Position + Owner.transform.position, network.Size );
				if( !networkBounds.Contains( position ) )
				// Reject networks whose bounds do not contain the point
				{
					continue;
				}
				
				foreach( NetworkNodeAsset node in network.Nodes )
				// Find the nearest node in this network
				{
					if( !node.Enabled || !seeker.Valid( node ) )
					{
						continue;
					}
					
					if( nearest == null || ( WorldPosition( nearest ) - position ).sqrMagnitude > ( WorldPosition( node ) - position ).sqrMagnitude )
					{
						nearest = node;
					}
				}
			}
			
			return nearest;
		}
Ejemplo n.º 5
0
			public bool Match( Seeker seeker )
			{
				return this.start == seeker.Start && this.end == seeker.End && seeker.ValidPath( Solution );
			}
Ejemplo n.º 6
0
		public void UncacheSeeker( Seeker seeker )
		{
			cachedSeekers.Remove( seeker );
		}
Ejemplo n.º 7
0
		public void UseSeeker( Seeker seeker )
		{
			idleSeekers.Remove( seeker );
			activeSeekers.Remove( seeker );
			if( !usedSeekers.Contains( seeker ) )
			{
				usedSeekers.Add( seeker );
			}
		}
Ejemplo n.º 8
0
 public void SeekerKilled(Seeker seeker)
 {
     idleSeekers.Remove(seeker);
     activeSeekers.Remove(seeker);
     usedSeekers.Remove(seeker);
 }
Ejemplo n.º 9
0
		public void SeekerStarted( Seeker seeker )
		{
			idleSeekers.Remove( seeker );
			if( !activeSeekers.Contains( seeker ) )
			{
				activeSeekers.Add( seeker );
			}
		}
Ejemplo n.º 10
0
		public void RegisterSeeker( Seeker seeker )
		{
			idleSeekers.Add( seeker );
			seeker.CacheLifespan = seekerCacheLifespan;
		}
Ejemplo n.º 11
0
		public ArrayList GetCache( Seeker seeker )
		{
			foreach( CachedSeeker cache in cachedSeekers )
			{
				if( cache.Match( seeker ) )
				{
					if( seeker.CacheLifespan != NoCache )
					{
						cache.Restart( seeker.CacheLifespan );
					}
					
					return cache.Solution;
				}
			}
			
			return null;
		}
Ejemplo n.º 12
0
 public void OnSearchFailed(Seeker seeker)
 {
     idleSeekers.Add(seeker);
     activeSeekers.Remove(seeker);
 }
Ejemplo n.º 13
0
 public bool Match(Seeker seeker)
 {
     return(this.start == seeker.Start && this.end == seeker.End && seeker.ValidPath(Solution));
 }
Ejemplo n.º 14
0
 public void UncacheSeeker(Seeker seeker)
 {
     cachedSeekers.Remove(seeker);
 }
Ejemplo n.º 15
0
		public void OnSearchCompleted( Seeker seeker )
		{
			UseSeeker( seeker );
			if( seeker.CacheLifespan != NoCache )
			{
				cachedSeekers.Add( new CachedSeeker( seeker ) );
			}
		}
Ejemplo n.º 16
0
		public void SeekerKilled( Seeker seeker )
		{
			idleSeekers.Remove( seeker );
			activeSeekers.Remove( seeker );
			usedSeekers.Remove( seeker );
		}
Ejemplo n.º 17
0
		public void OnSearchFailed( Seeker seeker )
		{
			idleSeekers.Add( seeker );
			activeSeekers.Remove( seeker );
		}
Ejemplo n.º 18
0
 public void RegisterSeeker(Seeker seeker)
 {
     idleSeekers.Add(seeker);
     seeker.CacheLifespan = seekerCacheLifespan;
 }