예제 #1
0
 public void Populate(BezierMap bm, Map map)
 {
     // Debug.Log("saoehusnaoeh" + map.finish);
     // Debug.Log("aoeuaoeuaeo" + bm.trunk.pivots.Length);
     Instantiate(map.finish, bm.trunk.end, Quaternion.identity, transform);
     CircleSpawner cCircleSpawner;
     // int rnd;
     // foreach (Bezier bez in bm.branches) {
     //   cCircleSpawner = Instantiate(circleSpawner.gameObject, bez.start, Quaternion.identity, transform).GetComponent<CircleSpawner>();
     //   rnd = (int)Mathf.Clamp((map.ambushes.Length) * Random.value, 0f, map.ambushes.Length - 1f);
     //   cCircleSpawner.Construct(map.ambushes[rnd]);
     //   Instantiate(map.rewards[(int)((map.rewards.Length - 1) * Random.value)], bez.end, Quaternion.identity, transform);
     // }
 }
예제 #2
0
 public void Generate(Map map)
 {
     bm = new BezierMap(map);
     gm.Generate(bm, map);
     sm.Populate(bm, map);
 }
예제 #3
0
    public void Generate(BezierMap bm, Map map)
    {
        // references

        this.bm          = bm;
        this.trunkWidth  = map.trunkWidth;
        this.branchWidth = map.branchWidth;
        this.wallWidth   = map.wallWidth;
        this.precision   = map.precision;

        this.floorTile   = map.floorTile;
        this.wallTiles   = map.wallTiles;
        this.shadowTiles = map.shadowTiles;

        this.graftSize = map.graftSize;
        this.leafSize  = map.leafSize;
        this.rootSize  = map.rootSize;
        this.crownSize = map.crownSize;

        wallPositions.Clear();
        floorPositions.Clear();
        wallContours.Clear();

        walls.ClearAllTiles();
        floor.ClearAllTiles();
        decor.ClearAllTiles();

        // shaping

        BrushBezier(bm.trunk, wallPositions, trunkWidth + wallWidth, true);
        BrushBezier(bm.trunk, floorPositions, trunkWidth + wallWidth / 2, true);

        BrushPos(bm.trunk.start, wallPositions, rootSize + wallWidth, true);
        BrushPos(bm.trunk.start, floorPositions, rootSize + wallWidth / 2, true);

        BrushPos(bm.trunk.end, wallPositions, crownSize + wallWidth, true);
        BrushPos(bm.trunk.end, floorPositions, crownSize + wallWidth / 2, true);

        foreach (Bezier bez in bm.branches)
        {
            BrushBezier(bez, wallPositions, branchWidth + wallWidth, true);
            BrushBezier(bez, floorPositions, branchWidth + wallWidth / 2, true);

            BrushPos(bez.start, wallPositions, graftSize + wallWidth, true);
            BrushPos(bez.start, floorPositions, graftSize + wallWidth / 2, true);

            BrushPos(bez.end, wallPositions, leafSize + wallWidth, true);
            BrushPos(bez.end, floorPositions, leafSize + wallWidth / 2, true);
        }

        // paving

        BrushBezier(bm.trunk, wallPositions, trunkWidth, false);
        BrushPos(bm.trunk.start, wallPositions, rootSize, false);
        BrushPos(bm.trunk.end, wallPositions, crownSize, false);

        foreach (Bezier bez in bm.branches)
        {
            BrushBezier(bez, wallPositions, branchWidth, false);
            BrushPos(bez.start, wallPositions, graftSize, false);
            BrushPos(bez.end, wallPositions, leafSize, false);
        }

        wallContours = ContourPositions(wallPositions);

        MapContours(walls, wallContours, wallTiles);
        MapPositions(floor, floorPositions, floorTile);
        MapShadows(decor, wallContours, shadowTiles);
    }