public void SetOptionData( string data ) { if ( data != null ) { Serializer<CaseOptionData> serializer = new Serializer<CaseOptionData>(); CaseOptionData = serializer.FromString(data); } }
// create seperate method so we can call this outside public IEnumerator LoadConfig( CaseOptionData data ) { if ( data == null ) { UnityEngine.Debug.LogError("CaseConfigurator.LoadConfig() : data is NULL (probably bad load)..."); yield return null; } UnityEngine.Debug.Log("CaseConfigurator.LoadConfig(" + data.casename + ")"); // set assessment name AssessmentMgr.GetInstance().Scenario.Name = data.casename; // first, load up the base configuration if (data.baseConfig != null){ if (data.baseConfig.Enabled){ string prefabName = "CaseOptions/"+data.baseConfig.Prefab; UnityEngine.Debug.Log("CaseConfigurator.LoadConfig() load prefab <" + prefabName + ">"); UnityEngine.Object ro = Resources.Load(prefabName); if (ro != null){ GameObject newGO = Instantiate(ro) as GameObject; if (newGO != null){ newGO.name = data.baseConfig.Name; newGO.transform.parent = gameObject.transform; // eventually, we may need to call Link() here. // yield a few frames for all of that to get linked yield return null; yield return null; yield return null; } } else Debug.LogWarning("Could not load base Configuration "+prefabName); } } else UnityEngine.Debug.LogWarning("No base configuration found in Config "+ data.casename); // load injuries here if ( data.injury != null ) { // load primary injury prefab first if ( data.injury.Prefab != null && data.injury.Prefab != "" ) { string prefabName = "CaseOptions/"+data.injury.Prefab; UnityEngine.Debug.Log("CaseConfigurator.LoadConfig() load prefab <" + prefabName + ">"); UnityEngine.Object ro = Resources.Load(prefabName); if (ro != null){ GameObject newGO = Instantiate(ro) as GameObject; if (newGO != null){ newGO.name = data.injury.Name; newGO.transform.parent = gameObject.transform; // eventually, we may need to call Link() here. // yield a few frames for all of that to get linked yield return null; yield return null; yield return null; } } else UnityEngine.Debug.Log("CaseConfigurator.LoadConfig() : can't load prefab <" + prefabName + ">"); } // now load any secondary injuries foreach( CaseConfigOption secondary in data.injury.SecondaryOptions ) { string prefabName; // get name of prefab if ( secondary.Enabled == true ) prefabName = secondary.Prefab; else prefabName = secondary.PrefabWhenDisabled; if ( prefabName != null && prefabName != "" ) { prefabName = "CaseOptions/"+prefabName; UnityEngine.Debug.Log("CaseConfigurator.LoadConfig() load prefab <" + prefabName + ">"); UnityEngine.Object ro = Resources.Load(prefabName); if (ro != null){ GameObject newGO = Instantiate(ro) as GameObject; if (newGO != null){ newGO.name = secondary.Name; newGO.transform.parent = gameObject.transform; // eventually, we may need to call Link() here. // yield a few frames for all of that to get linked yield return null; yield return null; yield return null; } } else UnityEngine.Debug.Log("CaseConfigurator.LoadConfig() : can't load prefab <" + prefabName + ">"); } } } // look for each configured option as our child, instantiate from resources prefabs or asset bundles if not found, // make them our children, then call the necessary startup methods. if (data.options != null) { foreach (CaseConfigOption opt in data.options) { string prefabName1; // get name of prefab if ( opt.Enabled == true ) prefabName1 = opt.Prefab; else prefabName1 = opt.PrefabWhenDisabled; if ( prefabName1 != null && prefabName1 != "" ) { prefabName1 = "CaseOptions/"+prefabName1; UnityEngine.Debug.Log("CaseConfigurator.LoadConfig() load prefab <" + prefabName1 + ">"); UnityEngine.Object ro = Resources.Load(prefabName1); if (ro != null){ GameObject newGO = Instantiate(ro) as GameObject; if (newGO != null){ newGO.name = opt.Name; newGO.transform.parent = gameObject.transform; // eventually, we may need to call Link() here. // yield a few frames for all of that to get linked yield return null; yield return null; yield return null; } } else UnityEngine.Debug.Log("CaseConfigurator.LoadConfig() : can't load prefab <" + prefabName1 + ">"); } } } // grab/set the initial vitals state Patient patient = ObjectManager.GetInstance().GetBaseObject("Patient") as Patient; int HR = Convert.ToInt32(data.start.HR); if ( HR != -1 ) patient.HR = HR; int BPSYS = Convert.ToInt32(data.start.BPSYS); if ( BPSYS != -1 ) patient.BP_SYS = BPSYS; int BPDIA = Convert.ToInt32(data.start.BPDIA); if ( BPDIA != -1 ) patient.BP_DIA = BPDIA; int SP = Convert.ToInt32(data.start.SP); if ( SP != -1 ) patient.SP = SP; float TEMP = Convert.ToSingle(data.start.TEMP); if ( TEMP != -1 ) patient.TEMP = TEMP; float RESP = Convert.ToSingle(data.start.RESP); if ( RESP != -1 ) patient.RR = RESP; }
public void CreateCase() { // create new case Data = new CaseOptionData(); // set to first injury Data.injury = CaseConfiguratorMgr.GetInstance().InjuryConfig[0]; // set owner Data.owner = LoginMgr.GetInstance().Username; }
void loadCase(bool status, string data, string error_msg, WWW download) { // convert from string data to serialized Serializer<CaseOptionData> serializer = new Serializer<CaseOptionData>(); this.data = serializer.FromString(data); }