Beispiel #1
0
        /// <summary>
        /// Loads a Scene from Scene Types. Use Set scene for already Loaded Scenes.
        /// </summary>
        public Scene LoadScene(string sceneTypeName, string newSceneName)
        {
            var a =
                (Scene)
                Activator.CreateInstance(SceneTypes[sceneTypeName], SpriteBatch, Graphics, GraphicsDevice, Window,
                                         Content, 1080, 720);

            LoadedScenes.Add(newSceneName, a);
            return(a);
        }
        public IEnumerator SetupScene(IScene sceneRoot)
        {
            this.Publish(new SceneLoaderEvent()
            {
                State     = SceneState.Instantiating,
                SceneRoot = sceneRoot
            });



            //If the scene was loaded via the api (it was queued having some name and settings)
            if (ScenesQueue.Count > 0)
            {
                var sceneQueueItem = ScenesQueue.Dequeue();
                sceneRoot.Name            = sceneQueueItem.Name;
                sceneRoot._SettingsObject = sceneQueueItem.Settings;
            }
            //Else, means scene was the start scene (loaded before kernel)
            else
            {
//				sceneRoot.Name = Application.loadedLevelName;
                sceneRoot.Name = UnityEngine.SceneManagement.SceneManager.GetSceneAt(UnityEngine.SceneManagement.SceneManager.sceneCount - 1).name;
            }


            this.Publish(new SceneLoaderEvent()
            {
                State     = SceneState.Instantiated,
                SceneRoot = sceneRoot
            });
            var sceneRootClosure = sceneRoot;
            Action <float, string> updateDelegate = (v, m) => {
                this.Publish(new SceneLoaderEvent()
                {
                    SceneRoot       = sceneRootClosure,
                    Name            = sceneRootClosure.Name,
                    State           = SceneState.Update,
                    Progress        = v,
                    ProgressMessage = m
                });
            };

            var sceneLoader = SceneLoaders.FirstOrDefault(loader => loader.SceneType == sceneRoot.GetType()) ??
                              _defaultSceneLoader;

            yield return(StartCoroutine(sceneLoader.Load(sceneRoot, updateDelegate)));

            LoadedScenes.Add(sceneRoot);

            this.Publish(new SceneLoaderEvent()
            {
                State     = SceneState.Loaded,
                SceneRoot = sceneRoot
            });
        }
 public void Add(object objectToAdd)
 {
     if (objectToAdd is NodeNetwork)
     {
         LoadedNodeNetworks.Add(objectToAdd as NodeNetwork);
     }
     else if (objectToAdd is Scene)
     {
         LoadedScenes.Add(objectToAdd as Scene);
     }
     else if (objectToAdd is EmitterList)
     {
         LoadedEmitterLists.Add(objectToAdd as EmitterList);
     }
     else if (objectToAdd is ShapeCollection)
     {
         LoadedShapeCollections.Add(objectToAdd as ShapeCollection);
     }
 }
        private object LoadRfsAndAddToLists(ReferencedFileSave r, bool isBeingAccessed, IElement container)
        {
            string extension = FileManager.GetExtension(r.Name).ToLower();

            object runtimeObject = null;

            if (!r.LoadedOnlyWhenReferenced || isBeingAccessed)
            {
                switch (extension)
                {
                case "scnx":
                    runtimeObject = LoadScnx(r, container);
                    if ((!r.IsSharedStatic || container is ScreenSave) && runtimeObject != null)
                    {
                        LoadedScenes.Add(runtimeObject as Scene);
                    }
                    break;

                case "shcx":
                    runtimeObject = LoadShcx(r, container);
                    if ((!r.IsSharedStatic || container is ScreenSave) && runtimeObject != null)
                    {
                        LoadedShapeCollections.Add(runtimeObject as ShapeCollection);
                    }
                    break;

                case "nntx":
                    runtimeObject = LoadNntx(r, container);
                    if ((!r.IsSharedStatic || container is ScreenSave) && runtimeObject != null)
                    {
                        LoadedNodeNetworks.Add(runtimeObject as NodeNetwork);
                    }
                    break;

                case "emix":
                    runtimeObject = LoadEmix(r);
                    if ((!r.IsSharedStatic || container is ScreenSave) && runtimeObject != null)
                    {
                        LoadedEmitterLists.Add(runtimeObject as EmitterList);
                    }
                    break;

                case "achx":
                    runtimeObject = LoadAchx(r);
                    break;

                case "png":
                case "bmp":
                case "dds":
                case "tga":
                    runtimeObject = LoadTexture2D(r);
                    break;

                case "csv":
                    runtimeObject = LoadCsv(r);
                    break;

                case "fnt":
                    runtimeObject = LoadFnt(r);
                    break;

                case "splx":
                    runtimeObject = LoadSplx(r);
                    break;
                }
            }


            return(runtimeObject);
        }