Esempio n. 1
0
 public PathData(PathData pathData, ConnectionAsset connection, float gScore, float hScore)
 {
     this.path = new ArrayList(pathData.Path);
     this.path.Add(connection);
     this.gScore = pathData.GScore + gScore;
     this.hScore = pathData.HScore + hScore;
 }
Esempio n. 2
0
 public PathData(ConnectionAsset connection, float gScore, float hScore)
 {
     this.path = new ArrayList();
     this.path.Add(connection);
     this.gScore = gScore;
     this.hScore = hScore;
 }
Esempio n. 3
0
 public void OnDisabled(ConnectionAsset connection)
 {
     if (autoRecalculate)
     {
         RecalculateConnection(connection);
     }
 }
Esempio n. 4
0
        public bool RemoveConnection(ConnectionAsset connection)
        {
            bool found;

            ConnectionAsset[] newConnections;

            found          = false;
            newConnections = new ConnectionAsset[connections.Length - 1];

            for (int i = 0; i < newConnections.Length; i++)
            {
                if (connections[i] == connection)
                {
                    found = true;
                }

                newConnections[i] = connections[i + ((found) ? 1 : 0)];
            }

            found = (connections[newConnections.Length] == connection) ? true : found;

            if (!found)
            {
                return(false);
            }

            connections = newConnections;

            return(true);
        }
Esempio n. 5
0
        public bool DoesUse(ConnectionAsset connection)
        {
            foreach (ConnectionAsset connectionAsset in Solution)
            {
                if (connectionAsset == connection)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 6
0
        public bool ValidConnection(ConnectionAsset connection)
        {
            if (!connection.Enabled ||                                                                  // Connection is disabled?
                !connection.To.Enabled ||                                                               // Target is disabled?
                connection.Width < radius * 2.0f ||                                                     // Seeker doesn't fit?
                !Valid(connection) ||                                                                   // Tags of connection don't fit our seeker?
                !Valid(connection.To)                                                                   // Tags of target don't fit our seeker?
                )
            {
                return(false);
            }

            return(true);
        }
Esempio n. 7
0
        public void AddConnection(ConnectionAsset connection)
        {
            ConnectionAsset[] newConnections;

            if (ConnectsTo(connection.To as NetworkNodeAsset))
            {
                return;
            }

            newConnections = new ConnectionAsset[connections.Length + 1];

            for (int i = 0; i < connections.Length; i++)
            {
                newConnections[i] = connections[i];
            }

            newConnections[connections.Length] = connection;
            connections = newConnections;
        }
Esempio n. 8
0
        public void RecalculateConnection(ConnectionAsset connection)
        {
            CachedSeeker cache;
            Seeker       seeker;

            // TODO: Implement for active seekers as well (we need to get out of the seeker coroutine without doing OnCompleted/OnFailed)

            for (int i = 0; i < cachedSeekers.Count;)
            {
                cache = ( CachedSeeker )cachedSeekers[i];

                if (cache.DoesUse(connection))
                {
                    cachedSeekers.Remove(cache);
                }
                else
                {
                    i++;
                }
            }

            for (int i = 0; i < usedSeekers.Count;)
            {
                seeker = ( Seeker )usedSeekers[i];

                if (seeker.DoesUse(connection))
                {
                    usedSeekers.Remove(seeker);
                    seeker.Invalidate();
                }
                else
                {
                    i++;
                }
            }
        }
Esempio n. 9
0
        public void OnRenderGizmos(Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection, bool onlySelectedConnection)
        {
            if (!onlySelectedConnection)
            {
                Gizmos.color = (!networkSelected) ? Color.yellow : (nodeSelected) ? Color.white : Color.green;
                Gizmos.DrawWireSphere(Position + transform.position + offset, radius);
            }

            foreach (ConnectionAsset connection in Connections)
            {
                Vector3 from, to, vector, fromOffsetA, fromOffsetB, toOffsetA, toOffsetB;

                if (onlySelectedConnection && selectedConnection != connection)
                {
                    continue;
                }

                from        = Position + transform.position + offset;
                to          = connection.To.Position + transform.position + offset;
                vector      = to - from;
                fromOffsetA = from + vector.normalized * (connection.From as WaypointAsset).Radius + Vector3.Cross(vector, Vector3.up).normalized * -(connection.Width / 2.0f);
                fromOffsetB = from + vector.normalized * (connection.From as WaypointAsset).Radius + Vector3.Cross(vector, Vector3.up).normalized *(connection.Width / 2.0f);
                toOffsetA   = to - vector.normalized * (connection.To as WaypointAsset).Radius + Vector3.Cross(vector, Vector3.up).normalized * -(connection.Width / 2.0f);
                toOffsetB   = to - vector.normalized * (connection.To as WaypointAsset).Radius + Vector3.Cross(vector, Vector3.up).normalized *(connection.Width / 2.0f);

                Gizmos.color = (!networkSelected) ? Color.yellow : (selectedConnection == connection) ? Color.white : Color.green;

                Gizmos.DrawLine(fromOffsetA, toOffsetA);
                Gizmos.DrawLine(fromOffsetB, toOffsetB);
            }
        }
Esempio n. 10
0
		public void AddConnection( ConnectionAsset connection )
		{
			ConnectionAsset[] newConnections;
			
			if( ConnectsTo( connection.To as NetworkNodeAsset ) )
			{
				return;
			}
			
			newConnections = new ConnectionAsset[ connections.Length + 1 ];
			
			for( int i = 0; i < connections.Length; i++ )
			{
				newConnections[ i ] = connections[ i ];
			}
			
			newConnections[ connections.Length ] = connection;
			connections = newConnections;
		}
Esempio n. 11
0
        public virtual void OnRenderGizmos(Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection)
        {
            Gizmos.color = (!networkSelected) ? Color.yellow : (nodeSelected) ? Color.white : Color.green;
            Gizmos.DrawWireSphere(Position + transform.position + offset, standardMarkerSize);

            foreach (ConnectionAsset connection in Connections)
            {
                Vector3 from, to, vector;

                from   = Position + transform.position + offset;
                to     = connection.To.Position + transform.position + offset;
                vector = to - from;

                Gizmos.color = (!networkSelected) ? Color.yellow : (selectedConnection == connection) ? Color.white : Color.green;

                Gizmos.DrawLine(from + vector.normalized /* * waypoint.Radius*/,
                                to - vector.normalized /* * ( connection.To as WaypointAsset ).Radius */);

                Gizmos.DrawLine(to - vector.normalized /* * ( connection.To as WaypointAsset ).Radius*/,
                                to - vector.normalized * (/*( connection.To as WaypointAsset ).Radius*/ 1.0f + connection.Width / 2.0f) +
                                Vector3.Lerp((Vector3.Cross(vector, Vector3.up).normalized),
                                             vector.normalized, 0.5f) * connection.Width / 2.0f);

                Gizmos.DrawLine(to - vector.normalized /* * ( connection.To as WaypointAsset ).Radius*/,
                                to - vector.normalized * (/*( connection.To as WaypointAsset ).Radius*/ 1.0f + connection.Width / 2.0f) +
                                Vector3.Lerp((Vector3.Cross(vector, Vector3.up).normalized * -1.0f),
                                             vector.normalized, 0.5f) * connection.Width / 2.0f);
            }
        }
Esempio n. 12
0
 public PathData( PathData pathData, ConnectionAsset connection, float gScore, float hScore )
 {
     this.path = new ArrayList( pathData.Path );
     this.path.Add( connection );
     this.gScore = pathData.GScore + gScore;
     this.hScore = pathData.HScore + hScore;
 }
Esempio n. 13
0
		public bool RemoveConnection( ConnectionAsset connection )
		{
			bool found;
			ConnectionAsset[] newConnections;
			
			found = false;
			newConnections = new ConnectionAsset[ connections.Length - 1 ];
			
			for( int i = 0; i < newConnections.Length; i++ )
			{
				if( connections[ i ] == connection )
				{
					found = true;
				}

				newConnections[ i ] = connections[ i + ( ( found ) ? 1 : 0 ) ];
			}
			
			found = ( connections[ newConnections.Length ] == connection ) ? true : found;
			
			if( !found )
			{
				return false;
			}
			
			connections = newConnections;

			return true;
		}
Esempio n. 14
0
 private float GScore(ConnectionAsset connection)
 {
     return(connection.Cost);
 }
Esempio n. 15
0
 public PathData( ConnectionAsset connection, float gScore, float hScore )
 {
     this.path = new ArrayList();
     this.path.Add( connection );
     this.gScore = gScore;
     this.hScore = hScore;
 }
Esempio n. 16
0
		public virtual void OnRenderGizmos( Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection )
		{
			Gizmos.color = ( !networkSelected ) ? Color.yellow : ( nodeSelected ) ? Color.white : Color.green;
		    Gizmos.DrawWireSphere( Position + transform.position + offset, standardMarkerSize );
			
			foreach( ConnectionAsset connection in Connections )
			{
				Vector3 from, to, vector;
				
				from = Position + transform.position + offset;
				to = connection.To.Position + transform.position + offset;
				vector = to - from;
				
				Gizmos.color = ( !networkSelected ) ? Color.yellow : ( selectedConnection == connection ) ? Color.white : Color.green;
					
				Gizmos.DrawLine( from + vector.normalized/* * waypoint.Radius*/,
					to - vector.normalized/* * ( connection.To as WaypointAsset ).Radius */);
				
				Gizmos.DrawLine( to - vector.normalized/* * ( connection.To as WaypointAsset ).Radius*/,
					to - vector.normalized * ( /*( connection.To as WaypointAsset ).Radius*/1.0f + connection.Width / 2.0f ) +
					Vector3.Lerp( ( Vector3.Cross( vector, Vector3.up ).normalized ),
					vector.normalized, 0.5f ) * connection.Width / 2.0f );
					
				Gizmos.DrawLine( to - vector.normalized/* * ( connection.To as WaypointAsset ).Radius*/,
					to - vector.normalized * ( /*( connection.To as WaypointAsset ).Radius*/1.0f + connection.Width / 2.0f ) +
					Vector3.Lerp( ( Vector3.Cross( vector, Vector3.up ).normalized * -1.0f ),
					vector.normalized, 0.5f ) * connection.Width / 2.0f );
			}
		}
Esempio n. 17
0
 private float GScore( ConnectionAsset connection )
 {
     return connection.Cost;
 }
Esempio n. 18
0
		public void OnRenderGizmos( Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection, bool onlySelectedConnection )
		{
			if( target == null )
			{
				return;
			}
			
			if( networkSelected )
			{
				if( target is WaypointAsset )
				{
					( ( WaypointAsset )target ).OnRenderGizmos( transform, standardMarkerSize, offset, networkSelected, nodeSelected, selectedConnection, true );
				}
				else
				{
					target.OnRenderGizmos( transform, standardMarkerSize, offset, networkSelected, nodeSelected, selectedConnection );
				}
			}
			
			Gizmos.color = Color.red;
			Gizmos.DrawWireSphere( transform.position + offset + Position, standardMarkerSize );
			
			
			foreach( ConnectionAsset connection in Connections )
			{
				Vector3 from, to, vector, fromOffsetA, fromOffsetB, toOffsetA, toOffsetB;
				
				if( onlySelectedConnection && selectedConnection != connection )
				{
					continue;
				}
				
				from = Position + transform.position + Target.Network.Position;
				to = connection.To.Position + transform.position + ( ( GridNodeAsset )connection.To ).Target.Network.Position;
				vector = to - from;
				fromOffsetA = from + vector.normalized + Vector3.Cross( vector, Vector3.up ).normalized * -( connection.Width / 2.0f );
				fromOffsetB = from + vector.normalized + Vector3.Cross( vector, Vector3.up ).normalized * ( connection.Width / 2.0f );
				toOffsetA = to - vector.normalized + Vector3.Cross( vector, Vector3.up ).normalized * -( connection.Width / 2.0f );
				toOffsetB = to - vector.normalized + Vector3.Cross( vector, Vector3.up ).normalized * ( connection.Width / 2.0f );

				Gizmos.color = ( !networkSelected ) ? Color.yellow : ( selectedConnection == connection ) ? Color.white : Color.green;

				Gizmos.DrawLine( fromOffsetA, toOffsetA );
				Gizmos.DrawLine( fromOffsetB, toOffsetB );
			}
		}
Esempio n. 19
0
        public void OnRenderGizmos(Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection, bool onlySelectedConnection)
        {
            if (target == null)
            {
                return;
            }

            if (networkSelected)
            {
                if (target is WaypointAsset)
                {
                    (( WaypointAsset )target).OnRenderGizmos(transform, standardMarkerSize, offset, networkSelected, nodeSelected, selectedConnection, true);
                }
                else
                {
                    target.OnRenderGizmos(transform, standardMarkerSize, offset, networkSelected, nodeSelected, selectedConnection);
                }
            }

            Gizmos.color = Color.red;
            Gizmos.DrawWireSphere(transform.position + offset + Position, standardMarkerSize);


            foreach (ConnectionAsset connection in Connections)
            {
                Vector3 from, to, vector, fromOffsetA, fromOffsetB, toOffsetA, toOffsetB;

                if (onlySelectedConnection && selectedConnection != connection)
                {
                    continue;
                }

                from        = Position + transform.position + Target.Network.Position;
                to          = connection.To.Position + transform.position + (( GridNodeAsset )connection.To).Target.Network.Position;
                vector      = to - from;
                fromOffsetA = from + vector.normalized + Vector3.Cross(vector, Vector3.up).normalized * -(connection.Width / 2.0f);
                fromOffsetB = from + vector.normalized + Vector3.Cross(vector, Vector3.up).normalized *(connection.Width / 2.0f);
                toOffsetA   = to - vector.normalized + Vector3.Cross(vector, Vector3.up).normalized * -(connection.Width / 2.0f);
                toOffsetB   = to - vector.normalized + Vector3.Cross(vector, Vector3.up).normalized *(connection.Width / 2.0f);

                Gizmos.color = (!networkSelected) ? Color.yellow : (selectedConnection == connection) ? Color.white : Color.green;

                Gizmos.DrawLine(fromOffsetA, toOffsetA);
                Gizmos.DrawLine(fromOffsetB, toOffsetB);
            }
        }
Esempio n. 20
0
		public override void OnRenderGizmos( Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection )
		{
			Gizmos.color = ( !networkSelected ) ? Color.yellow : ( nodeSelected ) ? Color.white : Color.green;
			
		    Gizmos.DrawWireSphere( Position + transform.position + offset, standardMarkerSize );
			
			foreach( TriangleAsset triangle in triangles )
			{
				Gizmos.DrawLine( triangle.Points[ 0 ] + transform.position + offset, triangle.Points[ 1 ] + transform.position + offset );
				Gizmos.DrawLine( triangle.Points[ 1 ] + transform.position + offset, triangle.Points[ 2 ] + transform.position + offset );
				Gizmos.DrawLine( triangle.Points[ 2 ] + transform.position + offset, triangle.Points[ 0 ] + transform.position + offset );
			}
			
			// TODO: Draw polygon border
			// [17:47]  <AngryAnt> Ah right. I'm just thinking in vertices because thats the info I have available. So in that context it becomes: If only one triangle contains both vertices of an edge then the edge is on the border of the polygon?
			
			/*foreach( ConnectionAsset connection in Connections )
			{
				Vector3 from, to, vector;
				
				from = Position + transform.position + offset;
				to = connection.To.Position + transform.position + offset;
				vector = to - from;
				
				Gizmos.color = ( !networkSelected ) ? Color.yellow : ( selectedConnection == connection ) ? Color.white : Color.green;
					
				Gizmos.DrawLine( from + vector.normalized/* * waypoint.Radius* /,
					to - vector.normalized/* * ( connection.To as WaypointAsset ).Radius * /);
				
				Gizmos.DrawLine( to - vector.normalized/* * ( connection.To as WaypointAsset ).Radius* /,
					to - vector.normalized * ( /*( connection.To as WaypointAsset ).Radius* /1.0f + /*connection.Width* /1.0f / 2.0f ) +
					Vector3.Lerp( ( Vector3.Cross( vector, Vector3.up ).normalized ),
					vector.normalized, 0.5f ) * /*connection.Width* /1.0f / 2.0f );
					
				Gizmos.DrawLine( to - vector.normalized/* * ( connection.To as WaypointAsset ).Radius* /,
					to - vector.normalized * ( /*( connection.To as WaypointAsset ).Radius* /1.0f + /*connection.Width* /1.0f / 2.0f ) +
					Vector3.Lerp( ( Vector3.Cross( vector, Vector3.up ).normalized * -1.0f ),
					vector.normalized, 0.5f ) * /*connection.Width* /1.0f / 2.0f );
			}*/
		}
Esempio n. 21
0
		public void RecalculateConnection( ConnectionAsset connection )
		{
			CachedSeeker cache;
			Seeker seeker;

			// TODO: Implement for active seekers as well (we need to get out of the seeker coroutine without doing OnCompleted/OnFailed)
			
			for( int i = 0; i < cachedSeekers.Count; )
			{
				cache = ( CachedSeeker )cachedSeekers[ i ];
				
				if( cache.DoesUse( connection ) )
				{
					cachedSeekers.Remove( cache );
				}
				else
				{
					i++;
				}
			}
			
			for( int i = 0; i < usedSeekers.Count; )
			{
				seeker = ( Seeker )usedSeekers[ i ];
				
				if( seeker.DoesUse( connection ) )
				{
					usedSeekers.Remove( seeker );
					seeker.Invalidate();
				}
				else
				{
					i++;
				}
			}
		}
Esempio n. 22
0
 private float HScore(ConnectionAsset connection)
 {
     return(Vector3.Distance(connection.To.Position, End.Position));
 }
Esempio n. 23
0
		public void OnRenderGizmos( Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection, bool onlySelectedConnection )
		{
			if( !onlySelectedConnection )
			{
				Gizmos.color = ( !networkSelected ) ? Color.yellow : ( nodeSelected ) ? Color.white : Color.green;
		    	Gizmos.DrawWireSphere( Position + transform.position + offset, radius );
			}
			
			foreach( ConnectionAsset connection in Connections )
			{
				Vector3 from, to, vector, fromOffsetA, fromOffsetB, toOffsetA, toOffsetB;
				
				if( onlySelectedConnection && selectedConnection != connection )
				{
					continue;
				}
				
				from = Position + transform.position + offset;
				to = connection.To.Position + transform.position + offset;
				vector = to - from;
				fromOffsetA = from + vector.normalized * ( connection.From as WaypointAsset ).Radius + Vector3.Cross( vector, Vector3.up ).normalized * -( connection.Width / 2.0f );
				fromOffsetB = from + vector.normalized * ( connection.From as WaypointAsset ).Radius + Vector3.Cross( vector, Vector3.up ).normalized * ( connection.Width / 2.0f );
				toOffsetA = to - vector.normalized * ( connection.To as WaypointAsset ).Radius + Vector3.Cross( vector, Vector3.up ).normalized * -( connection.Width / 2.0f );
				toOffsetB = to - vector.normalized * ( connection.To as WaypointAsset ).Radius + Vector3.Cross( vector, Vector3.up ).normalized * ( connection.Width / 2.0f );

				Gizmos.color = ( !networkSelected ) ? Color.yellow : ( selectedConnection == connection ) ? Color.white : Color.green;

				Gizmos.DrawLine( fromOffsetA, toOffsetA );
				Gizmos.DrawLine( fromOffsetB, toOffsetB );
			}
		}
Esempio n. 24
0
 private float HScore( ConnectionAsset connection )
 {
     return Vector3.Distance( connection.To.Position, End.Position );
 }
Esempio n. 25
0
		public override void OnRenderGizmos( Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection )
		{
			OnRenderGizmos( transform, standardMarkerSize, offset, networkSelected, nodeSelected, selectedConnection, false );
		}
Esempio n. 26
0
		public void OnDisabled( ConnectionAsset connection )
		{
			if( autoRecalculate )
			{
				RecalculateConnection( connection );
			}
		}
Esempio n. 27
0
 public override void OnRenderGizmos(Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection)
 {
     OnRenderGizmos(transform, standardMarkerSize, offset, networkSelected, nodeSelected, selectedConnection, false);
 }
Esempio n. 28
0
        public bool DoesUse( ConnectionAsset connection )
        {
            foreach( ConnectionAsset connectionAsset in Solution )
            {
                if( connectionAsset == connection )
                {
                    return true;
                }
            }

            return false;
        }
Esempio n. 29
0
        public override void OnRenderGizmos(Transform transform, float standardMarkerSize, Vector3 offset, bool networkSelected, bool nodeSelected, ConnectionAsset selectedConnection)
        {
            Gizmos.color = (!networkSelected) ? Color.yellow : (nodeSelected) ? Color.white : Color.green;

            Gizmos.DrawWireSphere(Position + transform.position + offset, standardMarkerSize);

            foreach (TriangleAsset triangle in triangles)
            {
                Gizmos.DrawLine(triangle.Points[0] + transform.position + offset, triangle.Points[1] + transform.position + offset);
                Gizmos.DrawLine(triangle.Points[1] + transform.position + offset, triangle.Points[2] + transform.position + offset);
                Gizmos.DrawLine(triangle.Points[2] + transform.position + offset, triangle.Points[0] + transform.position + offset);
            }

            // TODO: Draw polygon border
            // [17:47]  <AngryAnt> Ah right. I'm just thinking in vertices because thats the info I have available. So in that context it becomes: If only one triangle contains both vertices of an edge then the edge is on the border of the polygon?

            /*foreach( ConnectionAsset connection in Connections )
             * {
             *      Vector3 from, to, vector;
             *
             *      from = Position + transform.position + offset;
             *      to = connection.To.Position + transform.position + offset;
             *      vector = to - from;
             *
             *      Gizmos.color = ( !networkSelected ) ? Color.yellow : ( selectedConnection == connection ) ? Color.white : Color.green;
             *
             *      Gizmos.DrawLine( from + vector.normalized/* * waypoint.Radius* /,
             *              to - vector.normalized/* * ( connection.To as WaypointAsset ).Radius * /);
             *
             *      Gizmos.DrawLine( to - vector.normalized/* * ( connection.To as WaypointAsset ).Radius* /,
             *              to - vector.normalized * ( /*( connection.To as WaypointAsset ).Radius* /1.0f + /*connection.Width* /1.0f / 2.0f ) +
             *              Vector3.Lerp( ( Vector3.Cross( vector, Vector3.up ).normalized ),
             *              vector.normalized, 0.5f ) * /*connection.Width* /1.0f / 2.0f );
             *
             *      Gizmos.DrawLine( to - vector.normalized/* * ( connection.To as WaypointAsset ).Radius* /,
             *              to - vector.normalized * ( /*( connection.To as WaypointAsset ).Radius* /1.0f + /*connection.Width* /1.0f / 2.0f ) +
             *              Vector3.Lerp( ( Vector3.Cross( vector, Vector3.up ).normalized * -1.0f ),
             *              vector.normalized, 0.5f ) * /*connection.Width* /1.0f / 2.0f );
             * }*/
        }
Esempio n. 30
0
        public bool ValidConnection( ConnectionAsset connection )
        {
            if( !connection.Enabled ||								// Connection is disabled?
                !connection.To.Enabled ||							// Target is disabled?
                connection.Width < radius * 2.0f ||					// Seeker doesn't fit?
                !Valid( connection ) ||								// Tags of connection don't fit our seeker?
                !Valid( connection.To )								// Tags of target don't fit our seeker?
            )
            {
                return false;
            }

            return true;
        }