Exemple #1
0
    public void Bisect()
    {
        if (_isFinal)
        {
            FindSidewalkNLotVerts();
            //CityMapManager.Instance.AddRoad(this);
            CityMapManager.Instance.AddSidewalk(this);
            initialLot = new BuildingLot(this);
            if (initialLot.isFinal())
            {
                initialLot.freeEdges.AddRange(new int[] { 0, 1, 2, 3 });
                finalLots.Add(initialLot);
            }
            else
            {
                CreateBuildingLots();
            }

            CityMapManager.Instance.Add(this);
            return;
        }

        var big_offset = Random.Range(0f, _divergence * edges[0].length) * edges[0].direction;

        if (Util.RollDice(new float[] { 0.5f, 0.5f }) == 1)
        {
            big_offset *= -1;
        }
        var opp_offset = Random.Range(0f, _divergence * edges[2].length) * edges[2].direction;

        if (Util.RollDice(new float[] { 0.5f, 0.5f }) == 1)
        {
            opp_offset *= -1;
        }

        Block b1 = new Block(edges[3].start, edges[3].end,
                             edges[0].middle + big_offset, edges[2].middle + opp_offset);

        b1.Bisect();
        Block b2 = new Block(edges[1].start, edges[1].end,
                             edges[2].middle + opp_offset, edges[0].middle + big_offset);

        b2.Bisect();
    }