Ejemplo n.º 1
0
        /// <summary>
        /// Define the road and cross section
        /// </summary>
        /// <param name="couveSize">The size off set</param>
        /// <param name="index">The road index</param>
        /// <param name="roadNetworkNode">The main road node</param>
        /// <param name="road">The rode node to populate</param>
        /// <param name="crossSection">The cross section to populate</param>
        public static void DefineCrossSectionOffSet(float couveSize, int index, RoadNetworkNode roadNetworkNode, out RoadNetworkNode road, out RoadCrossSection crossSection)
        {
            road = roadNetworkNode.Details.Roads[index];
            Vector3 pos        = roadNetworkNode.gameObject.transform.position;
            float   angleA     = RoadUnionHelper.AngleClamp(RoadUnionHelper.GetAngleOfRoad(roadNetworkNode, index) + (Mathf.PI / 2));
            Vector3 roadPointA = road.GetOffSetDownRoad(pos, (RoadConstructorHelper.CrossSectionDetails.RoadWidthValue * couveSize));

            crossSection = new RoadCrossSection(roadPointA, angleA - (float)(Math.PI / 2), RoadConstructorHelper.CrossSection(road), RoadConstructorHelper.Materials(road));
        }
        /// <summary>
        /// Created the intersections of the roads
        /// </summary>
        /// <param name="roadBuilderObject">The road builder object</param>
        public void CreateLayout(RoadBuilder roadBuilderObject)
        {
            float   angleRoadStart = RoadUnionHelper.AngleClamp(RoadUnionHelper.GetAngleOfRoad(_roadNetworkNode, 0));
            Vector3 pos            = _roadNetworkNode.transform.position;

            ICrossSection sc = _roadNetworkNode.gameObject.GetComponent <ICrossSection>();

            if (sc == null)
            {
                sc = RoadConstructorHelper.CrossSectionDetails;
            }

            IMaterialFrequency mf = _roadNetworkNode.gameObject.GetComponent <IMaterialFrequency>();

            if (mf == null)
            {
                mf = RoadConstructorHelper.MaterialFrequencySet;
            }

            RoadCrossSection rA = new RoadCrossSection(pos, angleRoadStart, sc, mf);

            StreetManager.Instance.AddStreetEnd(_roadNetworkNode.name, _roadNetworkNode.Details.Roads[0].name, sc, mf, rA);
        }