Пример #1
0
    public int CalPopulation()
    {
        int population = 0;

        foreach (GameObject house in houses)
        {
            PeopleInitiator peopleInitScript = house.GetComponent <PeopleInitiator>();
            population += peopleInitScript.GetPplPerHouse();
        }
        return(population);
    }
    /* This is the method that is used to initialize the workplace and house coordinates by the agent's house object. */
    public void Setup(GameObject house_p, GameObject workPlace_p, float inHouseRange_p)
    {
        house = house_p;
        PeopleInitiator peopleInitiatorScript = house.GetComponent <PeopleInitiator>();

        house_startRoad = peopleInitiatorScript.startRoad;
        house_x         = peopleInitiatorScript.startPos.x;
        house_z         = peopleInitiatorScript.startPos.z;

        workPlace = workPlace_p;
        WorkPlace workPlaceScript = workPlace.GetComponent <WorkPlace>();

        workplace_startRoad = workPlaceScript.nearestRoad;
        workplace_x         = workPlaceScript.addressOnRoad.x;
        workplace_z         = workPlaceScript.addressOnRoad.z;

        inHouseRange = inHouseRange_p;
    }