public void Dispose() { this.gameRunning = false; GameLogger.getLogger().log("Closing Game Thread"); try { this.gameThread.Interrupt(); } catch (Exception e) {} GameLogger.getLogger().log("Unloading BGMs"); foreach (BackgroundMusic bgm in BackgroundMusic.getLoadedBackgroundMusics()) { try { bgm.Dispose(); } catch (Exception e) {} } GameLogger.getLogger().log("Destroying all GUIs"); foreach (GUI gui in GUI.getGUIs()) { try { gui.Dispose(); } catch (Exception e) {} } GameLogger.getLogger().log("Diposing Scene"); try { Scene.getActiveScene().Dispose(); } catch (Exception e) {} getDisplayManager().Dispose(); }
//Instance public GameLogger() { logger = this; }
private void load() { //Load Resource List List <Model> modelsToVBO = new List <Model>(); XmlReader reader = XmlReader.Create(Game.APPLICATION_DIRECTORY + this.thingsToLoad); while (reader.Read()) { if (reader.Name == null || reader.Name == "" || reader.Name == "xml") { continue; } ResourceType rt = ResourceType.getTypeByXMLValue(reader.Name); if (rt == null) { continue; } String name = reader["name"]; String file = reader["file"]; //Load File Depending on Type Object data = null; if (rt.Equals(ResourceType.LANGUAGE)) { data = LanguageLoader.getLoader().loadLanguage(XmlReader.Create(RESOURCES_DIRECTORY + file)); } else if (rt.Equals(ResourceType.MODEL)) { List <Model> m = ModelLoader.WAVEFRONT_LOADER.loadModels(FileUtilities.getResourceAsString(RESOURCES_DIRECTORY + file)); foreach (Model mod in m) { mod.addToVBOList(); } modelsToVBO.AddRange(m); data = m; } else if (rt.Equals(ResourceType.SCENE)) { //TODO: Finish } else if (rt.Equals(ResourceType.ANIMATION)) { String resource = FileUtilities.getResourceAsString(RESOURCES_DIRECTORY + file); data = AnimationLoader.getLoader().loadAnimationRules(resource); } else if (rt.Equals(ResourceType.BACKGROUND_MUSIC)) { } else if (rt.Equals(ResourceType.TEXTURE)) { data = new LoadableTexture(RESOURCES_DIRECTORY + file); ((LoadableTexture)data).loadNow(); } if (data == null) { GameLogger.getLogger().log("Failed to load " + reader.Name + " (" + reader.Depth + ")"); continue; } if (Game.GAME_INSTANCE.getDebugMode()) { GameLogger.getLogger().log("Loaded " + rt.getName() + ": " + name + "(" + file + ")"); } Resource res = new Resource(rt, name, file, data); this.loadedStuff.Add(res); } foreach (Model m in modelsToVBO) { while (!m.isOnVBO()) { continue; } } this.loaded(); }