private void Awake() { if (UserInfoManager._instance.GetUserInfo() == null) { BackHandler._instance.GoToMain(); } _instance = this; }
protected void Awake() { if (FindObjectsOfType(typeof(Game)).Length > 1) { Destroy(this.gameObject); return; } DontDestroyOnLoad(this.gameObject); DontDestroyOnLoad(Camera.main); executeStack = new Stack <KeyValuePair <Interactuable, ExecutionEvent> >(); skin = Resources.Load("basic") as GUISkin; if (!string.IsNullOrEmpty(gamePath)) { ResourceManager = ResourceManagerFactory.CreateExternal(gamePath + gameName); } else { if (!string.IsNullOrEmpty(gameName)) { ResourceManager = ResourceManagerFactory.CreateLocal(gameName, useSystemIO ? ResourceManager.LoadingType.SystemIO : ResourceManager.LoadingType.ResourcesLoad); } else { ResourceManager = ResourceManagerFactory.CreateLocal("CurrentGame/", useSystemIO ? ResourceManager.LoadingType.SystemIO : ResourceManager.LoadingType.ResourcesLoad); } } if (Game.GameToLoad != "") { gameName = Game.GameToLoad; gamePath = ResourceManager.getCurrentDirectory() + System.IO.Path.DirectorySeparatorChar + "Games" + System.IO.Path.DirectorySeparatorChar; useSystemIO = true; } AdventureData data = new AdventureData(); var incidences = new List <Incidence>(); AdventureHandler adventure = new AdventureHandler(data, ResourceManager, incidences); adventure.Parse("descriptor.xml"); game_state = new GameState(data); bookDrawer = new BookDrawer(ResourceManager); gameExtensions = new List <GameExtension>(); foreach (var gameExtension in GetAllSubclassOf(typeof(GameExtension))) { gameExtensions.Add(gameObject.AddComponent(gameExtension) as GameExtension); } }
/** * Loads the adventure data from the given ZIP file. * * @param zipFile * Path to the zip file which holds the adventure * @return The adventure data, null if there was an error */ public static AdventureData loadAdventureData(InputStreamCreator isCreator, List <Incidence> incidences) { AdventureData adventureDataTemp = null; try { // Set the adventure handler AdventureHandler adventureParser = new AdventureHandler(isCreator, incidences); //factory.setValidating(false); //SAXParser saxParser = factory.newSAXParser(); // Read and close the input stream string descriptorIS = isCreator.buildInputStream("descriptor.xml"); adventureParser.Parse(descriptorIS); //descriptorIS.close(); // Load the assessment and adaptation profiles. It must be after parse // the adventure data because the profile's load from xml inserts each profile // in each chapter. adventureParser.loadProfiles(); // Store the adventure data adventureDataTemp = adventureParser.getAdventureData(); } catch (Exception e) { Debug.LogError(e); } //catch (ParserConfigurationException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.SAX"), e)); //} //catch (SAXException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.SAX"), e)); //} //catch (IOException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.IO"), e)); //} //catch (IllegalArgumentException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.NoDescriptor"), e)); //} return(adventureDataTemp); }
/** * Loads the adventure data from the given ZIP file. * * @param zipFile * Path to the zip file which holds the adventure * @return The adventure data, null if there was an error */ public static AdventureData loadAdventureData(InputStreamCreator isCreator, List<Incidence> incidences) { AdventureData adventureDataTemp = null; try { // Set the adventure handler AdventureHandler adventureParser = new AdventureHandler(isCreator, incidences); //factory.setValidating(false); //SAXParser saxParser = factory.newSAXParser(); // Read and close the input stream string descriptorIS = isCreator.buildInputStream("descriptor.xml"); adventureParser.Parse(descriptorIS); //descriptorIS.close(); // Load the assessment and adaptation profiles. It must be after parse // the adventure data because the profile's load from xml inserts each profile // in each chapter. adventureParser.loadProfiles(); // Store the adventure data adventureDataTemp = adventureParser.getAdventureData(); } catch (Exception e) { Debug.LogError(e); } //catch (ParserConfigurationException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.SAX"), e)); //} //catch (SAXException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.SAX"), e)); //} //catch (IOException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.IO"), e)); //} //catch (IllegalArgumentException e) //{ // incidences.add(Incidence.createDescriptorIncidence(Language.GetText("Error.LoadDescriptor.NoDescriptor"), e)); //} return adventureDataTemp; }
protected void Awake() { Game.instance = this; executeStack = new Stack <KeyValuePair <Interactuable, ExecutionEvent> >(); skin = Resources.Load("basic") as GUISkin; if (!string.IsNullOrEmpty(gamePath)) { ResourceManager = ResourceManagerFactory.CreateExternal(gamePath + gameName); } else { if (!string.IsNullOrEmpty(gameName)) { ResourceManager = ResourceManagerFactory.CreateLocal(gameName, useSystemIO ? ResourceManager.LoadingType.SYSTEM_IO : ResourceManager.LoadingType.RESOURCES_LOAD); } else { ResourceManager = ResourceManagerFactory.CreateLocal("CurrentGame/", useSystemIO ? ResourceManager.LoadingType.SYSTEM_IO : ResourceManager.LoadingType.RESOURCES_LOAD); } } if (Game.GameToLoad != "") { gameName = Game.GameToLoad; gamePath = ResourceManager.getCurrentDirectory() + System.IO.Path.DirectorySeparatorChar + "Games" + System.IO.Path.DirectorySeparatorChar; useSystemIO = true; } AdventureData data = new AdventureData(); var incidences = new List <Incidence>(); AdventureHandler adventure = new AdventureHandler(data, ResourceManager, incidences); adventure.Parse("descriptor.xml"); PrepareTracker(data.getTrackerConfig()); game_state = new GameState(data); //Create Main game completable Completable mainGame = new Completable(); Completable.Milestone gameStart = new Completable.Milestone(); gameStart.setType(Completable.Milestone.MilestoneType.SCENE); gameStart.setId(data.getChapters()[0].getInitialChapterTarget().getId()); mainGame.setStart(gameStart); mainGame.setId(data.getTitle()); mainGame.setType(Completable.TYPE_GAME); Completable.Milestone gameEnd = new Completable.Milestone(); gameEnd.setType(Completable.Milestone.MilestoneType.ENDING); mainGame.setEnd(gameEnd); Completable.Progress gameProgress = new Completable.Progress(); gameProgress.setType(Completable.Progress.ProgressType.SUM); Completable.Score mainScore = new Completable.Score(); mainScore.setMethod(Completable.Score.ScoreMethod.AVERAGE); foreach (Completable part in GameState.GetCompletables()) { Completable.Milestone tmpMilestone = new Completable.Milestone(); tmpMilestone.setType(Completable.Milestone.MilestoneType.COMPLETABLE); tmpMilestone.setId(part.getId()); gameProgress.addMilestone(tmpMilestone); Completable.Score tmpScore = new Completable.Score(); tmpScore.setMethod(Completable.Score.ScoreMethod.SINGLE); tmpScore.setType(Completable.Score.ScoreType.COMPLETABLE); tmpScore.setId(part.getId()); mainScore.addSubScore(tmpScore); } mainGame.setProgress(gameProgress); mainGame.setScore(mainScore); GameState.GetCompletables().Insert(0, mainGame); CompletablesController.Instance.SetCompletables(GameState.GetCompletables()); bookDrawer = new BookDrawer(ResourceManager); }