示例#1
0
    private void CreateHouseInPosition(Vector3 position)
    {
        if (SurfaceManager.IsWater(surface, position))
        {
            return;
        }

        position.y = SurfaceManager.GetSurfaceHeight(surface, position);
        float dir = (int)position.sqrMagnitude % 4 * 90;

        GameObject house = Instantiate(housesModels[Random.Range(0, housesModels.Length)],
                                       position, Quaternion.AngleAxis(dir, Vector3.up));

        house.transform.parent = transform;
        house.tag      = "House";
        house.isStatic = true;
    }
示例#2
0
 private bool CouldTreeSpawnIn(Vector3 randomPos)
 {
     return(randomPos.y < maxHeight &&
            !SurfaceManager.IsWater(surface, randomPos) &&
            randomPos.y > SurfaceManager.WaterHeight(surface) + minHeight &&
            !cities.cities.Any((CityGenerator.City city) =>
     {
         Vector3 pos = randomPos;
         pos.y = city.region.bounds.center.y;
         return city.region.bounds.Contains(pos);
     }) &&
            !noTreesRegions.Any((BoxCollider box) =>
     {
         Vector3 pos = randomPos;
         pos.y = box.bounds.center.y;
         return box.bounds.Contains(pos);
     }));
 }