예제 #1
0
 /// <summary>
 /// Updates running events and checks if a new event should be started
 /// </summary>
 public void Update()
 {
     if (m_CurrentEvent == null)
     {
         if (elapsed >= checkEvents)
         {
             IEnumerable <KeyValuePair <double, WorldEvent> > aviableEvents = m_WorldEvents.Where(ev => ev.Value.PrerequisitesMet());
             foreach (KeyValuePair <double, WorldEvent> ev in aviableEvents)
             {
                 float probability = UnityEngine.Random.Range(0, 100) / 100f;
                 if (probability <= ev.Key)
                 {
                     m_CurrentEvent = ev.Value;
                     m_CurrentEvent.Start();
                     break;
                 }
             }
             elapsed = 0;
         }
         elapsed += Time.deltaTime;
     }
     else
     {
         m_CurrentEvent.Update();
     }
 }
예제 #2
0
 /// <summary>
 /// Recieves the Event Done Event and sets the current event to null
 /// </summary>
 /// <param name="sender">The event sending that it is done</param>
 private void EventDone(WorldEvent sender)
 {
     m_CurrentEvent = null;
 }