Exemplo n.º 1
0
        internal SceneLoader(string sceneName, object scene, LoaderUtility loaderUtility, GameLoader gameLoader)
        {
            GameLoader = gameLoader;
            Game = GameLoader.Game;
            this.loaderUtility = loaderUtility;

            PropertyHolder sceneValues = loaderUtility.GetProperties(scene);

            LoadedScene = new LoadedScene(sceneName, sceneValues, this, gameLoader.Game, loaderUtility);

            IEnumerable<object> managers = loaderUtility.GetOfType(scene, loaderUtility.ManagerType);

            foreach (object manager in managers)
            {
                PropertyHolder managerValues = loaderUtility.GetProperties(manager);
                string type = loaderUtility.GetType(manager);
                LoadedManager lm = LoadedManager.GetLoadedManager(type, LoadedScene, managerValues, loaderUtility);
                LoadedScene.addLoadedManager(lm);
            }

            IEnumerable<object> entities = loaderUtility.GetOfType(scene, loaderUtility.EntityType);

            foreach (object entity in entities)
            {
                string name = loaderUtility.GetName(entity);
                if (ClassFactory.isRegistered(name)) Game.CurrentGame.Die("The name " + name + " can't be both defined and used for an entity");
                LoadedEntity loadedEntity = gameLoader.entityParse(entity, name, onid++);
                LoadedScene.addLoadedEntity(loadedEntity);
            }
        }
Exemplo n.º 2
0
        internal static LoadedManager GetLoadedManager(string type, LoadedScene ls, PropertyHolder values, LoaderUtility loaderUtil)
        {
            Dictionary<string, LoadedManager> managersByName;

            if(!ManagerMap.TryGetValue(ls, out managersByName))
            {
                ManagerMap[ls] =  managersByName = new Dictionary<string, LoadedManager>();
            }

            LoadedManager loadedManager;
            if (!managersByName.TryGetValue(type, out loadedManager))
            {
                loadedManager = new LoadedManager(type, values, loaderUtil);
                managersByName[type] = loadedManager;
            }
            else
            {
                if (values != null) loadedManager.Values.AddRange(values);
            }
            return loadedManager;
        }