Exemplo n.º 1
0
 public bool HasLinkTo(Townv2 to)
 {
     foreach (TownLink lnk in links)
     {
         if (lnk.IsLinkingTown(to))
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 2
0
 private void CreateTowns()
 {
     for (int i = 0; i < townDensity; i++)
     {
         Vector3    townPosition = new Vector3(Random.Range(0f, terrainGen.chunkSize.x * terrainGen.chunksX), 0f, Random.Range(0f, terrainGen.chunkSize.y * terrainGen.chunksZ));
         RaycastHit hit;
         if (terrainGen.DownRaycast(townPosition, out hit) && hit.point.y > terrainGen.waterLevel + terrainGen.shoreHeight && Vector3.Dot(Vector3.up, hit.normal) > townSlopeThreashold)
         {
             townPosition.y = hit.point.y;
             towns.Add(Townv2.CreateNew(this, townContainer.transform, townPosition, null));
         }
     }
 }
Exemplo n.º 3
0
        public static Townv2 CreateNew(TownGen gen, Transform parent, Vector3 position, GameObject debug)
        {
            GameObject go = new GameObject("Town");

            go.transform.SetParent(parent);
            go.transform.position = position;
            if (debug != null)
            {
                Instantiate(debug, go.transform).transform.localPosition = Vector3.zero;
            }
            Townv2 town = go.AddComponent <Townv2>();

            town.Init(gen);
            return(town);
        }
Exemplo n.º 4
0
 public Townv2 Other(Townv2 t)
 {
     return((t == town1) ? town2 : town1);
 }
Exemplo n.º 5
0
 public bool IsLinkingTown(Townv2 town)
 {
     return(town1 == town || town2 == town);
 }
Exemplo n.º 6
0
 public TownLink(Townv2 t1, Townv2 t2)
 {
     town1       = t1;
     town2       = t2;
     RoadCreated = false;
 }