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]++; }
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; } }
void Start() { GetComponent <TextShowner>().text = type.ToString(); tr = GetComponent <Transform>(); FindObjectOfType <DemandKeeper>().RegisterDemand(this, type); }