public bool HasLinkTo(Townv2 to) { foreach (TownLink lnk in links) { if (lnk.IsLinkingTown(to)) { return(true); } } return(false); }
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)); } } }
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); }
public Townv2 Other(Townv2 t) { return((t == town1) ? town2 : town1); }
public bool IsLinkingTown(Townv2 town) { return(town1 == town || town2 == town); }
public TownLink(Townv2 t1, Townv2 t2) { town1 = t1; town2 = t2; RoadCreated = false; }