예제 #1
0
        public static void PauseEngine(bool storeUnpauseInstructions)
        {
            if (mUnpauseInstructions.Count != 0)
            {
                throw new System.InvalidOperationException(
                          "Can't execute pause since there are already instructions in the Unpause InstructionList." +
                          " Are you causing PauseEngine twice in a row?" +
                          " Each PauseEngine method must be followed by an UnpauseEngine before PauseEngine can be called again.");
            }
            // When the engine pauses, each manager stops
            // all activity and fills the unpauseInstructions
            // with instructions that are executed to restart activity.

            // Turn off sorting so we don't sort over and over and over...
            // Looks like we never need to turn this back on.
            mUnpauseInstructions.SortOnAdd = false;

            SpriteManager.Pause(mUnpauseInstructions);

            ShapeManager.Pause(mUnpauseInstructions);

#if SILVERLIGHT
            throw new NotImplementedException();
#else
            TextManager.Pause(mUnpauseInstructions);
#endif

            InstructionListUnpause instructions = new InstructionListUnpause(mInstructions);
            mInstructions.Clear();
            mUnpauseInstructions.Add(instructions);

            if (!storeUnpauseInstructions)
            {
                mUnpauseInstructions.Clear();
            }

            // ... now do one sort at the end to make sure all is sorted properly
            // Actually, no, don't sort, it's not necessary!  We're going to execute
            // everything anyway.
            //mUnpauseInstructions.Sort((a, b) => a.TimeToExecute.CompareTo(b));
        }