private void SetCurrentEvent(EventWrapper wrapper) { continueButton.gameObject.SetActive(false); resultWrapper = null; eventWrapper = wrapper; var sobj = wrapper.Sobj; title.text = sobj.readableName; mainDesc.text = sobj.mainDescription; mainImage.sprite = sobj.mainImage; optionList.gameObject.SetActive(true); var numOpts = sobj.options.Length; if (numOpts == 0) { NextEvent(); } else { options = new EventOptionUI[numOpts]; for (var i = 0; i < numOpts; ++i) { CreateOption(sobj.options[i], i); } } }
public static bool TryTrigger(this EventWrapper wrapper) { if (wrapper.AlwaysTrigger()) { return(true); } if (wrapper.NeverTrigger()) { return(false); } var rand = Random.Range(.0f, 1); return(rand < wrapper.Probability); }
public void AddEventToFront(EventWrapper wrapper) { eventQueue.PushFront(wrapper); }
public void PushEvent(EventWrapper wrapper) { eventQueue.PushBack(wrapper); }
public static bool NeverTrigger(this EventWrapper wrapper) => wrapper.Probability < Tolerance;
public static bool AlwaysTrigger(this EventWrapper wrapper) => 1 - wrapper.Probability < Tolerance;