public void HandleNegativeEvent(EventScriptableObj eventObj) { string numberText = ""; switch (eventObj.m_NegativeEventType) { case NegativeEventTypes.INCREASE_TEMPERATURE: { Temperature temperature = GameStats.Instance.m_Temperature; if (temperature == null) { return; } float increaseAmt = 0; if (eventObj.m_AffectedByPercentage) { increaseAmt = ((float)temperature.m_CurrTemperatureAmt * Random.Range(eventObj.m_MinMaxAffectedPercentages.x, eventObj.m_MinMaxAffectedPercentages.y)); } else { increaseAmt = Random.Range(eventObj.m_MinMaxAffectedAmount.x, eventObj.m_MinMaxAffectedAmount.y); } temperature.AddToTemperatureOffset(-increaseAmt); numberText = "Temperature slightly increased."; } break; case NegativeEventTypes.DECREASE_POPULARITY: { Popularity popularity = GameStats.Instance.m_Popularity; if (popularity == null) { return; } int decreaseAmt = 0; if (eventObj.m_AffectedByPercentage) { decreaseAmt = (int)((float)popularity.m_CurrentPopularity * Random.Range(eventObj.m_MinMaxAffectedPercentages.x, eventObj.m_MinMaxAffectedPercentages.y)); } else { decreaseAmt = (int)Random.Range(eventObj.m_MinMaxAffectedAmount.x, eventObj.m_MinMaxAffectedAmount.y); } numberText = decreaseAmt.ToString(); popularity.UpdatePopularityOffset(-decreaseAmt); } break; case NegativeEventTypes.LOSE_MONEY: { Money money = GameStats.Instance.m_Money; if (money == null) { return; } int decreaseAmt = 0; if (eventObj.m_AffectedByPercentage) { decreaseAmt = (int)((float)money.m_CurrMoney * Random.Range(eventObj.m_MinMaxAffectedPercentages.x, eventObj.m_MinMaxAffectedPercentages.y)); } else { decreaseAmt = (int)Random.Range(eventObj.m_MinMaxAffectedAmount.x, eventObj.m_MinMaxAffectedAmount.y); } numberText = "$" + decreaseAmt.ToString(); money.ReduceMoney(decreaseAmt); } break; case NegativeEventTypes.EVIL_COOPERATE: { //THIS EVENT CAN ONLY HAPPEN WHEN THERE ARE TREES if (MapManager.Instance.GetTotalAmtOfTreeOnMap() == 0) { return; } int numberToSpawn = (int)Random.Range(eventObj.m_MinMaxAffectedAmount.x, eventObj.m_MinMaxAffectedAmount.y); for (int i = 0; i < numberToSpawn; ++i) { NPCManager.Instance.SpawnEvilPeople(); } } break; } ++m_EventNumberInAMonth; ++m_NumberOfBadEventsInAMonth; UpdateUI(eventObj, numberText); SoundManager.Instance.Play("UnsuccessfulFund"); }
public void HandlePositiveEvents(EventScriptableObj eventObj) { string numberText = ""; switch (eventObj.m_PositiveEventType) { case PositiveEventTypes.DECREASE_TEMPERATURE: { Temperature temperature = GameStats.Instance.m_Temperature; if (temperature == null) { return; } float decreaseAmt = 0; if (eventObj.m_AffectedByPercentage) { decreaseAmt = ((float)temperature.m_CurrTemperatureAmt * Random.Range(eventObj.m_MinMaxAffectedPercentages.x, eventObj.m_MinMaxAffectedPercentages.y)); } else { decreaseAmt = Random.Range(eventObj.m_MinMaxAffectedAmount.x, eventObj.m_MinMaxAffectedAmount.y); } temperature.AddToTemperatureOffset(decreaseAmt); numberText = "Temperature slightly decreased."; } break; case PositiveEventTypes.GET_MONEY: { Money money = GameStats.Instance.m_Money; if (money == null) { return; } int increaseAmt = 0; if (eventObj.m_AffectedByPercentage) { increaseAmt = (int)((float)money.m_CurrMoney * Random.Range(eventObj.m_MinMaxAffectedPercentages.x, eventObj.m_MinMaxAffectedPercentages.y)); } else { increaseAmt = (int)Random.Range(eventObj.m_MinMaxAffectedAmount.x, eventObj.m_MinMaxAffectedAmount.y); } numberText = "$" + increaseAmt.ToString(); money.IncreaseMoney(increaseAmt); } break; case PositiveEventTypes.INCREASE_POPULARITY: { Popularity popularity = GameStats.Instance.m_Popularity; if (popularity == null) { return; } int increaseAmt = 0; if (eventObj.m_AffectedByPercentage) { increaseAmt = (int)((float)popularity.m_CurrentPopularity * Random.Range(eventObj.m_MinMaxAffectedPercentages.x, eventObj.m_MinMaxAffectedPercentages.y)); } else { increaseAmt = (int)Random.Range(eventObj.m_MinMaxAffectedAmount.x, eventObj.m_MinMaxAffectedAmount.y); } numberText = increaseAmt.ToString(); popularity.UpdatePopularityOffset(increaseAmt); } break; } ++m_EventNumberInAMonth; UpdateUI(eventObj, numberText); SoundManager.Instance.Play("successfulFund"); }