Esempio n. 1
0
    NeedProvider GetClosestProvider(NeedType need)
    {
        NeedProvider closest = null;
        float dist = 0;

        NeedProvider[] provs = GameObject.FindObjectsOfType<NeedProvider>();
        foreach (NeedProvider p in provs)
        {
            if (p.need == need && !p.IsFull() && !p.myCultists.Contains(this))
            {
                Tile t = p.GetComponent<Tile>();

                float d = Mathf.Abs(t.Pos.y - transform.position.y);
                if (closest == null || d < dist)
                {
                    closest = p;
                    dist = d;
                }
            }
            else if (p.myCultists.Contains(this))
            {
                p.myCultists.Remove(this);
            }
        }

        return closest;
    }
Esempio n. 2
0
 public TerrainNeedSystem(NeedType needType = NeedType.Terrain) : base(needType)
 {
     EventManager.Instance.SubscribeToEvent(EventType.TerrainChange, () =>
     {
         this.isDirty = true;
     });
 }
Esempio n. 3
0
        public NeedType ResolveActiveNeed(NeedData needData)
        {
            NeedType currentNeed = needData.CurrentNeed;
            NeedType biggestNeed = needData.GetLeastSatisfied();

            bool biggestNeedShouldBecomeCurrent;

            if (currentNeed == NeedType.Default || currentNeed == biggestNeed)
            {
                biggestNeedShouldBecomeCurrent = true;
            }
            else
            {
                float       currentNeedSatisfaction = needData.GetSatisfaction(currentNeed);
                float       biggestNeedSatisfaction = needData.GetSatisfaction(biggestNeed);
                const float threshold           = 0.10f;
                bool        thresholdIsExceeded = currentNeedSatisfaction - biggestNeedSatisfaction > threshold;
                biggestNeedShouldBecomeCurrent = thresholdIsExceeded;
            }

            if (biggestNeedShouldBecomeCurrent)
            {
                currentNeed = biggestNeed;
            }
            return(currentNeed);
        }
 public ActionData(ActionType actType, ComponentType actTag, NeedType needType, bool requireNav) : this()
 {
     ActionType = actType;
     ActionTag  = actTag;
     NeedType   = needType;
     RequireNav = requireNav;
 }
Esempio n. 5
0
 public void UpdateNeedSystem(NeedType needType)
 {
     if (this.m_needSystems.ContainsKey(needType))
     {
         this.m_needSystems[needType].UpdateSystem();
     }
 }
Esempio n. 6
0
    void NeedsCheck()
    {
        if (foodLife >= 10)  // checkt of je eten nodig hebt
        {
            needType = NeedType.Food;
        }
        else if (drinkLife >= 10)  // checkt of je drinken nodig hebt
        {
            needType = NeedType.Drink;
        }
        else if (toiletLife >= 10) // checkt of je naar het toilet moet
        {
            needType = NeedType.Toilet;
        }


        switch (needType)                                                       //kijkt welke needtype het is
        {
        case NeedType.Drink:                                                    //denk aan, "in case...."
            navMeshAgent.SetDestination(CalculateDestination(typeof(Drink)));
            goingSomewhere = true;
            break;                                                              //na drink, is hij klaar met drinken, etc etc.

        case NeedType.Food:
            navMeshAgent.SetDestination(CalculateDestination(typeof(Food)));
            goingSomewhere = true;
            break;

        case NeedType.Toilet:
            navMeshAgent.SetDestination(CalculateDestination(typeof(Toilet)));
            goingSomewhere = true;
            break;
        }
    }
Esempio n. 7
0
 public Item(string name, int price, int value, NeedType usage = NeedType.Bellyful)
 {
     _name  = name;
     _price = price;
     _value = value;
     _usage = usage;
 }
Esempio n. 8
0
 public void setupNeedTracker(NeedType need)
 {
     if (IsNeedMet.ContainsKey(need))
     {
         return;
     }
     IsNeedMet.Add(need, false);
 }
Esempio n. 9
0
 protected BuildType(string title, Money cost, Money upkeep, NeedType serviceType, params ClientsAmount[] clientsData)
 {
     Title       = title;
     Cost        = cost;
     Upkeep      = upkeep;
     NeedType    = serviceType;
     ClientsData = clientsData;
 }
Esempio n. 10
0
    private NeedType OptionDataToNeedType(TMP_Dropdown.OptionData option)
    {
        int      endIndex  = option.text.IndexOf(suffix);
        string   substring = option.text.Substring(0, endIndex);
        NeedType need      = (NeedType)System.Enum.Parse(typeof(NeedType), substring);

        return(need);
    }
Esempio n. 11
0
    // Get all the food source on map with the type given
    private List <FoodSource> getFoodSourceByType(NeedType foodSourceType)
    {
        List <FoodSource> foodSources = new List <FoodSource>();

        // TODO: get all the food source on map by its type, `foodSourceType`.

        return(foodSources);
    }
Esempio n. 12
0
 public Need(NeedType type, ActivityType activity, float baseStepValue)
 {
     _type = type;
     SelectName();
     _baseStepValue = baseStepValue;
     _activity      = activity;
     StepValue      = _baseStepValue;
     Value          = 100f;
 }
Esempio n. 13
0
        public void ModifyNeedWithFactor(NeedType needType, NeedFactor needFactor, float delta)
        {
            float previousFactorValue          = _factors[needFactor];
            float satisfactionChangeFromFactor = delta - previousFactorValue;

            _factors[needFactor] = delta;

            _satisfactions[needType] += satisfactionChangeFromFactor;
        }
Esempio n. 14
0
 private ClientsAmount ServicedClients(NeedType needType)
 {
     return(_buildings
            .SelectMany(t => t.Services)
            .Where(t => t is CommonService)
            .Where(t => t.NeedType == needType)
            .Select(t => new ClientsAmount(t.ServicedMax))
            .Append(new ClientsAmount(0))
            .Sum());
 }
Esempio n. 15
0
 /// <summary>
 /// Returns the need of the NeedType provided or null if it doesn't exist.
 /// </summary>
 /// <param name="needType">The type of need to be searched for.</param>
 public Need GetNeed(NeedType needType)
 {
     foreach (Need need in Needs)
     {
         if (need.Type == needType)
         {
             return(need);
         }
     }
     return(null);
 }
Esempio n. 16
0
 private ClientsAmount ServicedClients(ClientType clientType, NeedType needType)
 {
     return(_buildings
            .SelectMany(t => t.Services)
            .Where(t => t is SpecialService)
            .Cast <SpecialService>()
            .Where(t => t.NeedType == needType)
            .Where(t => t.ClientType == clientType)
            .Select(t => clientType.CreateClients(t.ServicedMax))
            .Append(clientType.CreateClients(0))
            .Sum());
 }
Esempio n. 17
0
    public void SetNeedTypeValue(NeedType need)
    {
        int index = dropdown.options.FindIndex(x => OptionDataToNeedType(x) == need);

        // If the need was found in the list that set it to that found index
        if (index >= 0)
        {
            dropdown.value = index;
            dropdown.RefreshShownValue();
            OnDropdownValueChanged(index);
        }
    }
Esempio n. 18
0
    public void RegisterDemand(DemandHolder demand, NeedType type)
    {
        if (!demandCountDict.ContainsKey(type))
        {
            demandCountDict[type] = 0;
        }

        string demandID = type.ToString() + "_" + demandCountDict[type];

        demandDict[demandID] = demand;

        demandCountDict[type]++;
    }
Esempio n. 19
0
 private void OnDemandOverflowed(NeedType type)
 {
     /*foreach(var demand in demands)
      * {
      *      if(demand.DemandType == type)
      *      {
      *              currentDemand = demand;
      *              break;
      *      }
      * }
      *
      * SetTargetForPerson();*/
 }
Esempio n. 20
0
    public override void BeginExecution(StateData state, ActionKey action, Otto actor)
    {
        base.BeginExecution(state, action, actor);

        var inventory = state.GetTraitOnObjectAtIndex <Inventory>(action[1]);

        m_ConsumableType = inventory.ConsumableType;
        m_NeedType       = inventory.SatisfiesNeed;
        m_NeedReduction  = inventory.NeedReduction;

        m_Animator.SetTrigger(k_Consumables);
        m_Animator.SetTrigger(m_ConsumableType == ConsumableType.Apple ? k_EatFromPocket : k_DrinkFromPocket);
    }
Esempio n. 21
0
 public virtual void SatisfyNeed(float value, NeedType type)
 {
     if (curLevel > value)
     {
         curLevel -= value;
         curTime   = GetTimeFromNeedCurve(curLevel);
     }
     else
     {
         curLevel = 0;
         curTime  = 0;
     }
 }
Esempio n. 22
0
    /// <summary>
    /// Updates the value of a need to the provided value T returning true if successful and false if unsuccessful.
    /// </summary>
    /// <param name="needType">The type of the need to be searched for</param>
    /// <param name="value">The new value the need will have</param>
    public bool UpdateNeed <T>(NeedType needType, T value)
    {
        Need <T> need = (Need <T>)GetNeed(needType);

        if (need != null)
        {
            need.CurrentValue = value;
            return(true);
        }
        else
        {
            return(false);
        }
    }
Esempio n. 23
0
    public override void BeginExecution(Entity stateEntity, ActionContext action, Otto actor)
    {
        base.BeginExecution(stateEntity, action, actor);

        var ecsAction = action;
        var inventory = ecsAction.GetTrait <Inventory>(1);

        m_ConsumableType = inventory.ConsumableType;
        m_NeedType       = inventory.SatisfiesNeed;
        m_NeedReduction  = inventory.NeedReduction;

        m_Animator.SetTrigger(k_Consumables);
        m_Animator.SetTrigger(m_ConsumableType == ConsumableType.Apple ? k_EatFromPocket : k_DrinkFromPocket);
    }
Esempio n. 24
0
    private void OnEnable()
    {
        // Trigger the Sound
        SoundManager.Instance.m_doorOpen.PlaySound();

        //TODO: check their Account -> Needs the money tracking system

//        if (!hasAccount)
//        {
//            need = NeedType.makeAccount;
//        }
        _fundCheck    = AccountMoney;
        amDone        = false;
        introduced    = false;
        hapinessLevel = 5;

        //setup their action they want to do
        if (Random.Range(0, 100) > 95) //5 percent chance
        {
            need = NeedType.robbery;
        }
        else
        {
            var temp = Random.Range(0, 2); //int Rand.Range is exclusive
            need = (NeedType)temp;
        }
        action = need.ToString();

        //set the wait time to wait
        _maxTime = Random.Range(maxTimeRange.minValue, maxTimeRange.maxValue) * 2;

        //set money wanting to use
        //set money to use in range of wanting to use(difference!)
        _moneyWanting = (int)Random.Range(moneyToUse.minValue, moneyToUse.maxValue);
        _money        = _moneyWanting + Random.Range(-moneyRange, moneyRange + 1);

        // if the account has no money, they will change their action to deposit
        if (AccountMoney <= 1)
        {
            action = "deposit";
            return;
        }

        //if they want to withdraw/exchange/transfer and "money" is higher than the total
        //on their bank account, the total will be the new "money"
        if (need == NeedType.withdraw && AccountMoney < _money)
        {
            _money = AccountMoney;
        }
    }
Esempio n. 25
0
        public static ItemType GetMappingItemType(this NeedType needType)
        {
            switch (needType)
            {
            case NeedType.Hungry: return(ItemType.Food);

            case NeedType.Food: return(ItemType.Food);

            case NeedType.Thirst: return(ItemType.Water);

            case NeedType.Water: return(ItemType.Water);

            default: return(ItemType.Null);
            }
        }
Esempio n. 26
0
 public ItemSaveData(Item item)
 {
     localPos = item.transform.localPosition;
     if (item as SpecialItem)
     {
         var tmp = item as SpecialItem;
         type    = NeedType.Special;
         special = tmp.type;
     }
     else
     {
         var tmp = item as Feeder;
         type     = NeedType.Food;
         food     = tmp.type;
         capacity = tmp.capacity;
     }
 }
Esempio n. 27
0
        public void SetField(string fieldName, object value)
        {
            switch (fieldName)
            {
            case nameof(NeedType):
                NeedType = (NeedType)Enum.ToObject(typeof(NeedType), value);
                break;

            case nameof(Urgency):
                Urgency = (System.Int64)value;
                break;

            case nameof(ChangePerSecond):
                ChangePerSecond = (System.Int64)value;
                break;
            }
        }
Esempio n. 28
0
        public void SetField(string fieldName, object value)
        {
            switch (fieldName)
            {
            case nameof(ConsumableType):
                ConsumableType = (ConsumableType)Enum.ToObject(typeof(ConsumableType), value);
                break;

            case nameof(Amount):
                Amount = (System.Int64)value;
                break;

            case nameof(SatisfiesNeed):
                SatisfiesNeed = (NeedType)Enum.ToObject(typeof(NeedType), value);
                break;

            case nameof(NeedReduction):
                NeedReduction = (System.Int64)value;
                break;
            }
        }
Esempio n. 29
0
    public string GetNearestDemandHolder(Transform personPos, NeedType type)
    {
        float  delta    = 999999;
        string demandID = "";

        foreach (var pair in demandDict)
        {
            if (pair.Value.GetDemandType != type)
            {
                continue;
            }

            float tempDelta = (pair.Value.GetTransform.position - personPos.position).sqrMagnitude;
            if (tempDelta < delta)
            {
                delta    = tempDelta;
                demandID = pair.Key;
            }
        }

        return(demandID);
    }
Esempio n. 30
0
    // This function will be envoked when a food source is marked "dirty"
    public void updateFoodType(NeedType foodSourceType)
    {
        List <FoodSource> foodSources = getFoodSourceByType(foodSourceType);

        var ratingAndPopulationPair          = new SortedList();
        var foodSourceAndCanCosumePopulation = new Dictionary <FoodSource, List <AnimalPopulation> >();

        foreach (FoodSource foodSource in foodSources)
        {
            List <AnimalPopulation> animalPopulations = getPopulationsCanAccess(foodSource);
            List <AnimalPopulation> populationsThatCanConsumeFoodSource = getPopulationsThatConsumeFoodSource(animalPopulations, foodSource.Type);

            foodSourceAndCanCosumePopulation.Add(foodSource, populationsThatCanConsumeFoodSource);

            float competionRating = getCompetionRating(populationsThatCanConsumeFoodSource);
            ratingAndPopulationPair.Add(competionRating, foodSource);
        }

        foreach (DictionaryEntry pair in ratingAndPopulationPair)
        {
            distributeFoodSource((FoodSource)pair.Value, foodSourceAndCanCosumePopulation[(FoodSource)pair.Value]);
        }
    }
Esempio n. 31
0
    public void SufferFromNeed(Need playerNeed)
    {
        if (GameManager.Instance.hardMode)
        {
            GameManager.Instance.SetGameOverMessage(playerNeed.gameOverMessage);
            GameManager.Instance.gameState = GameState.GameOver;
            //GameManager.Instance.GameEnd();
            return;
        }

        NeedType needType = playerNeed.Type;

        switch (needType)
        {
        case NeedType.Energy:
            playerNeed.Points = 10;
            gameManager.Time  = 8;
            gameManager.DaysToDeadLine--;
            gameManager.LoadNextDay();
            break;

        case NeedType.Hunger:
            break;

        case NeedType.Fun:
            break;

        case NeedType.Hygiene:
            break;

        case NeedType.Mentality:
            break;

        default:
            break;
        }
    }
Esempio n. 32
0
	public static void ReportNeedComplete(NeedType needType){
		if (needType == NeedType.Coffee){
			instance.coffeeDrinked = true;
		}
		else if (needType == NeedType.Shower){
			instance.showerTook = true;
		}
        else if (needType == NeedType.Whisky)
        {
            Debug.Log("whisky drinked");
            instance.whiskyDrinked = true;
        }
        else if (needType == NeedType.Newspaper)
        {
            instance.newspaperRead = true;
        }
	}