public void CalculateTotal() { if (_linkedEvent != null && _ticketSlider != null) { EconomyManager economyManager = Singleton <EconomyManager> .instance; CityEventXmlCosts costs = _linkedEvent.GetCosts(); totalCost = 0f; maxIncome = 0f; totalCost += costs._creation; totalCost += _ticketSlider.value * costs._perHead; maxIncome += _ticketSlider.value * costs._entry; if (_incentiveList != null) { FastList <object> optionItems = _incentiveList.rowsData; foreach (IncentiveOptionItem optionItemObject in optionItems) { totalCost += optionItemObject.cost * optionItemObject.sliderValue; maxIncome += optionItemObject.returnCost * optionItemObject.sliderValue; } } if (_costLabel != null) { _costLabel.text = totalCost.ToString(Settings.moneyFormat, LocaleManager.cultureInfo); _incomeLabel.text = maxIncome.ToString(Settings.moneyFormat, LocaleManager.cultureInfo); } if (_ticketSlider != null) { UIPanel sliderPanel = _ticketSlider.parent as UIPanel; UILabel sliderLabel = sliderPanel.Find <UILabel>("Label"); sliderLabel.text = string.Format(LocalisationStrings.EVENT_TICKETCOUNT, _ticketSlider.value); } if (_startTimeSlider != null) { UIPanel sliderPanel = _startTimeSlider.parent as UIPanel; UILabel sliderLabel = sliderPanel.Find <UILabel>("Label"); sliderLabel.text = string.Format(LocalisationStrings.EVENT_STARTTIMESLIDER, TimeOfDaySlider.getTimeFromFloatingValue(_startTimeSlider.value)); } if (_startDaySlider != null) { UIPanel sliderPanel = _startDaySlider.parent as UIPanel; UILabel sliderLabel = sliderPanel.Find <UILabel>("Label"); sliderLabel.text = string.Format(LocalisationStrings.EVENT_STARTDAYSLIDER, _startDaySlider.value); } if (_createButton != null) { int adjustedCost = Mathf.RoundToInt(totalCost * 100f); if (economyManager.PeekResource(EconomyManager.Resource.Construction, adjustedCost) != adjustedCost) { _createButton.Disable(); } else { _createButton.Enable(); } } } }