public CatProject(Game _game) { prefabList = new PrefabList(); modelList1 = new CatModelList(); materialList1 = null; typeManager = new TypeManager(); m_soundManager = new SoundManager(); }
/** * @brief Load material template under a directory * * @param _materialDirectory material templates directory * * @result materialTemplateList containing the templates * */ public static CatMaterialTemplateList LoadMaterialTemplates(string _materialDirectory) { CatMaterialTemplateList materialList = new CatMaterialTemplateList(); // search for .material files under _materialDirectory if (!Directory.Exists(_materialDirectory)) { return(materialList); } string[] files = Directory.GetFiles(_materialDirectory, "*.material"); foreach (string file in files) { CatMaterialTemplate materialTempalte = CatMaterialTemplate.LoadMaterialTemplate(file); // get name from file // TODO: add sub-directory support string materialName = Path.GetFileNameWithoutExtension(file); materialTempalte.SetName(materialName); materialList.m_materialTemplates.Add(materialName, materialTempalte); } return(materialList); }
public static CatProject OpenProject(string _fileName, Game _game) { if (!File.Exists(_fileName)) { return(null); } XmlDocument doc = new XmlDocument(); doc.Load(_fileName); // get project root int index = _fileName.LastIndexOf('/'); if (index < 0) { index = _fileName.LastIndexOf('\\'); } string projectRoot = ""; if (index >= 0) { projectRoot = _fileName.Substring(0, index) + '/'; } // read project itself CatProject newProject = new CatProject(_game); XmlNode nodeProject = doc.SelectSingleNode("Project"); newProject.projectRoot = projectRoot; newProject.projectName = nodeProject.SelectSingleNode("ProjectName").InnerText; XmlElement nodeSceneLoad = (XmlElement)nodeProject.SelectSingleNode("SceneLoad"); newProject.startupSceneName = nodeSceneLoad.GetAttribute("startup"); newProject.currentSceneName = nodeSceneLoad.GetAttribute("current"); newProject.contentManger = new ContentManager(_game.Services); newProject.contentManger.RootDirectory = projectRoot + ASSET_DIR + '/' + RESOURCE_DIR + '/'; Mgr <CatProject> .Singleton = newProject; // load shader if (Mgr <GameEngine> .Singleton._gameEngineMode == GameEngine.GameEngineMode.MapEditor) { newProject.CompileResource(); newProject.SynchronizeScene(); newProject.SynchronizeBTTrees(); } //newProject.CompileShader(newProject.projectRoot); // read configures // test new materiallist newProject.materialList1 = CatMaterialTemplateList.LoadMaterialTemplates( newProject.projectRoot + ASSET_DIR + '/' + RESOURCE_DIR + "/material/"); // newProject.materialList = MaterialList.LoadMaterilas( // newProject.GetConfigurePath(newProject.materialConfigure), // newProject); // test new model newProject.modelList1 = CatModelList.LoadModels( newProject.projectRoot + ASSET_DIR + '/' + RESOURCE_DIR + "/model/", newProject); // newProject.modelList = ModelList.LoadModels( // newProject.GetConfigurePath(newProject.modelConfigure), // newProject); // load plugins newProject.typeManager = new TypeManager(); newProject.typeManager.Load_Plugins(newProject.projectRoot + PLUGIN_DIR + '/'); newProject.typeManager.LoadConsoleCommands(newProject.projectRoot + PLUGIN_DIR + '/'); newProject.typeManager.LoadBTTreeNodes(newProject.projectRoot + PLUGIN_DIR + '/'); Mgr <GameEngine> .Singleton.CatConsole.SetTypeManager(newProject.typeManager); if (Mgr <GameEngine> .Singleton._gameEngineMode == GameEngine.GameEngineMode.MapEditor) { newProject.typeManager.Load_EditorScripts(newProject.projectRoot + PLUGIN_DIR + '/'); } Mgr <TypeManager> .Singleton = newProject.typeManager; newProject.m_btTreeManager = new BTTreeManager(); newProject.m_btTreeManager.BTTreeDirectoryRoot = newProject.projectRoot + '/' + ASSET_DIR + '/' + RESOURCE_DIR + "/ai"; newProject.m_btTreeManager.BTTreeWriteDirectory = newProject.projectRoot + '/' + RESOURCE_DIR + "/ai"; // newProject.prefabList = PrefabList.LoadPrefabs( // newProject.GetConfigurePath(newProject.prefabConfigure), // newProject); newProject.prefabList = PrefabList.LoadFromFiles( newProject.projectRoot + ASSET_DIR + '/' + RESOURCE_DIR + "/prefab/"); // load current scene // newProject.runningScene = Scene.LoadScene( // newProject.GetSceneFileAddress(newProject.currentSceneName)); return(newProject); }