Esempio n. 1
0
 private void GenerateRandomRoads(int nbRoads, float minLength, float maxLength, float width)
 {
     for (int i = 0; i < nbRoads; i++)
     {
         float    distance = Random.Range(minLength, maxLength);
         float    angle    = Random.Range(0f, 360f);
         Vector3  nJuncPos = Quaternion.Euler(0f, angle, 0f) * (Vector3.right * distance);
         Junction nJunc    = CreateNew(transform.parent, nJuncPos);
         Road     road     = Road.CreateNew(transform.parent, this, nJunc, width);
     }
 }
Esempio n. 2
0
        private Dictionary <Orientation, Junction> GenerateLinearRoads(Town town, Orientation exclude, float minLength, float maxLength, float width)
        {
            Dictionary <Orientation, Junction> createdJuncs = new Dictionary <Orientation, Junction>();

            for (int i = 0; i < 4; i++)
            {
                if ((Orientation)i == exclude)
                {
                    continue;
                }
                float    distance = Random.Range(minLength, maxLength);
                Vector3  nJuncPos = transform.localPosition + Quaternion.Euler(0f, 90 * i, 0f) * (Vector3.forward * distance);
                Junction nJunc    = CreateNew(transform.parent, nJuncPos);
                Road     road     = Road.CreateNew(transform.parent, this, nJunc, width);
                createdJuncs.Add((Orientation)i, nJunc);
            }
            return(createdJuncs);
        }
Esempio n. 3
0
        public void CreateRoadTo(Junction junc, float width, bool followGround, float subdivDistance, TerrainGen terrain)
        {
            Road road = Road.CreateNew(transform.parent, this, junc, width, followGround, subdivDistance, terrain);

            roads.Add(road);
        }