Activity() публичный Метод

public Activity ( bool firstTimeCalled ) : void
firstTimeCalled bool
Результат void
Пример #1
0
        private static Screen LoadScreen(string screen, Layer layerToLoadScreenOn, bool addToManagers, bool makeCurrentScreen)
        {
            mNextScreenLayer = layerToLoadScreenOn;

            Screen newScreen = null;

            Type typeOfScreen = MainAssembly.GetType(screen);

            if (typeOfScreen == null)
            {
                throw new System.ArgumentException("There is no " + screen + " class defined in your project or linked assemblies.");
            }

            if (screen != null && screen != "")
            {
#if XBOX360
                newScreen = (Screen)Activator.CreateInstance(typeOfScreen);
#else
                newScreen = (Screen)Activator.CreateInstance(typeOfScreen, new object[0]);
#endif
            }

            if (newScreen != null)
            {
                FlatRedBall.Input.InputManager.CurrentFrameInputSuspended = true;

                if (addToManagers)
                {
                    // We do this so that new Screens are the CurrentScreen in Activity.
                    // This is useful in custom logic.
                    if (makeCurrentScreen)
                    {
                        mCurrentScreen = newScreen;
                    }
                    newScreen.Initialize(addToManagers);

                    newScreen.ApplyRestartVariables();
                }
                mSuppressStatePush = false;

                nextCallback?.Invoke(newScreen);
                nextCallback = null;


                if (addToManagers)
                {
                    newScreen.Activity(true);


                    newScreen.ActivityCallCount++;
                }
            }

            return(newScreen);
        }
Пример #2
0
        /// <summary>
        /// Calls activity on the current screen and checks to see if screen
        /// activity is finished.  If activity is finished, the current Screen's
        /// NextScreen is loaded.
        /// </summary>
        #endregion
        public static void Activity()
        {
            if (mCurrentScreen == null)
            {
                return;
            }

            mCurrentScreen.Activity(false);

            mCurrentScreen.ActivityCallCount++;

            if (mCurrentScreen.ActivityCallCount == 2 && mWasFixedTimeStep.HasValue)
            {
#if !FRB_MDX
                FlatRedBallServices.Game.IsFixedTimeStep = mWasFixedTimeStep.Value;
                TimeManager.TimeFactor = mLastTimeFactor.Value;
#endif
            }

            if (mCurrentScreen.IsActivityFinished)
            {
                string type = mCurrentScreen.NextScreen;
                Screen asyncLoadedScreen = mCurrentScreen.mNextScreenToLoadAsync;



                mWasFixedTimeStep = FlatRedBallServices.Game.IsFixedTimeStep;
                mLastTimeFactor   = TimeManager.TimeFactor;

                FlatRedBallServices.Game.IsFixedTimeStep = false;
                TimeManager.TimeFactor = 0;

                GuiManager.Cursor.IgnoreInputThisFrame = true;

                mCurrentScreen.Destroy();

                // check to see if there is any leftover data
                CheckAndWarnIfNotEmpty();

                // Let's perform a GC here.
                GC.Collect();

                // Not sure why this started to freeze on Android in the automated test project
                // on April 22, 2015. I'm commenting it out because I don't think we need to wait
                // for finalizers, and we can just continue on. Maybe try to bring the code back
                // on Android in the future too.
                // March 16, 2017 - Desktop GL too, not sure why...
                                #if !ANDROID && !DESKTOP_GL
                GC.WaitForPendingFinalizers();
                                #endif

                if (asyncLoadedScreen == null)
                {
                    // Loads the Screen, suspends input for one frame, and
                    // calls Activity on the Screen.
                    // The Activity call is required for objects like SpriteGrids
                    // which need to be managed internally.

                    // No need to assign mCurrentScreen - this is done by the 4th argument "true"
                    //mCurrentScreen =
                    LoadScreen(type, null, true, true);
                }
                else
                {
                    mCurrentScreen = asyncLoadedScreen;

                    nextCallback?.Invoke(mCurrentScreen);
                    nextCallback = null;

                    mCurrentScreen.AddToManagers();

                    mCurrentScreen.Activity(true);


                    mCurrentScreen.ActivityCallCount++;
                }
                mNumberOfFramesSinceLastScreenLoad = 0;
            }
            else
            {
                mNumberOfFramesSinceLastScreenLoad++;
            }
        }