Пример #1
0
        public virtual void Initialize()
        {
            PerfMon.Reset();

            this.oldRootComponent = this.RootComponent;

            this.IsInitialized = false;

            PerfMon.Start("ScreenInitialize");

            PerfMon.Start("LoadXml");
            if (xmlContent == null)
            {
                xmlContent = (XScreen)GameEngine.LoadXml(this.FileName, this.RootComponentType);
            }

            this.RootComponent = (XScreen)xmlContent.Copy();
            this.RootComponent.ScreenEngine = this;
            this.InsertSystemSubcomponents();
            PerfMon.Stop("LoadXml");

            this.CurrentEvents.Clear();
            this.tapAreas.Clear();
            this.obstacles.Clear();

            PerfMon.Start("InitHierarchy");
            this.RootComponent.InitHierarchy();
            PerfMon.Stop("InitHierarchy");

            PerfMon.Start("Initialize");
            game.InvokeOnMainThread(() => {
                this.RootComponent.InitializeMainThread(this.initializeParameters);
            });

            this.RootComponent.Initialize(this.initializeParameters);
            PerfMon.Stop("Initialize");

            PerfMon.Stop("ScreenInitialize");

            PerfMon.Dump();

            this.IsInitialized = true;

            if (this.oldRootComponent != null)
            {
                this.oldRootComponent.Dispose();
                this.oldRootComponent = null;
            }
        }