Ejemplo n.º 1
0
    public override GameObject GenerateAreaScenery(Terrain terrain)
    {
        var result = new GameObject(Name);

        // Generate trees taking buildings into consideration
        foreach (var areaData in AreaDataGraph.GetAllNodeData())
        {
            // Poisson filling
            PoissonDiskFillData poissonData =
                new PoissonDiskFillData(Trees, areaData.Polygon, TreeDistance, AngleTolerance, true);
            poissonData.AddClearPolygons(ClearPolygons);
            PoissonDataList.Add(poissonData);

            // Place arenas - skip start position
            if (areaData.Segment.Type == AreaSegment.EAreaSegmentType.Start)
            {
                continue;
            }

            var arena = PlaceArena(areaData, terrain);
            arena.transform.parent = result.transform;
        }


        return(result);
    }
Ejemplo n.º 2
0
    public override GameObject GenerateAreaScenery(Terrain terrain)
    {
        var result = new GameObject(Name);

        // Place lamps
        var lamps = PlaceStreetLamps(terrain);

        lamps.transform.parent = result.transform;

        // Place buildings
        var buildings = PlaceBuildings(terrain);

        buildings.transform.parent = result.transform;

        // Generate trees taking buildings into consideration
        foreach (var areaData in AreaDataGraph.GetAllNodeData())
        {
            // Poisson filling
            PoissonDiskFillData poissonData = new PoissonDiskFillData(Trees, areaData.Polygon, TreeDistance, TreeAngleTolerance, true);
            poissonData.AddClearPolygons(ClearPolygons);
            PoissonDataList.Add(poissonData);

            // Place arenas
            var arena = PlaceArena(areaData, terrain);
            arena.transform.parent = result.transform;
        }

        return(result);
    }
Ejemplo n.º 3
0
    public override GameObject GenerateAreaScenery(Terrain terrain)
    {
        var result = new GameObject(Name);
        var data   = AreaDataGraph.GetNodeData(0);

        // Create church
        var church = PlaceChurch(data);

        if (church)
        {
            church.transform.position += new Vector3(0, terrain.SampleHeight(church.transform.position), 0);
            church.transform.rotation  = terrain.GetNormalRotation(church.transform.position) * church.transform.rotation;
            church.CorrectAngleTolerance(AngleTolerance);
            church.transform.parent = result.transform;
        }

        // Place chest
        var chestPosition       = new Vector3(data.Center.x, 0, data.Center.y);
        var chestPositionHeight = chestPosition + new Vector3(0, terrain.SampleHeight(chestPosition), 0);
        var pathPosition        = new Vector3(data.Paths[0][0].x, 0, data.Paths[0][0].y);

        if ((pathPosition - chestPosition).sqrMagnitude < 1)
        {
            pathPosition = new Vector3(data.Paths[0][1].x, 0, data.Paths[0][1].y);
        }
        var chest = Object.Instantiate(ChestPrefab, chestPositionHeight, terrain.GetNormalRotation(chestPositionHeight) * Quaternion.LookRotation(pathPosition - chestPosition, Vector3.up));

        chest.transform.parent = result.transform;
        chest.GetComponent <ChestBossTrigger>().MiniBoss = MiniBosses[Random.Range(0, MiniBosses.Length)];

        // Place cemetary
        var cemetery = PlaceCemetery(data, terrain);

        cemetery.transform.parent = result.transform;

        // Fill spaces with trees
        PoissonDiskFillData poissonData = new PoissonDiskFillData(Trees, BorderPolygon.ToArray(), TreeDistance, TreeAngleTolerance, true);

        poissonData.AddClearPolygons(ClearPolygons);
        PoissonDataList.Add(poissonData);

        // Place arena
        PlaceArena(data, terrain).transform.parent = result.transform;

        return(result);
    }