public void TestSingleEvent(int timeSpan)
        {
            container.AddTimedEvent(TimeSpanType.Milliseconds, timeSpan, "msg", "par1", "par2");

            // elapse timeSpan for events to expire
            var startTime = StaticTimer.GetElapsedMilliseconds();
            var nowTime   = 0.0;

            // save some space, because system timers are never 100% precise
            while ((nowTime = StaticTimer.GetElapsedMilliseconds()) - startTime < timeSpan + 10)
            {
            }

            container.ProcessTimedEvents();
            bus.ProcessEventsSequentially(); // events must be processed on the main thread!
            Assert.AreEqual(1, processor.ObservedEvents);
        }
Example #2
0
 /// <summary>
 /// Creates timed events for spawning customers
 /// </summary>
 public void GenerateCustomerSpawnEvents()
 {
     foreach (Customer customer in allCustomersInLevel)
     {
         customerSpawnEvents.AddTimedEvent(
             TimeSpanType.Seconds,
             customer.WhenToSpawn,
             "LEVEL",
             "SPAWN_CUSTOMER",
             customer.Name);
     }
 }
Example #3
0
 /// <summary>
 /// Checks collision between rendered customers and the player
 /// </summary>
 private void CustomerCollision()
 {
     if (CurrentlyCarriedCustomer != null)   //should only carry one customer at once
     {
         return;
     }
     foreach (Customer customer in activeCustomersInlevel)
     {
         if (!customer.Collision(player.Shape.AsDynamicShape()))
         {
             continue;
         }
         CurrentlyCarriedCustomer = customer;
         CustomerDespawnEvents.AddTimedEvent(
             TimeSpanType.Seconds, customer.TimeToDeliver, "LEVEL", "DESPAWN_CUSTOMER",
             customer.Name);
     }
 }