//! Close the interaction box // Also resets all the values public void CloseInteractionBox() { interactionBoxWashBottle.SetActive(false); boxSlider.value = 0.0f; volumeSelected = 0.0f; interactingGlassware = null; fillUpWithWater.SetActive(false); if (CursorManager.GetCurrentState() == MouseState.ms_interacting) { CursorManager.SetMouseState(MouseState.ms_default); CursorManager.SetCursorToDefault(); } }
public void OnStopRun() { CloseInteractionBox(); maxVolume = 0.0f; volumeHeld = 0.0f; boxSlider.value = 0.0f; volumeSelected = 0.0f; u_boxSlider.value = 0.0f; u_volumeSelected = 0.0f; interactingReagent = null; interactingGlassware = null; CursorManager.SetMouseState(MouseState.ms_default); CursorManager.SetCursorToDefault(); }
// This case is to get liquid from a glassware public void OpenGraduatedFillingBox(float volumeAvailable, Glassware glassware) { volumeSelected = 0.0f; boxGraduatedFilling.SetActive(true); if (volumeAvailable < maxVolume) { boxGraduatedFilling.GetComponentInChildren <Slider> ().maxValue = volumeAvailable; } else { boxGraduatedFilling.GetComponentInChildren <Slider> ().maxValue = maxVolume; } interactingGlassware = glassware; CursorManager.SetMouseState(MouseState.ms_interacting); }
//UNFILLING INTERACTION //! Open the interaction box to unfill the pipette // Also defines the maximum value for the slider // Case to unfill pipette into a glassware public void OpenGraduatedUnfillingBox(float volumeAvailable, Glassware glassware) //Ok { boxGraduatedUnfilling.SetActive(true); u_volumeSelected = 0.0f; //Defining volume on slider if (volumeAvailable < volumeHeld) { boxGraduatedUnfilling.GetComponentInChildren <Slider>().maxValue = volumeAvailable; } else { boxGraduatedUnfilling.GetComponentInChildren <Slider>().maxValue = volumeHeld; } interactingGlassware = glassware; interactingReagent = null; CursorManager.SetMouseState(MouseState.ms_interacting); }
//! Uses the spatula to hold a volume of a solid reagent public void FillSpatula(Glassware glassware) //Ok { CursorManager.SetMouseState(MouseState.ms_filledSpatula); CursorManager.SetNewCursor(filledSpatula_CursorTexture, hotSpot); GameObject.Find("GameController").GetComponent <GameController>().GetCurrentState().GetComponent <WorkBench>().cannotEndState = true; if ((spatulaCapacity + capacityError) < glassware.currentVolume) //Volume inside glassware < spatula capacity { volumeHeld = Random.Range(spatulaCapacity - capacityError, spatulaCapacity + capacityError); //glassware.RemoveSolid(volumeHeld); //reagentInSpatula = (Compound)(glassware.compounds [0] as Reagent).Clone (volumeHeld); } else { volumeHeld = glassware.currentVolume; } reagentInSpatula = (Compound)(glassware.content as Compound).Clone(volumeHeld); glassware.RemoveSolid(volumeHeld); CloseInteractionBox(); }
//! Unloads the pipette into a proper vessel // The vessel being the same reagent used to get the volume */ /*public void UnfillPipette(bool reagent) { //BasicallyDone * * volumeHeld = 0.0f; * reagentInPipette = null; * * CursorManager.SetMouseState (MouseState.ms_default); * CursorManager.SetCursorToDefault(); * }*/ /* END OF GRADUATED PIPETTE */ public void FillVolumetricPipette(Glassware glassware) //Ok { if (glassware.currentVolume < this.maxVolume) //Case volume on glass < pipette's max volume { this.volumeHeld = glassware.currentVolume; reagentInPipette = (Compound)(glassware.content as Compound).Clone(volumeHeld); glassware.RemoveLiquid(glassware.currentVolume); } else { this.volumeHeld = this.maxVolume; this.reagentInPipette = (Compound)(glassware.content as Compound).Clone(volumeHeld); glassware.RemoveLiquid(volumeHeld); } if (volumeHeld > 0.0f) { CursorManager.SetMouseState(MouseState.ms_filledPipette); CursorManager.SetNewCursor(filledPipette_CursorTexture, hotSpot); GameObject.Find("GameController").GetComponent <GameController>().GetCurrentState().GetComponent <WorkBench>().cannotEndState = true; } }
//! Close the interaction box public void CloseInteractionBox() { toggle.SetAllTogglesOff(); boxToChoosePipette.SetActive(false); boxGraduatedFilling.SetActive(false); boxGraduatedUnfilling.SetActive(false); interactingGlassware = null; interactingReagent = null; boxSlider.value = 0.0f; volumeSelected = 0.0f; u_boxSlider.value = 0.0f; u_volumeSelected = 0.0f; if (CursorManager.GetCurrentState() == MouseState.ms_interacting) { CursorManager.SetMouseState(MouseState.ms_default); CursorManager.SetCursorToDefault(); } }
// Update is called once per frame /*void Update () { * * }*/ public void SetGlass(Glassware glass, int index) { nameGlass.text = glass.name; prefabGlassware = glass; glasswareIndex = index; if (nameGlass.text.Contains("Balão")) { icon.sprite = icons[0]; } if (nameGlass.text.Contains("Erlenmeyer")) { icon.sprite = icons[1]; } if (nameGlass.text.Contains("Béquer")) { icon.sprite = icons[2]; } }
public void OpenInteractionBox(float volumeAvailable, Glassware glassware) { /* * OPENS THE RIGHT BOX WHETHER THE GLASSWARE IS ON A SCALE OR NOT */ boxToUnfillSpatula.SetActive(true); //Defining maximum amount of spatulas /* if (volumeAvailable < realVolumeSelected) { * maxVolume = volumeAvailable; * maxNumberOfSpatulas = (int)(volumeAvailable - (volumeAvailable % 1)); //Truncanting value * } * else { * maxVolume = realVolumeSelected; * maxNumberOfSpatulas = (int)(realVolumeSelected - (realVolumeSelected % 1)); //Trucanting value * }*/ interactingGlassware = glassware; }
//! Unloads the spatula into a proper vessel // Called when the filled spatula clicks on a valid vessel for the reagent. // In this overload, the vessel is a glassware public void UnfillSpatula(float volumeAvailable, Glassware glassware) { CloseInteractionBox(); if (volumeAvailable > volumeHeld) { //glassware.InsertSolid (volumeHeld, volumeHeld * reagentInSpatula.Density, reagentInSpatula); glassware.IncomingReagent(reagentInSpatula, volumeHeld); GameObject.Find("GameController").GetComponent <GameController>().GetCurrentState().GetComponent <WorkBench>().cannotEndState = false; CursorManager.SetMouseState(MouseState.ms_default); CursorManager.SetCursorToDefault(); volumeHeld = 0.0f; reagentInSpatula = null; } else { //glassware.InsertSolid (volumeAvailable, volumeAvailable * reagentInSpatula.Density, reagentInSpatula); glassware.IncomingReagent(reagentInSpatula, volumeAvailable); //TODO: Show something to the player? volumeHeld -= volumeAvailable; } /*if (realVolumeSelected > 0) { * interactingGlassware.InsertSolid (realVolumeSelected, realVolumeSelected * reagentInSpatula.density, reagentInSpatula); * spatulasInUse -= realVolumeSelected; * } * if (spatulasInUse <= realVolumeSelected) { * spatulasInUse = 0; * reagentInSpatula = null; * * CursorManager.SetMouseState (MouseState.ms_default); * CursorManager.SetCursorToDefault(); * } * * realVolumeSelected = 0.0f; * interactingGlassware = null;*/ }
public bool VerifyGlassware(Glassware glassware) { Debug.Log("Verifying glassware"); bool flag = false; float maxError = float.Parse(step ["maxError"]); if (glassware.content is Mixture) //TODO: Check if this is not checked before already { Debug.Log("Entrou mixture"); if ((glassware.content as Mixture).ProductFormula() != "") //Making sure the product exists { Debug.Log("Entrou formula"); if ((glassware.content as Mixture).Leftover1Molarity() > maxError || (glassware.content as Mixture).Leftover2Molarity() > maxError) //There's too much leftover to be correct { Debug.Log("Entrou leftover"); return(false); } else { Debug.Log("Else leftover"); foreach (string k in step.Keys) { if (step [k] != "null") { switch (k) { case "productFormula": if (step [k] == (glassware.content as Mixture).ProductFormula()) { Debug.Log((glassware.content as Mixture).ProductFormula()); flag = true; } else { return(false); } break; case "molarity": if (((glassware.content as Mixture).ProductMolarity() < float.Parse(step [k]) + maxError) && ((glassware.content as Mixture).ProductMolarity() > float.Parse(step [k]) - maxError)) { flag = true; } else { return(false); } break; case "minVolume": if (((glassware.content as Mixture).Volume > float.Parse(step [k]) - maxError)) { flag = true; } else { return(false); } break; /*case "density": * if (((glassware.content as Mixture).Density < float.Parse (step [k]) + maxError) && * ((glassware.content as Mixture).Density > float.Parse (step [k]) - maxError)) { * flag = true; * } else { * return false; * } * break; * case "turbidity": * if (((glassware.content as Mixture).Turbidity < float.Parse (step [k]) + maxError) && * ((glassware.content as Mixture).Turbidity > float.Parse (step [k]) - maxError)) { * flag = true; * } else { * return false; * } * break; * case "conductibility": * if (((glassware.content as Mixture).Conductibility < float.Parse (step [k]) + maxError) && * ((glassware.content as Mixture).Conductibility > float.Parse (step [k]) - maxError)) { * flag = true; * } else { * return false; * } * break;*/ } } } Debug.Log("Sera que deu bom?"); if (flag) { Debug.Log("Deu booom!"); return(true); } } } } else { Debug.Log("Entrou nao mistura"); foreach (string k in step.Keys) { if (step [k] != "null") { Debug.Log("Pre switch"); switch (k) { case "compoundFormula": Debug.Log("Caso formula"); if (step [k] == (glassware.content as Compound).Formula) { Debug.Log((glassware.content as Compound).Formula); flag = true; } else { return(false); } break; /*case "molarity": //TODO: reativar isso depois que tivermos as informaçoes da Teca * Debug.Log ("Caso molaridade"); * if (((glassware.content as Compound).Molarity < float.Parse (step [k]) + maxError) && * ((glassware.content as Compound).Molarity > float.Parse (step [k]) - maxError)) { * Debug.Log ("Caso molaridade true"); * flag = true; * } else { * Debug.Log ("Caso molaridade false"); * return false; * } * break;*/ case "minVolume": Debug.Log("Caso min volume"); if (((glassware.content as Compound).Volume > float.Parse(step [k]) - maxError)) { flag = true; } else { return(false); } break; /*case "density": * if (((glassware.content as Compound).Density < float.Parse (step [k]) + maxError) && * ((glassware.content as Compound).Density > float.Parse (step [k]) - maxError)) { * flag = true; * } else { * return false; * } * break; * case "turbidity": * if (((glassware.content as Compound).Turbidity < float.Parse (step [k]) + maxError) && * ((glassware.content as Compound).Turbidity > float.Parse (step [k]) - maxError)) { * flag = true; * } else { * return false; * } * break; * case "conductibility": * if (((glassware.content as Compound).Conductibility < float.Parse (step [k]) + maxError) && * ((glassware.content as Compound).Conductibility > float.Parse (step [k]) - maxError)) { * flag = true; * } else { * return false; * } * break;*/ } } } Debug.Log("Sera que deu bom no composto?"); if (flag) { Debug.Log("Deu booom!"); return(true); } } return(false); }