예제 #1
0
 ///<summary>
 ///Called by the scheduler to start sounds
 ///</summary>
 ///<param name="sender"></param>
 ///<param name="scheduleEventArguments"></param>
 public void ScheduledStartSound(
     object sender, ScheduledEventArguments scheduleEventArguments)
 {
     StartAllSound();
 }
        /// <summary>
        /// Invoke the events at the given time (and any time earlier) (and then removing that time/events list from the pool)
        /// </summary>
        /// <param name="time">the actual game-time.  all events scheduled at this time or earlier will be triggered and removed from the pool.</param>
        public void AdvanceTime(float elapsedMS)
        {
            elapsedMS += _remainderMS;
            int ms = (int)elapsedMS;
            _remainderMS = elapsedMS - (float)ms;
            _currentTime += ms;

            CallbackInformation toExecute;

            LinkedListNode<KeyValuePair<int, CallbackInformation>> currentNode = _scheduledEvents.First;

            while (currentNode != null)
            {
                if (currentNode.Value.Key > _currentTime)
                    return;
                toExecute = currentNode.Value.Value;

                if (_tempToSend == null)
                    _tempToSend = new ScheduledEventArguments();
                _tempToSend.DataToSend = toExecute.DataToSend;
                _tempToSend.TargetTime = currentNode.Value.Key;
                _currentEventId = toExecute.EventId;
                toExecute.MethodToCall(this, _tempToSend);
                _currentEventId = 0; // no event being processed now
                currentNode = currentNode.Next;
                _scheduledEvents.RemoveFirst();
            }
        }