public QueuedMessage(List<String> messages, int secondsDelay, AbstractEvent abstractEvent)
 {
     if (messages != null && messages.Count > 0)
     {
         this.messagesBeforeTimeSpan.AddRange(messages);
     }
     this.dueTime = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) + (secondsDelay * 1000) + updateInterval;
     this.abstractEvent = abstractEvent;
 }
 public QueuedMessage(String messageBeforeTimeSpan, String messageAfterTimeSpan, TimeSpan timeSpan, int secondsDelay, AbstractEvent abstractEvent)
 {
     if (messageBeforeTimeSpan != null)
     {
         this.messagesBeforeTimeSpan.Add(messageBeforeTimeSpan);
     }
     if (messageAfterTimeSpan != null)
     {
         this.messagesAfterTimeSpan.Add(messageAfterTimeSpan);
     }
     this.timeSpan = timeSpan;
     timeSpanSet = true;
     this.dueTime = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) + (secondsDelay * 1000) + updateInterval;
     this.abstractEvent = abstractEvent;
 }
 // used for creating a pearl of wisdom message where we need to copy the dueTime from the original
 public QueuedMessage(AbstractEvent abstractEvent)
 {
     this.abstractEvent = abstractEvent;
 }
 public QueuedMessage(int secondsDelay, AbstractEvent abstractEvent)
 {
     this.dueTime = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) + (secondsDelay * 1000) + updateInterval;
     this.abstractEvent = abstractEvent;
 }
 // we pass in the event which triggered this clip so that we can query the event before playing the
 // clip to check if it's still valid against the latest game state. This is necessary for clips queued
 // with non-zero delays (e.g. you might have crossed the start / finish line between the clip being
 // queued and it being played)
 public void queueClip(String eventName, int secondsDelay, AbstractEvent abstractEvent,
     PearlsOfWisdom.PearlType pearlType, double pearlMessageProbability)
 {
     queueClip(eventName, new QueuedMessage(secondsDelay, abstractEvent), pearlType, pearlMessageProbability);
 }
 public void queueClip(String eventName, int secondsDelay, AbstractEvent abstractEvent)
 {
     queueClip(eventName, secondsDelay, abstractEvent, PearlsOfWisdom.PearlType.NONE, 0);
 }
Example #7
0
 private void triggerEvent(String eventName, AbstractEvent abstractEvent, Shared lastState, Shared currentState)
 {
     try
     {
         abstractEvent.trigger(lastState, currentState);
     }
     catch (Exception e)
     {
         if (faultingEventsCount.ContainsKey(eventName))
         {
             faultingEventsCount[eventName]++;
             if (faultingEventsCount[eventName] > 5)
             {
                 Console.WriteLine("Event " + eventName +
                     " has failed > 5 times in this session");
             }
         }
         if (!faultingEvents.ContainsKey(eventName))
         {
             Console.WriteLine("Event " + eventName + " threw exception " + e.Message);
             Console.WriteLine("This is the first time this event has failed in this session");
             faultingEvents.Add(eventName, e.Message);
             faultingEventsCount.Add(eventName, 1);
         }
         else if (faultingEvents[eventName] != e.Message)
         {
             Console.WriteLine("Event " + eventName + " threw a different exception: " + e.Message);
             faultingEvents[eventName] = e.Message;
         }
     }
 }