Exemplo n.º 1
0
        protected override void OnDisabledInSimulation()
        {
            DestroyScene();

            if (instance == this)
            {
                instance = null;
            }
        }
Exemplo n.º 2
0
        protected override void OnEnabledInSimulation()
        {
            instance = this;

            if (Components["Button Scenes"] != null)
            {
                ((UIButton)Components["Button Scenes"]).Click += ButtonScenes_Click;
            }
            if (Components["Button Options"] != null)
            {
                ((UIButton)Components["Button Options"]).Click += ButtonOptions_Click;
            }
            if (Components["Button Exit"] != null)
            {
                ((UIButton)Components["Button Exit"]).Click += ButtonExit_Click;
            }

            //play buttons
            if (Components["Button Play Sci-fi Demo"] != null)
            {
                var button   = (UIButton)Components["Button Play Sci-fi Demo"];
                var fileName = @"Samples\Sci-fi Demo\Scenes\Sci-fi Demo.scene";
                button.AnyData = fileName;
                button.Click  += ButtonPlay_Click;
                if (button.Visible)
                {
                    button.Visible = VirtualFile.Exists(fileName);
                }
            }
            if (Components["Button Play Nature Demo"] != null)
            {
                var button   = (UIButton)Components["Button Play Nature Demo"];
                var fileName = @"Samples\Nature Demo\Scenes\Nature Demo.scene";
                button.AnyData = fileName;
                button.Click  += ButtonPlay_Click;
                if (button.Visible)
                {
                    button.Visible = VirtualFile.Exists(fileName);
                }
            }
            if (Components["Button Play Simple Game"] != null)
            {
                var button   = (UIButton)Components["Button Play Simple Game"];
                var fileName = @"Samples\Simple Game\SimpleGameLevel1.scene";
                button.AnyData = fileName;
                button.Click  += ButtonPlay_Click;
                if (button.Visible)
                {
                    button.Visible = VirtualFile.Exists(fileName);
                }
            }
            if (Components["Button Play Character Scene"] != null)
            {
                var button   = (UIButton)Components["Button Play Character Scene"];
                var fileName = @"Samples\Starter Content\Scenes\Character.scene";
                button.AnyData = fileName;
                button.Click  += ButtonPlay_Click;
                if (button.Visible)
                {
                    button.Visible = VirtualFile.Exists(fileName);
                }
            }
            if (Components["Button Play Spaceship 2D"] != null)
            {
                var button   = (UIButton)Components["Button Play Spaceship 2D"];
                var fileName = @"Samples\Starter Content\Scenes\Spaceship control 2D.scene";
                button.AnyData = fileName;
                button.Click  += ButtonPlay_Click;
                if (button.Visible)
                {
                    button.Visible = VirtualFile.Exists(fileName);
                }
            }
            if (Components["Button Play Character 2D"] != null)
            {
                var button   = (UIButton)Components["Button Play Character 2D"];
                var fileName = @"Samples\Starter Content\Scenes\Character 2D.scene";
                button.AnyData = fileName;
                button.Click  += ButtonPlay_Click;
                if (button.Visible)
                {
                    button.Visible = VirtualFile.Exists(fileName);
                }
            }

            // Update sound listener.
            SoundWorld.SetListenerReset();

            // Load background scene.
            currentDisplayBackgroundSceneOption = SimulationApp.DisplayBackgroundScene;
            if (currentDisplayBackgroundSceneOption && EngineApp.ApplicationType == EngineApp.ApplicationTypeEnum.Simulation)
            {
                var fileName = BackgroundScene.GetByReference;
                if (!string.IsNullOrEmpty(fileName) && VirtualFile.Exists(fileName))
                {
                    LoadScene(fileName);
                }
                else
                {
                    LoadScene("");
                }
            }
            else
            {
                LoadScene("");
            }
        }