Edge.getDirection C# (CSharp) Method

getDirection() public method

public getDirection ( ) : bool
return bool
	public bool getDirection ()
	{
		if (A.X == B.X)
			return true;
		else {
			return false;
		}
	}
}

Usage Example

Example #1
0
    public override void branchHighwayToHighway(ref List <Edge> branches, Edge oldEdge)
    {
        // Generate a spectrum of rays in a generally forward direction, and pick the ray with the highest population.
        Vector2 startVector  = new Vector2(oldEdge.n2.x, oldEdge.n2.y);
        Vector2 oldDirection = oldEdge.getDirection();

        /// Going straight ///
        List <Vector2> rays = this.castVectorsFromPoint(
            startVector, oldDirection,
            -CG.highwayStraightAngle,
            CG.highwayStraightAngle,
            RoadTypes.HIGHWAY, CG.rayCount);

        KeyValuePair <Vector2, float> rayAndPopulation = this.getBestRay(startVector, rays, RoadTypes.HIGHWAY);

        if (rayAndPopulation.Value > CG.highwayPopThreshold)
        {
            branches.Add(new Edge(oldEdge.n2, new Node(rayAndPopulation.Key.x, rayAndPopulation.Key.y),
                                  RoadTypes.HIGHWAY, oldEdge.getTime() + CG.highwayPriority));
        }

        /// Branch to left ///
        /// if CG.highwayBranchProbability is high then the highways will branch a lot
        /// SUGGESTED: LOW VALUES
        List <Vector2> leftRays = this.castVectorsFromPoint(
            startVector, oldDirection,
            -CG.highwayBranchAngle - CG.highwayStraightAngle,
            -CG.highwayBranchAngle + CG.highwayStraightAngle,
            RoadTypes.HIGHWAY, CG.rayCount);

        KeyValuePair <Vector2, float> leftRayAndPopulation = this.getBestRay(startVector, leftRays, RoadTypes.HIGHWAY);

        if (leftRayAndPopulation.Value > CG.highwayPopThreshold &&
            Random.value < CG.highwayBranchProb)
        {
            branches.Add(new Edge(oldEdge.n2, new Node(leftRayAndPopulation.Key.x, leftRayAndPopulation.Key.y),
                                  RoadTypes.HIGHWAY, oldEdge.getTime() + CG.highwayPriority));
        }

        /// Branch to right
        /// SUGGESTED: LOW VALUES
        List <Vector2> rightRays = this.castVectorsFromPoint(
            startVector, oldDirection,
            CG.highwayBranchAngle - CG.highwayStraightAngle,
            CG.highwayBranchAngle + CG.highwayStraightAngle,
            RoadTypes.HIGHWAY, CG.rayCount);

        KeyValuePair <Vector2, float> rightRayAndPopulation = this.getBestRay(startVector, rightRays, RoadTypes.HIGHWAY);

        if (rightRayAndPopulation.Value > CG.highwayPopThreshold &&
            Random.value < CG.highwayBranchProb)
        {
            branches.Add(new Edge(
                             oldEdge.n2, new Node(rightRayAndPopulation.Key.x, rightRayAndPopulation.Key.y),
                             RoadTypes.HIGHWAY, oldEdge.getTime() + CG.highwayPriority));
        }
    }
All Usage Examples Of Edge::getDirection