예제 #1
0
    public void lookForHome()
    {
        if (!isLookingForHouse)
        {
        }
        setIsLookingForHousing(true);
        if (getTownCurrentlyInsideOf())
        {
            if (getTownCurrentlyInsideOf().getTownAttractivnes() > 20)
            {
                if (getTownCurrentlyInsideOf().getAvailableResidentialBuildingsInTown().Count != 0)
                {
                    setHouse(getTownCurrentlyInsideOf().getAvailableResidentialBuildingsInTown()[Random.Range(0, getTownCurrentlyInsideOf().getAvailableResidentialBuildingsInTown().Count)]);
                    setIsLookingForHousing(false);
                    home.addResidentToBuilding(this);
                    setTownAlliegence(home.getTownBuildingIsApartOf());
                    StartCoroutine(townAlliegence.waitForCitizenToLoadThenAdd(this));

                    townAlliegence.updateAvailableResidentialBuildingsInTown();
                    townAlliegence.updateHomelessInTown();
                }
                else
                {
                    //Debug.Log("No more housing");
                }
            }
        }
        else
        {
            gameManager.getTownCatalog().getNearestTown();
            // Get nearest town with attractivnes over 20?
        }
    }