Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ...
- int check_for_event_1 = 0;
- DateTime event_1_start;
- double event_1_wait;
- void StartEvent1(double wait_time_ms)
- {
- check_for_event_1 = 1;
- event_1_start = DateTime.Now;
- event_1_wait = wait_time_ms;
- }
- ...
- // Somewhere when the event should start
- StartEvent1( 1000 * 30 );
- ...
- public void Tick()
- {
- ...
- if( check_for_event_1 == 1 ) // If we need to check this event
- {
- TimeSpan delta = DateTime.Now - event_1_start; // calculate time between start and now
- if( delta.TotalMilliseconds > event_1_wait ) // check for expiration
- {
- check_for_event_1 = 0; // disable it if needed (only execute once)
- // TODO: Execute logic for when the event happens
- // If you need it to happen again
- //StartEvent1( 1000 * 30 );
- }
- }
- ...
- }
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement