public void UpdateStageParameters(int stageID) { currentStageID = stageID; if (stageID >= 0) //I'm having an assumption here that, sometimes in the future, I'm going to send negative numbers as stageIDs for non playable levels (e.g. menus. loading, etc) { currentStageParameters = StagesData.GetStageParameters((uint)currentStageID); } }
public void CreateTemplateFile() { string filePath = Path.Combine(Application.dataPath, "stagesTemplate.json"); StagesData stagesData = new StagesData(); stagesData.stages = new Stage[4]; stagesData.stages[0].obstacles = new ObstacleData[3]; File.WriteAllText(filePath, JsonUtility.ToJson(stagesData, true)); Debug.Log("Well... Everything went well! >> " + filePath); }
public void LoadScene(uint stageID, GameStateManager.State newStateOnLoad) //this, coupled with the requiremnt that positive stageIDs should only be used for playable stages, { //should mean that this version of LoadScene will be used only for playable stages. Stage targetStage = StagesData.GetStageParameters(stageID); if (targetStage == null) { print("ERROR! Attempting to load a stage with an ID not existant in the database. ID: " + stageID); return; } print("Switching to scene: " + targetStage.name); GameManager.stateMan.UpdateStageParameters((int)stageID); LoadScene(targetStage.name, newStateOnLoad); }
public void LoadData() { string filePath = Path.Combine(Application.dataPath, stagesDataFileName); if (!File.Exists(filePath)) { Debug.LogError("File at " + filePath + " Doesn't exist..."); return; } //catches Unexisting File Exception string fileData = File.ReadAllText(filePath); StagesData stagesDataTemp = JsonUtility.FromJson <StagesData>(fileData); stagesData = stagesDataTemp; Debug.Log("Stage Data loaded successfully!"); }