示例#1
0
        public void update(GameTime gameTime)
        {
            int      dequeueCount = 0;
            Arranger arranger     = new Arranger(true, 1, 'C', 0);

            continueOperation.WaitOne();
            try {
                foreach (MessageBanner message in activeMessages)
                {
                    while (message == null)
                    {
                        ;
                    }
                    if (message.Expired)
                    {
                        dequeueCount++;
                    }
                    arranger.addObject(message, 0);
                }
            } catch (Exception e) {
                Console.WriteLine("[MessageQueue.update] 'activeMessages' collection: " + e.Message);
            }

            continueOperation.Set();

            List <Arranger.ArrangedObject> objects = arranger.calculateArrangements();

            try {
                foreach (Arranger.ArrangedObject obj in objects)
                {
                    ((Movable)obj.Object).moveTo(obj.Position, 5);
                    ((Movable)obj.Object).update(gameTime);
                }
            } catch (Exception e) {
                Console.WriteLine("[MessageQueue.update] 'objects' collection: " + e.Message);
            }

            for (int i = 0; i < dequeueCount; i++)
            {
                activeMessages.Dequeue();
            }
        }