/// <summary> /// Create and register a new location /// </summary> /// <param name="center"></param> /// <param name="radius"></param> public GameObject CreateLocation(Vector3 center, float radius) { //first, pull the genaric LocationSubject from the masterSubjectList and create prefab LocationSubject locFromMaster = masterSubjectList.GetSubject(DbIds.Location) as LocationSubject; GameObject newLocationObject = Instantiate(locFromMaster.Prefab, center, Quaternion.identity); newLocationObject.transform.localScale = new Vector3(radius * 2, 0.1f, radius * 2); //grab our connected script and create a fresh LocationSubject LocationObjectScript script = newLocationObject.GetComponent <LocationObjectScript>() as LocationObjectScript; LocationSubject newLocSubject = new LocationSubject(); //now lets set the values to make a new locationSubject card newLocSubject.Name = "Location " + Time.time; newLocSubject.Description = "New Location " + Time.time; newLocSubject.Radius = radius; newLocSubject.Coordinates = center; newLocSubject.Layer = 1; //add the next id available newLocSubject.SubjectID = masterSubjectList.GetNextID(); script.InitializeFromSubject(masterSubjectList, newLocSubject); //now add our card to the master list if (!masterSubjectList.AddSubject(newLocSubject)) { Debug.Log("FAIL ADD"); } //store to the script attached to our new object return(newLocationObject); }
/// <summary> /// !!! FOR TESTING ONLY DO NOT USE !!! <para/> /// Place a new location in the world and add it to the MasterSubjectList. /// </summary> /// <param name="newPosition">The center point of the new location</param> /// <param name="newRadius">The radius of the new location.</param> public GameObject T_PlaceLocation(Vector3 newPosition, float newRadius) { LocationSubject newLocation = new LocationSubject(masterSubjectList.GetSubject(DbIds.Location) as LocationSubject); newLocation.Name = "Location " + Time.time; newLocation.Description = "New Location " + Time.time; newLocation.Radius = newRadius; newLocation.Coordinates = newPosition; newLocation.Icon = null; newLocation.Layer = 1; //add the next id available newLocation.SubjectID = masterSubjectList.GetNextID(); GameObject location1 = Instantiate(newLocation.Prefab, newPosition, Quaternion.identity); LocationObjectScript locScript = location1.GetComponent <LocationObjectScript>(); locScript.InitializeFromSubject(masterSubjectList, newLocation); locScript.Relocate(newLocation); if (!masterSubjectList.AddSubject(newLocation)) { Debug.Log("FAIL ADD"); } return(location1); }