예제 #1
0
    public void Initialize()
    {
        //add nodes and streets
        city.streetGraph.AddNode(new Vector3(0, 0, 0));
        city.streetGraph.AddNode(new Vector3(10, 0, 0));
        city.streetGraph.AddNode(new Vector3(-10, 0, 0));
        city.streetGraph.AddNode(new Vector3(0, 0, 10));
        city.streetGraph.AddNode(new Vector3(10, 0, 10));
        city.streetGraph.AddNode(new Vector3(-10, 0, 10));

        city.streetGraph.AddLine(city.streetGraph.corners[0], city.streetGraph.corners[1], 0);
        city.streetGraph.AddLine(city.streetGraph.corners[0], city.streetGraph.corners[2], 0);
        city.streetGraph.AddLine(city.streetGraph.corners[0], city.streetGraph.corners[3], 0);
        city.streetGraph.AddLine(city.streetGraph.corners[1], city.streetGraph.corners[4], 0);
        city.streetGraph.AddLine(city.streetGraph.corners[4], city.streetGraph.corners[3], 0);
        city.streetGraph.AddLine(city.streetGraph.corners[3], city.streetGraph.corners[5], 0);
        city.streetGraph.AddLine(city.streetGraph.corners[5], city.streetGraph.corners[2], 0);

        //add blocks
        List <Node> nodesBlockOne = new List <Node>()
        {
            city.streetGraph.corners [0],
            city.streetGraph.corners [3],
            city.streetGraph.corners [5],
            city.streetGraph.corners [2]
        };

        List <Node> nodesBlockTwo = new List <Node>()
        {
            city.streetGraph.corners [0],
            city.streetGraph.corners [3],
            city.streetGraph.corners [4],
            city.streetGraph.corners [1]
        };

        city.streetGraph.Render(traffic);

        var blockOne = new Block(nodesBlockOne)
        {
            lut = new Core(),
            historicalCenter = true
        };
        var blockTwo = new Block(nodesBlockTwo)
        {
            lut = new Core(),
            historicalCenter = true
        };

        blockOne.building.height    = 2f;
        blockOne.inhabitantCapacity = 10000;
        blockOne.UpdateBuilding();
        blockTwo.building.height    = 2f;
        blockTwo.inhabitantCapacity = 10000;
        blockTwo.UpdateBuilding();

        city.AddBlock(blockOne);
        city.AddBlock(blockTwo);
    }
예제 #2
0
    public void Initialize()
    {
        //add nodes and streets
        city.streetGraph.AddNode(new Vector3(0, 0, 0));
        city.streetGraph.AddNode(new Vector3(10, 0, 0));
        city.streetGraph.AddNode(new Vector3(-10, 0, 0));
        city.streetGraph.AddNode(new Vector3(0, 0, 10));
        city.streetGraph.AddNode(new Vector3(10, 0, 10));
        city.streetGraph.AddNode(new Vector3(-10, 0, 10));

        city.streetGraph.AddLine(city.streetGraph.corners [0], city.streetGraph.corners [1], 0);
        city.streetGraph.AddLine(city.streetGraph.corners [0], city.streetGraph.corners [2], 0);
        city.streetGraph.AddLine(city.streetGraph.corners [0], city.streetGraph.corners [3], 0);
        city.streetGraph.AddLine(city.streetGraph.corners [1], city.streetGraph.corners [4], 0);
        city.streetGraph.AddLine(city.streetGraph.corners [4], city.streetGraph.corners [3], 0);
        city.streetGraph.AddLine(city.streetGraph.corners [3], city.streetGraph.corners [5], 0);
        city.streetGraph.AddLine(city.streetGraph.corners [5], city.streetGraph.corners [2], 0);

        //add blocks
        List <Node> nodesBlockOne = new List <Node> ()
        {
            city.streetGraph.corners [0],
            city.streetGraph.corners [3],
            city.streetGraph.corners [5],
            city.streetGraph.corners [2]
        };

        List <Node> nodesBlockTwo = new List <Node> ()
        {
            city.streetGraph.corners [0],
            city.streetGraph.corners [3],
            city.streetGraph.corners [4],
            city.streetGraph.corners [1]
        };

        city.streetGraph.Render(traffic);

        var blockOne = new Block(nodesBlockOne)
        {
            lut = residential
        };
        var blockTwo = new Block(nodesBlockTwo)
        {
            lut = commercial
        };

        blockOne.UpdateBuilding();
        blockTwo.UpdateBuilding();

        city.AddBlock(blockOne);
        city.AddBlock(blockTwo);

        blockHelper.newBlocks.Add(blockOne);
        blockHelper.newBlocks.Add(blockTwo);
    }
예제 #3
0
    public void FindBlocks(Node start, int maxSize, int minSize)
    {
        List <Node> list = new List <Node>();

        for (int i = 0; i < start.neighbours.Count; i++)
        {
            list = FindCycle(start, start.neighbours[i], start, maxSize);

            if (list.Count >= minSize && !city.IsExistingBlock(list))
            {
                Block block = new Block(list);
                city.AddBlock(block);
                newBlocks.Add(block);
            }
        }
    }