Esempio n. 1
0
 /// <summary>
 /// Assigns references and begins the restore hydration process.
 /// </summary>
 void Start()
 {
     cachedTransform = transform;
     refugeeManager  = RefugeeManager.GetInstance();
     housingManager  = HousingManager.GetInstance();
     //StartCoroutine(RestoreHydrationUpdate(RefugeeManager.GetInstance().GetUpdateHealthTimer()));
 }
Esempio n. 2
0
    /// <summary>
    /// Waits for the construction to finish.
    /// </summary>
    /// <returns></returns>
    protected override IEnumerator BuildingConstructionBegin()
    {
        yield return(new WaitForTicks(constructionTime));

        HousingManager housingManager = HousingManager.GetInstance();
        float          distance;

        for (int i = 0; i < housingManager.GetHousesCount(); ++i)
        {
            distance = Vector3.Distance(housingManager.GetHouseAtIndex(i).cachedTransform.position, cachedTransform.position);
            if (distance < maxRadius)
            {
                housingManager.GetHouseAtIndex(i).AddWaterSource(health);
            }
        }
    }
Esempio n. 3
0
 /// <summary>
 /// Sets the refugees house that they live in. If they are in the HomelessHouse, it lets the housing manager know that they are homeless.
 /// </summary>
 /// <param name="_h">House to live in</param>
 public void SetHouse(Building _h)
 {
     if (_h == null)
     {
         SetNewDestination(GameManager.GetInstance().receptionCenter.cachedTransform.position);
         return;
     }
     if (_h.GetType() == typeof(HomelessHouse))
     {
         HousingManager.GetInstance().EnqueueHomeless(this);
     }
     else
     {
         house = (House)_h;
     }
     SetNewDestination(_h.cachedTransform.position);
 }
Esempio n. 4
0
    private IEnumerator ProcessAllRefugees()
    {
        while (true)
        {
            if (queue.Count == 0)
            {
                yield return(new WaitForTicks(1));
            }
            else
            {
                Refugee current = queue.Dequeue();
                current.SetNewDestination(lineStartPos);
                yield return(new WaitForTicks(timeToProcess));

                current.SetNewDestination(finishedProcessingPos);
                HousingManager.GetInstance().GetBestHouse().AddOccupant(current);
            }
        }
    }
Esempio n. 5
0
    /// <summary>
    /// Removes a refugee from this house.
    /// </summary>
    /// <returns>Refugee removed.</returns>
    public virtual Refugee RemoveOccupant()
    {
        if (GetOccupantCount() == 0)
        {
            Debug.LogError("No Occupants to remove");
            return(null);
        }

        Refugee _r = occupants[0];

        occupants.Remove(_r);
        _r.SetHouse(null);

        if (GetOccupantCount() < prefOccupancy)
        {
            HousingManager.GetInstance().AddBelowPrefOccupants(GetHashVal(), this);
            HousingManager.GetInstance().RemoveBelowMaxOccupants(GetHashVal());
        }
        else if (GetOccupantCount() < maxOccupancy)
        {
            HousingManager.GetInstance().AddBelowMaxOccupants(GetHashVal(), this);
        }
        return(_r);
    }
Esempio n. 6
0
    /// <summary>
    /// Adds occupant _r into this house.
    /// </summary>
    /// <param name="_r">Refugee to add to this house.</param>
    public virtual void AddOccupant(Refugee _r)
    {
        if (maxOccupancy == GetOccupantCount())
        {
            Debug.LogError(gameObject.name + " is already a full house.");
            return;
        }

        occupants.Add(_r);
        _r.SetHouse(this);
        if (GetOccupantCount() < prefOccupancy)
        {
            HousingManager.GetInstance().AddBelowPrefOccupants(GetHashVal(), this);
        }
        else if (GetOccupantCount() < maxOccupancy)
        {
            HousingManager.GetInstance().RemoveBelowPrefOccupants(GetHashVal());
            HousingManager.GetInstance().AddBelowMaxOccupants(GetHashVal(), this);
        }
        else
        {
            HousingManager.GetInstance().RemoveBelowMaxOccupants(GetHashVal());
        }
    }
Esempio n. 7
0
    /// <summary>
    /// Waits for construction to finish and tells the HousingManager that it is ready.
    /// </summary>
    /// <returns></returns>
    protected override IEnumerator BuildingConstructionBegin()
    {
        yield return(new WaitForTicks(constructionTime));

        HousingManager.GetInstance().NewHouseBuilt(this);
    }