public void ShowEventOptions(List <Event.Option> options) { // disable normal 'continue' button endTurnButton.SetActive(false); // show option buttons for (int i = 0; i < options.Count; i++) { Event.Option option = options[i]; Debug.Log(option.copy); Button optionButton = CreateOptionButton(option.copy).GetComponent <Button>(); // Tell the button what to do when we press it optionButton.onClick.AddListener(delegate { OnClickOptionButton(option); }); } }
// enact that option void OnClickOptionButton(Event.Option option) { // // set option event as next event // Game.Instance.nextEvent = option.outcomeEvent; RefreshUI(); // play option event ? if (option.outcomeEvent) { Game.Instance.PlayEvent(option.outcomeEvent); } else { Debug.Log("no option event for option: " + option.copy); Game.Instance.Endturn(); } }
public void ExecuteOption(Event eventInfo, Event.Option option, float?paymentOverride = null, bool notify = true) { if (option.payment != null || paymentOverride.HasValue) { float amount = paymentOverride.HasValue ? Mathf.Abs(paymentOverride.Value) : option.payment.GetAmount(moneyTracker); bool isCharge = paymentOverride.HasValue ? (paymentOverride.Value < 0) : option.payment.isCharge; if (isCharge) { moneyTracker.SpendMoney(amount); if (notify) { OnEventExecuted.Invoke(eventInfo, -amount, timeTracker.currentTime); } } else { moneyTracker.GainMoney(amount); if (notify) { OnEventExecuted.Invoke(eventInfo, amount, timeTracker.currentTime); } } } foreach (Event.CalendarOutcome calendarOutcome in option.eventsToAddToCalendar) { calendar.Add(calendarOutcome); } foreach (Event.PoolOutcome poolOutcome in option.eventsToAddToPool) { pool.Add(poolOutcome); } foreach (Event eventType in option.eventTypesToRemoveFromCalendar) { calendar.RemoveType(eventType); } foreach (Event eventType in option.eventTypesToRemoveFromPool) { pool.RemoveType(eventType); } }