//Gets the JSON conformer file IEnumerator GetConformer(string ConformerID) { //Creates web request to load the JSON conformer via the conformerID UnityWebRequest www = UnityWebRequest.Get("https://pubchem.ncbi.nlm.nih.gov/rest/pug/conformers/" + ConformerID + "/JSON"); yield return(www.SendWebRequest()); //This should only happen with a real network error if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { // Show results as text Debug.Log(www.downloadHandler.text); JObject dataObj = JObject.Parse(www.downloadHandler.text); //Loads molecule from JObject and instantiates it at the position of the VoiceRecognizer molData = loadMolecule(dataObj); MoleculeCreator script = gameObject.GetComponent <MoleculeCreator>(); script.instantiateMolecule(molData, transform.position); GameObject.FindWithTag("DictationResult").GetComponent <TextMesh>().text = "Loaded: " + officialMolName; //Starts a couroutine to clear the billboard after a number of seconds StartCoroutine(ClearText()); } }
void OnCollisionEnter(Collision other) { /* * Debug.Log("((((((((((((((((((((((((((((("); * Debug.Log(testString); * Debug.Log(nullString); * Debug.Log("((((((((((((((((((((((((((((("); * Debug.Log(saturatedfatData.ToString()); */ if (other.gameObject.CompareTag("Floor") ) { MoleculeCreator script = gameObject.GetComponent <MoleculeCreator>(); //Debug.Log("Script: "+script); script.instantiateMolecule(molData, transform.position); } else { Destroy(gameObject); } }
void OnCollisionEnter(Collision other) { if (other.gameObject.CompareTag("Floor") && touched) { MoleculeCreator script = gameObject.GetComponent <MoleculeCreator>(); //GetComponent<Rigidbody>().position //GameObject.Find("Your_Name_Here").transform.position; script.instantiateMolecule(saturatedfatData, GameObject.Find("Ammo").transform.position); Debug.Log(GameObject.Find("Ammo").transform.position); GetComponent <AudioSource>().clip = potassium; GetComponent <AudioSource>().Play(); } touched = false; /*else * { * touched = false; * }*/ }
public void ProcessRecognizedPhrase(string phrase) { //Debug.Log(args.text); //Resets game if (phrase == "Reset") { L_Recognizer.Stop(); SceneManager.LoadScene(SceneManager.GetActiveScene().name); } //Changes tool if (toolKeyWords.Contains(phrase)) { GameObject rightWand = GameObject.FindWithTag("RightWand"); GameObject leftWand = GameObject.FindWithTag("LeftWand"); GameObject higherWand = null; higherWand = rightWand == null ? leftWand : leftWand == null ? rightWand : rightWand.transform.position.y > leftWand.transform.position.y ? rightWand : leftWand; if (higherWand == null) { Debug.LogError("Could not determine which wand has the higher y value"); } higherWand.GetComponent <Wand>().setToolByVoiceName(phrase); } //Spawns atoms if (atomPrefabKeywords.ContainsKey(phrase)) { Instantiate(atomPrefabKeywords[phrase], transform.position, transform.rotation); } //Spawns preloaded molecules if (moleculeKeywords.Contains(phrase)) { setMoleculeToSpawn(phrase); MoleculeCreator script = gameObject.GetComponent <MoleculeCreator>(); script.instantiateMolecule(molData, transform.position); } //Spawns Molecules via Pubchem if (phrase == "Create") { //Stops keyword recognizer (needed in order to start dictator) PhraseRecognitionSystem.Shutdown(); D_Recognizer = new DictationRecognizer(); //Updates position of "billboard" and updates its status to "Listening" ShowOnBillboard("Listening"); D_Recognizer.DictationResult += DictationRecognizer_DictationResult; D_Recognizer.DictationComplete += DictationRecognizer_DictationComplete; D_Recognizer.DictationError += DictationRecognizer_DictationError; //Starts dictation recognizer D_Recognizer.Start(); } if (phrase == "BondCount") { //Gets array of objects tagged with "bond" and "doublebond", returns the sum of their length Array getCountSingleBond = GameObject.FindGameObjectsWithTag("Bond"); Array getCountDoubleBond = GameObject.FindGameObjectsWithTag("DoubleBond"); int count = getCountSingleBond.Length + getCountDoubleBond.Length * 2; ShowOnBillboard("Bonds: " + count); } if (phrase == "AtomCount") { //Gets array of objects tagged with "atom", and returns its length Array getCount = GameObject.FindGameObjectsWithTag("Atom"); int count = getCount.Length; ShowOnBillboard("Atoms: " + count); } if (phrase == "help") { string help = "Voice Commands:\n\n ATP, CAFFEINE, SATURATED FAT Create molecule\n WATER, CARBON DIOXIDE,\n SULFURIC ACID, ASPIRIN, \n CREATE + [Name of Molecule] Fetch pubchem molecules\n[Element Name] Create atom\n HAND, TRACTOR, PISTOL, Change what you hold\n BLASTER, CARDS \n BLACKHOLE\n RESET Reset game\n"; ShowOnBillboard(help, 50); } if (phrase == "Blackhole") { GameObject.Find("Blackhole").GetComponent <BlackHole>().createBlackHole(); } }
// Use this for initialization void Start() { aspirinData = loadMolecule("aspirindata.json", "Aspirin"); waterData = loadMolecule("waterdata.json", "Water"); atpData = loadMolecule("atpdata.json", "ATP"); caffeineData = loadMolecule("caffeinedata.json", "Caffeine"); carbondioxideData = loadMolecule("carbondioxidedata.json", "CarbonDioxide"); saturatedfatData = loadMolecule("saturatedfatdata.json", "SaturatedFat"); sulfuricacidData = loadMolecule("sulfuricaciddata.json", "SulfuricAcid"); nitroData = loadMolecule("nitrodata.json", "Nitroglycerin"); /*atoms waterAtoms = new atoms(new List<int>{8,1,1}); * bonds waterBonds = new bonds (new List<int> {1, 1}, new List<int> {2, 3}, new List<int> {1, 1}); * coords waterCoords = new coords (new conformers(new List<float> {0,0.2774f,0.6068f}, new List<float> {0,0.8929f,-0.2383f}, new List<float> {0,0.2544f,-0.7169f})); * MoleculeData water = new MoleculeData( waterAtoms,waterBonds,waterCoords, "water");*/ MoleculeCreator script = gameObject.GetComponent <MoleculeCreator> (); //Debug.Log(waterData.atom.element[0]); //Debug.Log(waterData.conf.x[1]); for (int i = 0; i < 3; i++) { script.instantiateMolecule(aspirinData, new Vector3(Random.Range(-3f, 4f), Random.Range(2f, 4f), Random.Range(-4f, 4f)) * spawnDist); } for (int i = 0; i < 50; i++) { script.instantiateMolecule(waterData, new Vector3(Random.Range(-3f, 4f), Random.Range(2f, 4f), Random.Range(-4f, 4f)) * spawnDist); } for (int i = 0; i < 50; i++) { script.instantiateMolecule(carbondioxideData, new Vector3(Random.Range(-3f, 4f), Random.Range(2f, 4f), Random.Range(-4, 4f)) * spawnDist); } script.instantiateMolecule(caffeineData, new Vector3(Random.Range(-3f, 4f), Random.Range(3f, 4f), Random.Range(-4f, 4f)) * spawnDist); script.instantiateMolecule(caffeineData, new Vector3(Random.Range(-3f, 4f), Random.Range(3f, 4f), Random.Range(-4f, 4f)) * spawnDist); script.instantiateMolecule(caffeineData, new Vector3(Random.Range(-3f, 4f), Random.Range(3f, 4f), Random.Range(-4f, 4f)) * spawnDist); script.instantiateMolecule(saturatedfatData, new Vector3(Random.Range(-3f, 4f), Random.Range(3f, 4f), Random.Range(-4f, 4f)) * spawnDist); script.instantiateMolecule(sulfuricacidData, new Vector3(Random.Range(-3f, 4f), Random.Range(3f, 4f), Random.Range(-4f, 4f)) * spawnDist); script.instantiateMolecule(nitroData, new Vector3(Random.Range(-3f, 4f), Random.Range(3f, 4f), Random.Range(-4f, 4f)) * spawnDist); script.instantiateMolecule(atpData, new Vector3(Random.Range(-3f, 4f), Random.Range(3f, 4f), Random.Range(-4f, 4f)) * spawnDist); /* * script.instantiateMiniatureRigidMolecule(saturatedfatData, new Vector3(Random.Range(-3f, 4f), Random.Range(3f, 4f), Random.Range(-4f, 4f))); * * script.instantiateMiniatureRigidMolecule(atpData, new Vector3(Random.Range(-3f, 4f), Random.Range(3f, 4f), Random.Range(-4f, 4f)) ); * * * script.instantiateMiniatureRigidMolecule(caffeineData, new Vector3(Random.Range(-3f, 4f), Random.Range(3f, 4f), Random.Range(-4f, 4f))); * * script.instantiateMiniatureRigidMolecule(aspirinData, new Vector3(Random.Range(-3f, 4f), Random.Range(2f, 4f), Random.Range(-4f, 4f)));*/ }