Exemple #1
0
    public void SpawnImmigrant(Node start, Structure requester, Prole immigrant)
    {
        //by the way: it's way easier to deal with the starting point as a node than a structure, especially because we don't need to know where the immigrant came from
        //	no matter how weird that we instantiate 'end' here but not 'start'

        Queue <Node> path = new Pathfinder(worldController.Map).FindPath(start, new Node(requester), "Immigrant");

        if (path.Count == 0)
        {
            return;
        }

        GameObject go = worldController.SpawnObject("Walkers", "Immigrant", start);

        Walker w = go.GetComponent <Walker>();

        w.world       = worldController;
        w.Destination = requester;
        w.SetPath(path);
        w.SetPersonData(immigrant);               //data for immigrant moving into house
        w.Activate();

        immigrant.EvictHouse(false);          //quit current house if they have one, but don't quit work because they're still here
        if (immigrant.Employed)
        {
            immigrant.QuitWork();
        }
    }
Exemple #2
0
    public void SpawnEmigrant(Node start, Prole emigrant)
    {
        GameObject mapEntrance = GameObject.FindGameObjectWithTag("MapEntrance");

        if (mapEntrance == null)
        {
            return;
        }

        Node end = new Node(mapEntrance.GetComponent <Structure>());

        Queue <Node> path = new Pathfinder(worldController.Map).FindPath(start, end, "Emigrant");

        if (path.Count == 0)
        {
            return;
        }

        GameObject go = worldController.SpawnObject("Walkers", "Emigrant", start);
        //GameObject go = Instantiate(Resources.Load<GameObject>("Walkers/Emigrant"));
        //go.transform.position = mapExit.transform.position;
        //go.name = "Emigrant";

        Walker w = go.GetComponent <Walker>();

        w.world       = worldController;
        w.Destination = mapEntrance.GetComponent <Structure>();
        w.SetPersonData(emigrant);
        w.SetPath(path);
        w.Activate();

        //evict house at the very end to remove homeNode and remove prole data from house
        //quit job too because they're leaving the city
        emigrant.EvictHouse(false);
        emigrant.QuitWork();
        //RemoveResidents(ExcessResidents);
    }