Beispiel #1
0
    private void CheckFavoriteBuildings()
    {
        if (m_favoriteBuildings == null)
        {
            return;
        }

        int templId = 0;

        if (m_workplace != Guid.Empty)
        {
            templId = M_BuildingManager.SGetTemplIdFromBuilding(m_workplace);
        }

        for (int i = 0; i < m_favoriteBuildings.Count; i++)
        {
            FavoriteBuilding fav = m_favoriteBuildings[i];


            if (!fav.active && fav.buildingTemplId == templId)
            {
                fav.active      = true;
                fav.currentDays = 0;
                fav.currentMood = 0;
            }
            else if (fav.active && fav.buildingTemplId != templId)
            {
                fav.active      = false;
                fav.currentMood = 0;
            }
        }
    }
Beispiel #2
0
    /// <summary> Creates a new settler </summary>
    /// <returns>Guid of a new settler</returns>
    public Guid CreateSettler(Guid houseId)
    {
        Settler settler = new Settler(houseId);

        settler.SetName(GetRandName());
        settler.SetPortrait(GetRandPortrait());

        List <FavoriteBuilding> favoriteBuildings = new List <FavoriteBuilding>();
        List <FavoriteWare>     favoriteWares     = new List <FavoriteWare>();
        int FAVORITE_BUILDINGS = 3;
        int FAVORITE_WARES     = 3;

        M_BuildingManager.SEnableUniqueRandomizing(FAVORITE_BUILDINGS);
        for (int i = 0; i < FAVORITE_BUILDINGS; i++)
        {
            FavoriteBuilding temp = new FavoriteBuilding();
            temp.maxMood         = 20;
            temp.buildingTemplId = M_BuildingManager.SGetRandProductionBuildingTempl();
            temp.active          = false;
            favoriteBuildings.Add(temp);
        }


        M_WaresManager.SEnableUniqueWareRandomizing(FAVORITE_WARES);
        for (int i = 0; i < FAVORITE_WARES; i++)
        {
            FavoriteWare temp = new FavoriteWare();
            temp.mood   = UnityEngine.Random.Range(10, 21);;
            temp.ware   = M_WaresManager.SGetRandWare();
            temp.active = false;
            favoriteWares.Add(temp);
        }

        settler.SetFavoriteBuildings(favoriteBuildings);
        settler.SetFavortiteWares(favoriteWares);


        m_settlers.Add(settler);
        Debug.Log("CreateSettler id: " + settler.GetId());
        return(settler.GetId());
    }