예제 #1
0
        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);
                }
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
 public void AddEventToFront(EventWrapper wrapper)
 {
     eventQueue.PushFront(wrapper);
 }
예제 #4
0
 public void PushEvent(EventWrapper wrapper)
 {
     eventQueue.PushBack(wrapper);
 }
예제 #5
0
 public static bool NeverTrigger(this EventWrapper wrapper)
 => wrapper.Probability < Tolerance;
예제 #6
0
 public static bool AlwaysTrigger(this EventWrapper wrapper)
 => 1 - wrapper.Probability < Tolerance;