/// <summary>
    /// Refreshs the tab with Item info.
    /// </summary>
    /// <param name="i">ItemInventoryBase to get info from.</param>
    /// <param name="val">If set to <c>true</c>, activates tab. Else, deactivates.</param>
    public void refreshTab(ItemInventoryBase i, bool val)
    {
        if (!val)
        {
            actionTab.SetActive(false);
            return;
        }
        //gets info from "i"
        switch (i.getItemType())
        {
        case ItemType.Glassware:
            tabValues[0].text = i.gl.name;
            break;

        case ItemType.Liquids:
        case ItemType.Solids:
            tabValues[0].text = i.reagent;
            tabValues[1].text = CompoundFactory.GetInstance().GetCupboardCompound(i.reagent).MolarMass + " g/mol";
            tabValues[2].text = CompoundFactory.GetInstance().GetCupboardCompound(i.reagent).Density + " g/ml";
            tabValues[3].text = CompoundFactory.GetInstance().GetCupboardCompound(i.reagent).Purity *100 + "%";
            tabValues[4].text = CompoundFactory.GetInstance().GetCupboardCompound(i.reagent).Solubility + " g/1g";
            break;
        }

        actionTab.SetActive(true);
    }
Exemplo n.º 2
0
    public void writeReagentInfo(string name)
    {
        deleteContent();
        Compound reagent;

        reagent = CompoundFactory.GetInstance().GetCupboardCompound(name);

        //adds the infoUI to content
        prefabRect = infoPrefab.GetComponent <RectTransform> ();
        // calculate y position
        float y = (prefabRect.rect.height + offSetItens) * lastItemPos;

        // set position
        Vector3 currentPos = new Vector3(1f, -y);
        //Debug.Log("Current y position: " + y );

        // instantiate Item
        GameObject tempItem = Instantiate(prefabRect.gameObject,
                                          currentPos,
                                          prefabRect.transform.rotation) as GameObject;

        //add info to prefab
        tempItem.name = "Reagent Info";
        tempItem.GetComponent <JournalUIInfo> ().setReagent(reagent.Name, reagent.MolarMass, reagent.IsSolid, reagent.Density, reagent.Polarizability, reagent.Conductibility, reagent.Solubility, 0, 0, 0);
        // set new item parent to scroll rect content
        tempItem.transform.SetParent(contentRect.transform, false);
    }
Exemplo n.º 3
0
        /// <summary>
        /// This is what updates the datagrid when the compound selection is changed
        /// </summary>
        /// <param name="sender">not used</param>
        /// <param name="e">not used</param>
        private void Compound_ComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            List <CompoundTableData>  elements  = new List <CompoundTableData>();
            List <ConstantsTableData> constants = new List <ConstantsTableData>();
            Compound compound;

            if (Compound_ComboBox.SelectedItem != null)
            {
                compound = CompoundFactory.GetElementsOfCompound((Compound_ComboBox.SelectedItem as string).ToLower());

                foreach (KeyValuePair <Element, int> element in compound.elements)
                {
                    elements.Add(new CompoundTableData(element.Key.Name, element.Value));
                }

                constants.Add(new ConstantsTableData("Cp (kJ/mol-C)", "Cp" + compound.Abbr));
                constants.Add(new ConstantsTableData("Hf (kJ/mol)", "Hf" + compound.Abbr));
                constants.Add(new ConstantsTableData("Hv (kJ/mol)", "Hv" + compound.Abbr));
                constants.Add(new ConstantsTableData("Tb (C)", "Tb" + compound.Abbr));
                constants.Add(new ConstantsTableData("Tm (C)", "Tm" + compound.Abbr));

                Compound_DataGrid.ItemsSource  = elements;
                Constants_DataGrid.ItemsSource = constants;
            }
            else
            {
                Compound_DataGrid.ItemsSource  = elements;
                Constants_DataGrid.ItemsSource = constants;
            }
        }
 public static CompoundFactory GetInstance()
 {
     if (instance == null)
     {
         instance = new CompoundFactory();
     }
     return(instance);
 }
Exemplo n.º 5
0
    //! Put into workbench position an item from the inventory
    public bool PutItemFromInventory(ItemInventoryBase item)
    {
        bool worked = false;

        if (!item.physicalObject)
        {
            GameObject tempItem = Instantiate(item.itemBeingHeld.gameObject) as GameObject;
            if (!TryPutIntoPosition(tempItem))
            {
                Destroy(tempItem);
                worked = false;
            }
            else
            {
                if (tempItem.GetComponent <ReagentPot>() != null)
                {
                    if (item.reagent.Length != 0)
                    {
                        Compound reagent = CompoundFactory.GetInstance().GetCupboardCompound(item.reagent);

                        if (tempItem.GetComponent <ReagentPot>().isSolid)
                        {
                            tempItem.GetComponent <ReagentPot>().reagent.setValues(reagent as Compound);
                        }
                        else
                        {
                            tempItem.GetComponent <ReagentPot>().reagent.setValues(reagent as Compound);
                        }
                    }
                }
                worked = true;
            }
        }
        else
        {
            GameObject tempItem = GameObject.Find(item.index);
            if (TryPutIntoPosition(tempItem))
            {
                tempItem.SetActive(true);
                worked = true;
            }
            else
            {
                worked = false;
            }
        }

        if (worked)
        {
            soundBeaker.Play();
            return(true);
        }
        else
        {
            gameController.sendAlert("A Bancada está cheia!");
            return(false);
        }
    }
    //! Add the reagent clicked to the inventory
    public void AddToInventory()
    {
        //Debug.Log ("Add " + nameReagent.text);
        //inventoryManager.AddItemToInventory (GameObject.Find ("GetReagents").GetComponent<GetReagentState>().ReagentInstantiation(nameReagent.text));
        Compound reagent;

        reagent = CompoundFactory.GetInstance().GetCupboardCompound(nameReagent.text);
        inventoryManager.AddReagentToInventory(prefabReagentPot, reagent);
    }
Exemplo n.º 7
0
    public void FillVolumetricPipette(string reagent)       //OK
    {
        this.volumeHeld = this.maxVolume;

        this.reagentInPipette = (Compound)CompoundFactory.GetInstance().GetCupboardCompound((reagent)).Clone(volumeHeld);
        CursorManager.SetMouseState(MouseState.ms_filledPipette);
        CursorManager.SetNewCursor(filledPipette_CursorTexture, hotSpot);

        GameObject.Find("GameController").GetComponent <GameController>().GetCurrentState().GetComponent <WorkBench>().cannotEndState = true;
    }
    // Use this for initialization
    void Start()
    {
        tabValues[0].text = reagent.Name;
        tabValues[1].text = reagent.MolarMass + " g/mol";
        tabValues[2].text = reagent.Density + " g/ml";
        tabValues[3].text = CompoundFactory.GetInstance().GetCupboardCompound(reagent.Name).Purity *100 + "%";
        tabValues[4].text = reagent.Solubility + " g/1g";

        defaultColour = potMesh.GetComponent <Renderer>().material.color;
    }
Exemplo n.º 9
0
    //! Make the reaction using concentration A and B.
    public void MakeReaction(string reactionName, float concentrationA, float concentrationB)
    {
        ReactionClass reaction = ReactionsSaver.LoadReactions() [reactionName];

        float realConcentrationA;
        float realConcentrationB;

        float realConcentrationC;
        float realConcentrationD;

        realConcentrationB = concentrationB;         // limitant!!!

        realConcentrationA = realConcentrationB * reaction.stoichiometryR1;

        realConcentrationC = realConcentrationA * reaction.stoichiometryMainProduct;

        realConcentrationD = realConcentrationA * reaction.stoichiometrySubProduct;

        float phC = 0, phD = 0;
        float turbidityC = 0, turbidityD = 0;

        Dictionary <string, Compound> reagents = CompoundFactory.GetInstance().CupboardCollection;

        if (!reagents [reaction.mainProduct].IsSolid)
        {
            phC        = reagents [reaction.mainProduct].PH;
            turbidityC = reagents [reaction.mainProduct].Turbidity;
        }

        if (!reagents [reaction.subProduct].IsSolid)
        {
            phD        = reagents [reaction.mainProduct].PH;
            turbidityD = reagents [reaction.mainProduct].Turbidity;
        }

        polarizability = (reagents [reaction.mainProduct].Polarizability * realConcentrationC + reagents [reaction.subProduct].Polarizability * realConcentrationD) / (realConcentrationC + realConcentrationD);
        conductibility = (reagents [reaction.mainProduct].Conductibility * realConcentrationC + reagents [reaction.subProduct].Conductibility * realConcentrationD) / (realConcentrationC + realConcentrationD);
        solubility     = (reagents [reaction.mainProduct].Solubility * realConcentrationC + reagents [reaction.subProduct].Solubility * realConcentrationD) / (realConcentrationC + realConcentrationD);

        ph        = (phC * realConcentrationC + phD * realConcentrationD) / (realConcentrationC + realConcentrationD);
        turbidity = (turbidityC * realConcentrationC + turbidityD * realConcentrationD) / (realConcentrationC + realConcentrationD);

/*		float colorR = (reagents [reaction.cName].color.r * realConcentrationC + reagents [reaction.dName].color.r * realConcentrationD) / (realConcentrationC + realConcentrationD);
 *              float colorG = (reagents [reaction.cName].color.g * realConcentrationC + reagents [reaction.dName].color.g * realConcentrationD) / (realConcentrationC + realConcentrationD);
 *              float colorB = (reagents [reaction.cName].color.b * realConcentrationC + reagents [reaction.dName].color.b * realConcentrationD) / (realConcentrationC + realConcentrationD);
 *              float colorA = (reagents [reaction.cName].color.a * realConcentrationC + reagents [reaction.dName].color.a * realConcentrationD) / (realConcentrationC + realConcentrationD);
 *
 *              color = new Color (colorR, colorG, colorB, colorA);*/
    }
Exemplo n.º 10
0
        public static ObservableCollection <EquationType> BuildTypeOptions(Workspace workspace)
        {
            IList <string> compounds = WorkspaceUtility.GetUniqueSelectedCompounds(workspace);

            List <string> elements = new List <string>();

            foreach (string compoundstr in compounds)
            {
                Compound compound = CompoundFactory.GetElementsOfCompound((compoundstr).ToLower());

                foreach (KeyValuePair <Element, int> element in compound.elements)
                {
                    if (!elements.Contains(element.Key.Name))
                    {
                        elements.Add(element.Key.Name);
                    }
                }
            }

            ObservableCollection <EquationType> equationTypes = new ObservableCollection <EquationType>();

            equationTypes.Add(new EquationType(EquationTypeClassification.Total, "Total"));
            equationTypes.Add(new EquationType(EquationTypeClassification.Specification, "Specification"));
            equationTypes.Add(new EquationType(EquationTypeClassification.Basis, "Basis"));

            foreach (string compound in compounds)
            {
                if (compound != "Overall")
                {
                    equationTypes.Add(new EquationType(EquationTypeClassification.Compound, compound));
                }
            }

            if (workspace.Difficulty != OptionDifficultySetting.MaterialBalance)
            {
                foreach (string element in elements)
                {
                    equationTypes.Add(new EquationType(EquationTypeClassification.Atom, element + "(e)"));
                }
            }

            return(equationTypes);
        }
Exemplo n.º 11
0
    private ReactionTable()
    {
        table = new MultiDictionary <string, string, string> ();

        //Load the reagents from file into memory
        reactions = ReactionsSaver.LoadReactions();

        foreach (Compound c in CompoundFactory.GetInstance().CupboardCollection.Values)
        {
            foreach (ReactionClass re in reactions.Values)
            {
                if (re.reagent1 == c.Formula)
                {
                    table[re.reagent1, re.reagent2] = re.name;
                    table[re.reagent2, re.reagent1] = re.name;
                }
            }
        }
    }
Exemplo n.º 12
0
    //! Select the number of times the selected spatula is going to be used
    //  The volume of reagent held by the spatula will be define in a range associated if its capacity

/*	public void SelectingNumberOfSpatulas(bool increase) {
 *              /*
 * CODE FILLING THE SPATULA
 */
    /*if(precision)
     *	use slider?
     * else
     *	use intervals
     *
     */
/*		if(realVolumeSelected < 0 || timesToUseSpatula < 0) {		//Can't go below zero
 *                      realVolumeSelected = 0.0f;
 *                      timesToUseSpatula = 0;
 *              }
 *
 *              if (!usingPrecision) { //If the vessel is NOT on a scale
 *
 *                      if(increase) {
 *                              timesToUseSpatula++;
 *                              realVolumeSelected += Random.Range(spatulaCapacity - capacityError, spatulaCapacity + capacityError);
 *                      }
 *                      else {
 *                              timesToUseSpatula--;
 *                              realVolumeSelected -= Random.Range(spatulaCapacity - capacityError, spatulaCapacity + capacityError);
 *                      }
 *                      if(realVolumeSelected > maxVolume && interactingGlassware != null)
 *                              realVolumeSelected = maxVolume;
 *
 *                      if(realVolumeSelected < 0 || timesToUseSpatula < 0) {		//Can't go below zero
 *                              realVolumeSelected = 0.0f;
 *                              timesToUseSpatula = 0;
 *                      }
 *                      //timesToUseText.text = realVolumeSelected.ToString();
 *              }
 *      }*/

    /*//! Amount of Spatulas chosen
     * public void SetUsesOfSpatula() {
     *      volumeHeld = realVolumeSelected;
     *
     * }*/

    //! Uses the spatula to hold a volume of a solid reagent
    public void FillSpatula(string reagent)        //Ok

    /*if(realVolumeSelected > 0) {
     *      CursorManager.SetMouseState (MouseState.ms_filledSpatula);
     *      CursorManager.SetNewCursor (filledSpatula_CursorTexture, hotSpot);
     *
     *      reagentInSpatula = reagent;
     * }
     *
     * spatulasInUse = realVolumeSelected;
     * realVolumeSelected = 0;*/

    {
        CursorManager.SetMouseState(MouseState.ms_filledSpatula);
        CursorManager.SetNewCursor(filledSpatula_CursorTexture, hotSpot);
        GameObject.Find("GameController").GetComponent <GameController>().GetCurrentState().GetComponent <WorkBench>().cannotEndState = true;


        volumeHeld       = Random.Range(spatulaCapacity - capacityError, spatulaCapacity + capacityError);
        reagentInSpatula = (Compound)CompoundFactory.GetInstance().GetCupboardCompound((reagent)).Clone(volumeHeld);

        CloseInteractionBox();
    }
Exemplo n.º 13
0
    //! Use the pipette to hold the selected volume.
    public void FillGraduatedPipette()       //ReagentPot OK | Glassware Ok
    {
        if (volumeSelected > 0.0f)
        {
            volumeHeld = Random.Range(volumeSelected - graduatedError, volumeSelected + graduatedError);
        }
        if (interactingGlassware != null)
        {
            if (volumeSelected > 0.0f)
            {
                /*if (!(lastItemSelected.GetComponent<Glassware> () == null)) //Only removes from the last selected object if it's a glassware
                 * lastItemSelected.GetComponent<Glassware>().RemoveLiquid (amountSelectedPipeta);*/
                CursorManager.SetMouseState(MouseState.ms_filledPipette);                 //pipetaReagentCursor.CursorEnter ();
                CursorManager.SetNewCursor(filledPipette_CursorTexture, hotSpot);

                GameObject.Find("GameController").GetComponent <GameController> ().GetCurrentState().GetComponent <WorkBench> ().cannotEndState = true;

                reagentInPipette = (Compound)(interactingGlassware.content as Compound).Clone(volumeHeld);

                interactingGlassware.RemoveLiquid(volumeHeld);
            }
        }
        else if (interactingReagent != null)
        {
            if (volumeSelected > 0.0f)
            {
                CursorManager.SetMouseState(MouseState.ms_filledPipette);                 //pipetaReagentCursor.CursorEnter ();
                CursorManager.SetNewCursor(filledPipette_CursorTexture, hotSpot);

                GameObject.Find("GameController").GetComponent <GameController> ().GetCurrentState().GetComponent <WorkBench> ().cannotEndState = true;
                reagentInPipette = (Compound)CompoundFactory.GetInstance().GetCupboardCompound((interactingReagent.Name)).Clone(volumeHeld);
            }
        }

        //volumeHeld = volumeSelected;
        CloseInteractionBox();
    }
    /// <summary>
    /// The method is called to load a new phase
    /// </summary>
    /// <param name="glasswareStart">Glassware start.</param>
    private void NewPhase(bool glasswareStart)
    {
        //Check how to start the phase
        actualStep = 0;
        if (glasswareStart)
        {
            GameObject bequer = Instantiate((GameObject.Find("GameController").GetComponent <GameController> ().gameStates [2] as GetGlasswareState).glasswareList [0].gameObject) as GameObject;
            if ((GameObject.Find("GameController").GetComponent <GameController> ().gameStates [1] as WorkBench).TryPutIntoPosition(bequer))
            {
                Compound compound = new Compound();
                compound = CompoundFactory.GetInstance().GetCompound(phaseDefinitions ["compoundFormula"]);

                /*
                 * Changes on properties according to float.Parse(phaseDefinitions["molarity"])
                 */
                compound.PH       = 7.0f;
                compound.Molarity = 1.0f;

                bequer.GetComponent <Glassware> ().IncomingReagent(compound.Clone(float.Parse(phaseDefinitions ["volume"])) as Compound, float.Parse(phaseDefinitions ["volume"]));
                GameObject.Find("InventoryManager").GetComponent <InventoryManager>().AddProductToInventory(bequer.gameObject);
            }
        }
        else
        {
            // Cupboard test

            /*
             * Pote de reagente
             */
        }

        //Add steps to Experiment Menu on Tablet

        /*GameObject.Find ("Tablet").GetComponentInChildren<NotesState> ().LoadNotes ();
         * GameObject.Find ("Experiments Menu").GetComponent<ExperimentMenu> ().RefreshScroll (1); //TODO: RETHINK ABOUT ALL THIS STEP-PHASE CONSISTENCY ON JOURNAL*/
        NewStep();
    }
    /// <summary>
    /// Changes the background image of the selected item.
    /// </summary>
    /// <param name="obj">GameObject of the selected item.</param>
    public void changeImage(GameObject obj)
    {
        ItemInventoryBase item = obj.GetComponent <ItemInventoryBase> ();
        Image             icon = null;

        Image[] img = obj.GetComponentsInChildren <Image> ();
        //from images on obj, gets the Item Image
        for (int i = 0; i < img.Length; i++)
        {
            if (img[i].gameObject.name == "Item Image")
            {
                icon = img[i];
            }
        }

        Text txt = obj.GetComponentInChildren <Text> ();

        //chooses image depending on item
        //if reagent, sets underneath text to obj formula
        switch (item.getItemType())
        {
        case ItemType.Liquids:
            icon.sprite = icons[0];
            txt.text    = CompoundFactory.GetInstance().GetCupboardCompound(item.reagent).Formula;
            break;

        case ItemType.Solids:
            icon.sprite = icons[1];
            txt.text    = CompoundFactory.GetInstance().GetCupboardCompound(item.reagent).Formula;
            break;

        case ItemType.Glassware:
            txt.text = "";
            if (item.gl.name.Contains("Balão Vol."))
            {
                if (item.gl.name.Contains("25"))
                {
                    icon.sprite = icons[2];
                    break;
                }
                if (item.gl.name.Contains("50"))
                {
                    icon.sprite = icons[3];
                    break;
                }
                if (item.gl.name.Contains("100"))
                {
                    icon.sprite = icons[4];
                    break;
                }
            }
            if (item.gl.name.Contains("Béquer"))
            {
                icon.sprite = icons[5];
                break;
            }
            if (item.gl.name.Contains("Erlenmeyer"))
            {
                if (item.gl.name.Contains(" 50ml"))
                {
                    icon.sprite = icons[6];
                    break;
                }
                if (item.gl.name.Contains("125"))
                {
                    icon.sprite = icons[7];
                    break;
                }
                if (item.gl.name.Contains("250"))
                {
                    icon.sprite = icons[8];
                    break;
                }
            }
            break;

        case ItemType.Others:
            txt.text = "";
            string gl = GameObject.Find(item.index).GetComponent <Glassware>().gl;
            if (gl.Contains("Balão Vol."))
            {
                if (GameObject.Find(item.index).GetComponent <Glassware>().hasSolid)
                {
                    item.solid.sprite  = productsIcons[0];
                    item.solid.enabled = true;
                }
                if (GameObject.Find(item.index).GetComponent <Glassware>().hasLiquid)
                {
                    item.liquid.sprite  = productsIcons[1];
                    item.liquid.enabled = true;
                }

                if (gl.Contains("25"))
                {
                    icon.sprite = icons[2];
                    break;
                }
                if (gl.Contains("50"))
                {
                    icon.sprite = icons[3];
                    break;
                }
                if (gl.Contains("100"))
                {
                    icon.sprite = icons[4];
                    break;
                }
            }
            if (gl.Contains("Béquer"))
            {
                if (GameObject.Find(item.index).GetComponent <Glassware>().hasSolid)
                {
                    item.solid.sprite  = productsIcons[2];
                    item.solid.enabled = true;
                }
                if (GameObject.Find(item.index).GetComponent <Glassware>().hasLiquid)
                {
                    item.liquid.sprite  = productsIcons[3];
                    item.liquid.enabled = true;
                }
                icon.sprite = icons[5];
                break;
            }
            if (gl.Contains("Erlenmeyer"))
            {
                if (GameObject.Find(item.index).GetComponent <Glassware>().hasSolid)
                {
                    item.solid.sprite  = productsIcons[4];
                    item.solid.enabled = true;
                }
                if (GameObject.Find(item.index).GetComponent <Glassware>().hasLiquid)
                {
                    item.liquid.sprite  = productsIcons[5];
                    item.liquid.enabled = true;
                }
                if (gl.Contains(" 50ml"))
                {
                    icon.sprite = icons[6];
                    break;
                }
                if (gl.Contains("125"))
                {
                    icon.sprite = icons[7];
                    break;
                }
                if (gl.Contains("250"))
                {
                    icon.sprite = icons[8];
                    break;
                }
            }
            break;
        }
    }
    void OnGUI()
    {
        EditorGUILayout.BeginVertical();
        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Width(0), GUILayout.Height(0));

        EditorGUILayout.LabelField("Criar Reaçao:");

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        name = EditorGUILayout.TextField("Nome da Reaçao:", name);

        EditorGUILayout.Space();
        EditorGUILayout.Space();


        EditorGUILayout.LabelField("        'X'                    A        +        'Y'                    B        =        'W'                 C          +       'Z'                  D");


        EditorGUILayout.BeginHorizontal();

        aMultipler = EditorGUILayout.IntField(aMultipler);
        aName      = EditorGUILayout.TextField(aName);

        bMultipler = EditorGUILayout.IntField(bMultipler);
        bName      = EditorGUILayout.TextField(bName);

        cMultipler = EditorGUILayout.IntField(cMultipler);
        cName      = EditorGUILayout.TextField(cName);

        dMultipler = EditorGUILayout.IntField(dMultipler);
        dName      = EditorGUILayout.TextField(dName);

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();

        Dictionary <string, Compound> reagents = CompoundFactory.GetInstance().CupboardCollection;

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        //TODO: Add the isSolid component when defining the components

        /*if(aName != "")
         * {
         *      if (reagents.ContainsKey(aName))
         *      {
         *              EditorGUILayout.BeginVertical ();
         *
         *              EditorGUILayout.LabelField ("Nome: " + reagents [aName].Formula);
         *              EditorGUILayout.LabelField ("MassaMolar: " + reagents [aName].MolarMass);
         *              EditorGUILayout.LabelField ("Densidade: " + reagents [aName].Density);
         *              EditorGUILayout.LabelField ("pH: " + reagents [aName].PH);
         *              EditorGUILayout.ColorField ("Cor: ", reagents [aName].compoundColor);
         *
         *              EditorGUILayout.EndVertical ();
         *      }
         *      else
         *      {
         *              EditorGUILayout.BeginVertical ();
         *
         *              EditorGUILayout.LabelField ("Nome: ");
         *              EditorGUILayout.LabelField ("MassaMolar: ");
         *              EditorGUILayout.LabelField ("Densidade: ");
         *              EditorGUILayout.LabelField ("pH: ");
         *              EditorGUILayout.ColorField ("Cor: ", Color.black);
         *
         *              EditorGUILayout.EndVertical ();
         *      }
         * }
         * else
         * {
         *      EditorGUILayout.BeginVertical ();
         *
         *      EditorGUILayout.LabelField ("Nome: ");
         *      EditorGUILayout.LabelField ("MassaMolar: ");
         *      EditorGUILayout.LabelField ("Densidade: ");
         *      EditorGUILayout.LabelField ("pH: ");
         *      EditorGUILayout.ColorField ("Cor: ", Color.black);
         *
         *      EditorGUILayout.EndVertical ();
         * }
         *
         * if(bName != "")
         * {
         *      if (reagents.ContainsKey (bName))
         *      {
         *              EditorGUILayout.BeginVertical ();
         *
         *              EditorGUILayout.LabelField ("Nome: " + reagents [bName].Formula);
         *              EditorGUILayout.LabelField ("MassaMolar: " + reagents [bName].MolarMass);
         *              EditorGUILayout.LabelField ("Densidade: " + reagents [bName].Density);
         *              EditorGUILayout.LabelField ("pH: " + (reagents [bName] as Compound).PH);
         *              EditorGUILayout.ColorField ("Cor: ", reagents [bName].compoundColor);
         *
         *              EditorGUILayout.EndVertical ();
         *      }
         *      else
         *      {
         *              EditorGUILayout.BeginVertical ();
         *
         *              EditorGUILayout.LabelField ("Nome: ");
         *              EditorGUILayout.LabelField ("MassaMolar: ");
         *              EditorGUILayout.LabelField ("Densidade: ");
         *              EditorGUILayout.LabelField ("pH: ");
         *              EditorGUILayout.ColorField ("Cor: ", Color.black);
         *
         *              EditorGUILayout.EndVertical ();
         *      }
         * }
         * else
         * {
         *      EditorGUILayout.BeginVertical ();
         *
         *      EditorGUILayout.LabelField ("Nome: ");
         *      EditorGUILayout.LabelField ("MassaMolar: ");
         *      EditorGUILayout.LabelField ("Densidade: ");
         *      EditorGUILayout.LabelField ("pH: ");
         *      EditorGUILayout.ColorField ("Cor: ", Color.black);
         *
         *      EditorGUILayout.EndVertical ();
         * }
         *
         *
         * if(cName != "")
         * {
         *      if (reagents.ContainsKey (cName))
         *      {
         *              EditorGUILayout.BeginVertical ();
         *
         *              EditorGUILayout.LabelField ("Nome: " + reagents [cName].Formula);
         *              EditorGUILayout.LabelField ("MassaMolar: " + reagents [cName].MolarMass);
         *              EditorGUILayout.LabelField ("Densidade: " + reagents [cName].Density);
         *              EditorGUILayout.LabelField ("pH: " + (reagents [cName] as Compound).PH);
         *              EditorGUILayout.ColorField ("Cor: ", reagents [cName].compoundColor);
         *
         *              EditorGUILayout.EndVertical ();
         *      }
         *      else
         *      {
         *              EditorGUILayout.BeginVertical ();
         *
         *              EditorGUILayout.LabelField ("Nome: ");
         *              EditorGUILayout.LabelField ("MassaMolar: ");
         *              EditorGUILayout.LabelField ("Densidade: ");
         *              EditorGUILayout.LabelField ("ph: ");
         *              EditorGUILayout.ColorField ("Cor: ", Color.black);
         *
         *              EditorGUILayout.EndVertical ();
         *      }
         * }
         * else
         * {
         *      EditorGUILayout.BeginVertical ();
         *
         *      EditorGUILayout.LabelField ("Nome: ");
         *      EditorGUILayout.LabelField ("MassaMolar: ");
         *      EditorGUILayout.LabelField ("Densidade: ");
         *      EditorGUILayout.LabelField ("pH: ");
         *      EditorGUILayout.ColorField ("Cor: ", Color.black);
         *
         *      EditorGUILayout.EndVertical ();
         * }
         *
         *
         * if(dName != "")
         * {
         *      if (reagents.ContainsKey (dName))
         *      {
         *              EditorGUILayout.BeginVertical ();
         *
         *              EditorGUILayout.LabelField ("Nome: " + reagents [dName].Formula);
         *              EditorGUILayout.LabelField ("MassaMolar: " + reagents [dName].MolarMass);
         *              EditorGUILayout.LabelField ("Densidade: " + reagents [dName].Density);
         *              EditorGUILayout.LabelField ("pH: " + (reagents [dName] as Compound).PH);
         *              EditorGUILayout.ColorField ("Cor: ", reagents [dName].compoundColor);
         *
         *              EditorGUILayout.EndVertical ();
         *      }
         *      else
         *      {
         *              EditorGUILayout.BeginVertical ();
         *
         *              EditorGUILayout.LabelField ("Nome: ");
         *              EditorGUILayout.LabelField ("MassaMolar: ");
         *              EditorGUILayout.LabelField ("Densidade: ");
         *              EditorGUILayout.LabelField ("pH: ");
         *              EditorGUILayout.ColorField ("Cor: ", Color.black);
         *
         *              EditorGUILayout.EndVertical ();
         *      }
         * }
         * else
         * {
         *      EditorGUILayout.BeginVertical ();
         *
         *      EditorGUILayout.LabelField ("Nome: ");
         *      EditorGUILayout.LabelField ("MassaMolar: ");
         *      EditorGUILayout.LabelField ("Densidade: ");
         *      EditorGUILayout.LabelField ("pH: ");
         *      //EditorGUILayout.ColorField ("Cor: ", Color.black);
         *
         *      EditorGUILayout.EndVertical ();
         * }
         *
         * EditorGUILayout.EndHorizontal();
         *
         *
         * bool aOk = false;
         * bool bOk = false;
         * bool c*k = false;
         * bool dOk = false;
         *
         * if (aName != "" && aMultipler != 0)
         * {
         *      if (reagents.ContainsKey (aName))
         *      {
         *              aOk = true;
         *      }
         *      else
         *      {
         *              aOk = false;
         *      }
         * }
         * else
         * {
         *      aOk = false;
         * }
         *
         * if (cName != "" && cMultipler != 0)
         * {
         *      if(reagents.ContainsKey (cName))
         *      {
         *              c*k = true;
         *      }
         *      else
         *      {
         *              c*k = false;
         *      }
         * }
         * else
         * {
         *      c*k = false;
         * }
         *
         * if (bName == "")
         * {
         *      if(bMultipler == 0)
         *      {
         *              bOk = true;
         *      }
         *      else
         *      {
         *              bOk = false;
         *      }
         * }
         * else
         * {
         *      if(bMultipler != 0)
         *      {
         *              if(reagents.ContainsKey (bName))
         *              {
         *                      bOk = true;
         *              }
         *              else
         *              {
         *                      bOk = false;
         *              }
         *      }
         *      else
         *      {
         *              bOk = false;
         *      }
         * }
         *
         * if (dName == "")
         * {
         *      if(dMultipler == 0)
         *      {
         *              dOk = true;
         *      }
         *      else
         *      {
         *              dOk = false;
         *      }
         * }
         * else
         * {
         *      if(dMultipler != 0)
         *      {
         *              if(reagents.ContainsKey (dName))
         *              {
         *                      dOk = true;
         *              }
         *              else
         *              {
         *                      dOk = false;
         *              }
         *      }
         *      else
         *      {
         *              dOk = false;
         *      }
         * }
         *
         *
         * if (aOk && bOk && c*k && dOk && name != "")
         * {
         *      if(GUILayout.Button("Salvar"))
         *      {
         *              ReactionsSaver.SaveReactionsFromEditor(name, aMultipler, aName, bMultipler, bName, cMultipler, cName, dMultipler, dName);
         *              this.Close();
         *      }
         * }*/

        if (GUILayout.Button("Salvar"))
        {
            //ReactionsSaver.SaveReactionsFromEditor (name, aMultipler, aName, bMultipler, bName, cMultipler, cName, dMultipler, dName);
            this.Close();
        }

        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
    }
    public void Start()
    {
        cameraState.gameObject.SetActive(false);
        Compound actualReagent;

        reagents = CompoundFactory.GetInstance().CupboardCollection;

        // Set-up components
        if (canvasUI == null)
        {
            Debug.LogError("Canvas not found in GetReagentState");
        }

        UIScrollList = canvasUI.GetComponentInChildren <ScrollRect>();
        if (UIScrollList == null)
        {
            Debug.LogError("ScrollRect not found in GetReagentState");
        }

        prefabRect = reagentPrefab.GetComponent <RectTransform>();

        contentRect = UIScrollList.content;

        // Store keys in a List
        List <string> list = new List <string>(reagents.Keys);

        // Loop through list
        foreach (string k in list)
        {
            reagents.TryGetValue(k, out actualReagent);
            // calculate y position
            float y = (prefabRect.rect.height + offSetItens) * lastItemPos;

            // set position
            Vector3 currentPos = new Vector3(1f, -y);
            //Debug.Log("Current y position: " + y );

            // resize content rect
            contentRect.sizeDelta = new Vector2(
                1f, // width doesnt change
                prefabRect.rect.height + (prefabRect.rect.height + offSetItens) * lastItemPos);

            // instantiate Item
            GameObject tempItem = Instantiate(prefabRect.gameObject,
                                              currentPos,
                                              prefabRect.transform.rotation) as GameObject;

            // set reagent's name
            if (actualReagent.IsSolid)
            {
                tempItem.GetComponent <ReagentUiItemBehaviour>().SetReagent(actualReagent.Name, solidPrefab);
            }
            else
            {
                tempItem.GetComponent <ReagentUiItemBehaviour>().SetReagent(actualReagent.Name, liquidPrefab);
            }
            // next position on inventory grid
            lastItemPos++;

            // set new item parent to scroll rect content
            tempItem.transform.SetParent(contentRect.transform, false);
        }

        //  Old code

        /*
         * currentPosition = startPoint.localPosition;
         *
         *      Rect rectScroll = UIScrollList.rect;
         *
         *      rectScroll.height = (reagentPrefab.GetComponent<RectTransform>().rect.height * (reagentList.Length)) + (reagentList.Length *offSetItens);
         *
         *      RectTransform newUIScrollList = UIScrollList;
         *
         *      newUIScrollList.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Bottom, 0, rectScroll.height);
         *
         *      UIScrollList = newUIScrollList;
         *
         *      for(int i = 0; i<reagentList.Length; i++){
         *
         *              GameObject tempReagent = Instantiate(reagentPrefab.gameObject,  currentPosition, startPoint.rotation) as GameObject;
         *              tempReagent.transform.SetParent(UIScrollList.transform, false);
         *              tempReagent.GetComponent<RectTransform>().localPosition = currentPosition;
         *              tempReagent.GetComponent<ReagentUiItemBehaviour>().SetReagent(reagentList[i]);
         *
         *              currentPosition.y -= reagentPrefab.GetComponent<RectTransform>().rect.height + offSetItens;
         *
         *      }
         */
    }
Exemplo n.º 18
0
 //! Loads reagentsLiquid
 public void GetInfo(string reagent)
 {
     info = CompoundFactory.GetInstance().GetCupboardCompound(reagent) as Compound;
 }
Exemplo n.º 19
0
        private static List <string> GetTypeOptions(Workspace workspace, IStreamDataRow excludeMe)
        {
            // Start by making a list of unique selected compounds from all rows in all stream tables,
            // except for the one we need to exclude.
            List <string> compounds = new List <string>();

            foreach (AbstractStream stream in workspace.Streams)
            {
                ChemicalStream cs = stream as ChemicalStream;
                if (null != cs)
                {
                    // Go through all the rows in the properties table
                    foreach (IStreamDataRow otherRow in cs.PropertiesTable.Rows)
                    {
                        // Skip the row if it's the one we need to exclude
                        if (object.ReferenceEquals(otherRow, excludeMe))
                        {
                            continue;
                        }

                        string selectedCompound = (otherRow as ChemicalStreamData).SelectedCompound;
                        if (!string.IsNullOrEmpty(selectedCompound) &&
                            !compounds.Contains(selectedCompound))
                        {
                            compounds.Add(selectedCompound);
                        }
                    }
                }
            }

            // Now build a list of elements for the compounds in the list
            List <string> elements = new List <string>();

            foreach (string compoundstr in compounds)
            {
                Compound compound = CompoundFactory.GetElementsOfCompound((compoundstr).ToLower());

                foreach (KeyValuePair <Element, int> element in compound.elements)
                {
                    if (!elements.Contains(element.Key.Name))
                    {
                        elements.Add(element.Key.Name);
                    }
                }
            }

            List <string> equationTypes = new List <string>();

            equationTypes.Add("Total");
            equationTypes.Add("Specification");
            equationTypes.Add("Basis");
            foreach (string compound in compounds)
            {
                if (compound != "Overall")
                {
                    equationTypes.Add((new EquationType(EquationTypeClassification.Compound, compound)).ToString());
                }
            }
            if (workspace.Difficulty != OptionDifficultySetting.MaterialBalance)
            {
                foreach (string element in elements)
                {
                    equationTypes.Add((new EquationType(EquationTypeClassification.Atom, element + "(e)")).ToString());
                }
            }

            return(equationTypes);
        }
    void OnGUI()
    {
        EditorGUILayout.BeginVertical();
        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Width(0), GUILayout.Height(0));

        EditorGUILayout.LabelField("Deletar Produto:");

        Dictionary <string, Compound> products = CompoundFactory.GetInstance().Collection;

        string[] names = new string[products.Count];

        int counter = 0;

        foreach (string name in products.Keys)
        {
            names[counter] = name;
            counter++;
        }

        indexOfProduct = EditorGUILayout.Popup(indexOfProduct, names);

        selectedProduct = names[indexOfProduct];

        if (selectedProduct != selectedProductLastInteraction)
        {
            selected = false;
        }

        selectedProductLastInteraction = selectedProduct;

        if (!selected)
        {
            if (GUILayout.Button("Checar"))
            {
                selected       = true;
                deleteSelected = false;
                product        = products[names[indexOfProduct]] as Compound;
            }
        }

        if (selected)
        {
            EditorGUILayout.LabelField("Nome: " + product.Name);
            EditorGUILayout.LabelField("Massa Molar : " + product.MolarMass.ToString());
            EditorGUILayout.LabelField("Densidade : " + product.Density.ToString());
            EditorGUILayout.LabelField("Purity : " + product.Purity.ToString());
            EditorGUILayout.LabelField("Polaridade: " + product.Polarizability.ToString());
            EditorGUILayout.LabelField("Condutividade: " + product.Conductibility.ToString());
            EditorGUILayout.LabelField("Solubilidade: " + product.Solubility.ToString());

            if (!product.IsSolid)
            {
                EditorGUILayout.LabelField("Ph : " + (product as Compound).PH.ToString());
                EditorGUILayout.LabelField("Turbilidade: " + (product as Compound).Turbidity.ToString());
                EditorGUILayout.LabelField("Refratometro: " + (product as Compound).Refratometer.ToString());
                EditorGUILayout.LabelField("Espectro de Chama: " + product.FlameSpecter);

                if ((product as Compound).hplc != null)
                {
                    EditorGUILayout.LabelField("HPLC = " + (product as Compound).hplc.ToString());
                }
                else
                {
                    EditorGUILayout.LabelField("HPLC = ");
                }
            }

            if (product.irSpecter != null)
            {
                EditorGUILayout.LabelField("Espectro IR : " + product.irSpecter.name);
            }
            else
            {
                EditorGUILayout.LabelField("Espectro IR : ");
            }

            if (product.uvSpecter != null)
            {
                EditorGUILayout.LabelField("Espectro UV : " + product.uvSpecter.name);
            }
            else
            {
                EditorGUILayout.LabelField("Espectro UV : ");
            }

            /*	if(product.texture != null)
             * {
             *      EditorGUILayout.LabelField("Textura: " + product.texture.name);
             * }
             * else
             * {
             *      EditorGUILayout.LabelField("Textura: ");
             * }*/

            EditorGUILayout.ColorField("Cor: ", product.compoundColor);

            if (!deleteSelected)
            {
                if (GUILayout.Button("DELETAR!"))
                {
                    deleteSelected = true;
                }
            }
            else
            {
                EditorGUILayout.LabelField("Deletar?");
                if (GUILayout.Button("Sim"))
                {
                    Dictionary <string, Compound> allProducts = CompoundFactory.GetInstance().CupboardCollection;

                    allProducts.Remove(names[indexOfProduct]);
//					ComponentsSaver.SaveProducts(allProducts);

                    Debug.Log("Produto " + names[indexOfProduct] + " Removido com sucesso!");

                    this.Close();
                }
                if (GUILayout.Button("Nao"))
                {
                    this.Close();
                }
            }
        }

        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
    }
    /*public Mixture(Compound _product, Reagent[] _leftovers) {
     *      this.product = _product;
     *      this.leftovers = _leftovers;
     * }*/

    //Creates a Mixture, completing the reaction
    public Mixture(Compound r1, Compound r2)
    {
        ReactionClass reaction = ReactionTable.GetInstance().GetReaction(r1.Formula, r2.Formula);

        if (reaction != null)
        {
            //Makes sure the reagents are being dealt in the correct order
            if (reaction.reagent1 != r1.Formula)
            {
                string aux = reaction.reagent1;
                reaction.reagent1 = reaction.reagent2;
                reaction.reagent2 = aux;

                int auxSt = reaction.stoichiometryR1;
                reaction.stoichiometryR1 = reaction.stoichiometryR2;
                reaction.stoichiometryR2 = auxSt;
            }
            product = CompoundFactory.GetInstance().GetCompound(reaction.mainProduct);

            //Calculates the limiting reagent
            float limitingFactor1 = ((r1.Molarity / 1000) * r1.Volume) / reaction.stoichiometryR1;
            float limitingFactor2 = ((r2.Molarity / 1000) * r2.Volume) / reaction.stoichiometryR2;
            Debug.Log("limit1 =" + limitingFactor1.ToString() + "; limit2 = " + limitingFactor2.ToString());

            float trueLimiting;
            float limitingStoichiometry;
            if (limitingFactor1 <= limitingFactor2)               //Case: limiting reagent is R1
            {
                trueLimiting          = limitingFactor1;
                limitingStoichiometry = reaction.stoichiometryR1;
                //Defining the order of reagents. The first is always the limiting reagent
                leftovers.Add(r1);
                leftovers.Add(r2);
            }
            else
            {
                trueLimiting          = limitingFactor2;
                limitingStoichiometry = reaction.stoichiometryR2;

                leftovers.Add(r2);
                leftovers.Add(r1);
            }

            //Calculating mass of product
            //mass = limiting mols consumed * (stoichiometry of product / limiting stoichiometry) * product molar mass
            float productMass = ((trueLimiting * limitingStoichiometry) * reaction.stoichiometryMainProduct / limitingStoichiometry) * product.MolarMass;
            //Calculating total amount of water
            waterVolume  = (r1.RealMass - ((r1.Molarity / 1000) * r1.Volume * r1.MolarMass)) / Compound.waterDensity;
            waterVolume += (r2.RealMass - ((r2.Molarity / 1000) * r2.Volume * r2.MolarMass)) / Compound.waterDensity;
            if (reaction.subProduct == "H2O")
            {
                waterVolume += (((trueLimiting * limitingStoichiometry) * (reaction.stoichiometrySubProduct / limitingStoichiometry)) * Compound.waterMolarMass) / Compound.waterDensity;
            }


            //Setting product's molarity
            product.Purity   = 1.0f;
            product.Molarity = ((product.Purity * product.Density) / product.MolarMass);
            product.RealMass = productMass;
            this.Volume      = r1.Volume + r2.Volume;        //TODO:For the time being, the final volume is the sum of both volumes

            //Setting leftovers's values
            leftovers[0].Purity   = 1.0f;
            leftovers[0].Molarity = 0.0f;
            leftovers[0].RealMass = 0.0f;
            leftovers[0].Density  = 0.0f;
            leftovers[0].Volume   = 0.0f;

            float massOfReagent = (leftovers[1].Molarity * (leftovers[1].Volume / 1000) * leftovers[1].MolarMass)
                                  - (((trueLimiting * limitingStoichiometry) * (reaction.stoichiometryR2 / limitingStoichiometry)) * leftovers[1].MolarMass); // Mass = previous mass of reagent - mass consumed;

            leftovers[1].setValues(CompoundFactory.GetInstance().GetCupboardCompound(leftovers[1].Name));
            leftovers[1].Purity   = 1.0f;
            leftovers[1].RealMass = massOfReagent;
            if (leftovers[1].IsSolid)
            {
                //CHECK FOR PRECIPITATE
                //FOR THE TIME BEING, IT WILL BE DILUTED, AND WON'T CHANGE THE VOLUME
                leftovers[1].Volume = 0.0f;
            }
            else
            {
                //leftovers[1].Volume = leftovers[1].RealMass * leftovers[1].Density;
                leftovers[1].Volume = 0.0f;
            }

            //Setting Mixture's values
            //this.RealMass = this.GetMass ();
            //this.Volume = this.GetVolume ();
            this.Density = this.RealMass / this.Volume;
            this.Name    = reaction.name;

            //Setting product's values that depends on the mixture's final values
            product.Molarity      = (productMass / product.MolarMass) / (this.Volume * 0.001f);
            leftovers[1].Molarity = (leftovers[1].RealMass / leftovers[1].MolarMass) / (this.Volume * 0.001f);

            /*
             * TODO: VERIFICAR PRECIPITADOS
             */

            /*if ((reaction.subProduct != "H2O") || (reaction.subProduct != "")) { TODO: VERIFICAR REACTION.SUBPRODUCT E COMPONENTSAVER UTILIZANDO NAME AO INVES DE FORMULA
             *      leftovers.Add((Compound)CompoundFactory.GetInstance ().GetCompound (reaction.subProduct));
             *      leftovers[2].Purity = 1.0f;
             *      leftovers[2].RealMass = (trueLimiting * reaction.stoichiometrySubProduct / limitingStoichiometry) * leftovers[3].MolarMass;
             *      leftovers[2].Molarity = leftovers[3].RealMass / this.Volume;
             *      if(leftovers[2].IsSolid) {
             *              //CHECK FOR PRECIPITATE
             *              //FOR THE TIME BEING, IT WILL BE DILUTED, AND WON'T CHANGE THE VOLUME
             *              leftovers[2].Volume = 0.0f;
             *      }
             *      else {
             *              leftovers[2].Volume = leftovers[3].RealMass * leftovers[3].Density;
             *      }
             * }*/
        }
        else             //There was no reaction
        {
            Debug.Log("falha");
            product = null;

            leftovers.Add(r1);
            leftovers.Add(r2);

            Name = "UnknownMixture";

            float auxVolume = 0.0f;

            //Cases where the physical states are the same, the volumes do not change
            if (leftovers[0].IsSolid && (!leftovers[1].IsSolid))              //Case: l0 is solid, l1 is liquid
            {
                leftovers[0].Volume = 0.0f;
                this.IsSolid        = false;
            }
            else if (leftovers[1].IsSolid && (!leftovers[0].IsSolid))               //Case: l0 is liquid, l1 is solid
            {
                leftovers[1].Volume = 0.0f;
                this.IsSolid        = false;
            }
            else if (leftovers[0].IsSolid && leftovers[1].IsSolid)
            {
                this.IsSolid = true;
            }
            else if ((!leftovers[0].IsSolid) && (!leftovers[1].IsSolid))
            {
                this.IsSolid = false;
            }
        }
    }
Exemplo n.º 22
0
    //! Setup of reagent liquid in all machines.
    public void Setup(string reagent, float concentration)
    {
        Compound realReagent = CompoundFactory.GetInstance().GetCupboardCompound(reagent) as Compound;

        if (realReagent == null)
        {
            Debug.LogWarning("Reagent not seted in database");
            return;
        }


        allowShowFloat   = false;
        allowShowTexture = false;

        bool showFloat = false;

        switch (myType)
        {
        default:
        {
            setupFloat       = 0f;
            setupTexture     = null;
            allowShowFloat   = false;
            allowShowTexture = false;
        }
        break;

        case MACHINES.CONDUTIVIMETER:
        {
            setupFloat = realReagent.Conductibility;
            showFloat  = true;

            InventoryController inventory = FindObjectOfType(typeof(InventoryController)) as InventoryController;
        }
        break;

        case MACHINES.SPCTROPHOTOMETER_UV:
        {
            setupTexture     = realReagent.uvSpecter;
            allowShowTexture = true;

            InventoryController inventory = FindObjectOfType(typeof(InventoryController)) as InventoryController;
        }
        break;

        case MACHINES.SPCTROPHOTOMETER_IR:
        {
            setupTexture     = realReagent.irSpecter;
            allowShowTexture = true;

            InventoryController inventory = FindObjectOfType(typeof(InventoryController)) as InventoryController;
        }
        break;

        case MACHINES.TURBIDOMETER:
        {
            setupFloat = realReagent.Turbidity;
            showFloat  = true;

            InventoryController inventory = FindObjectOfType(typeof(InventoryController)) as InventoryController;
        }
        break;
        }

        if (showFloat)
        {
            resultFloat *= concentration;

            string errorStringForm = "0";
            if (errorPrecision > 0)
            {
                errorStringForm = "0.";
                for (int i = 0; i < errorPrecision; i++)
                {
                    errorStringForm += "0";
                }
            }

            textResult.text = applyErrorInFloat(resultFloat).ToString(errorStringForm);
        }

        if (allowShowTexture)
        {
            setupTexture = ChartGenerator.GenerateWithTextureConectingDots(setupTexture, concentration, 0.8f);
            HudText.SetText("O grafico foi Impresso!");
            GameObject.FindObjectOfType <PrinterUse>().SendFileToPrinter(setupTexture);
            timeToShowPrintTextAcc = Time.time;
        }
    }
    void OnGUI()
    {
        EditorGUILayout.BeginVertical();
        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Width(0), GUILayout.Height(0));

        EditorGUILayout.LabelField("Checar Reagente:");

        Dictionary <string, Compound> reagents = CompoundFactory.GetInstance().CupboardCollection;

        string[] names = new string[reagents.Count];

        int counter = 0;

        foreach (string name in reagents.Keys)
        {
            names[counter] = name;
            counter++;
        }

        indexOfComponent = EditorGUILayout.Popup(indexOfComponent, names);

        selectedComponent = names[indexOfComponent];

        if (selectedComponent != selectedComponentLastInteraction)
        {
            selected = false;
        }

        selectedComponentLastInteraction = selectedComponent;

        if (!selected)
        {
            if (GUILayout.Button("Checar"))
            {
                selected = true;
                reagent  = reagents[names[indexOfComponent]];
            }
        }

        if (selected)
        {
            EditorGUILayout.LabelField("Nome: " + reagent.Name);
            EditorGUILayout.LabelField("Formula :" + reagent.Formula);
            EditorGUILayout.LabelField("Massa Molar : " + reagent.MolarMass.ToString());
            EditorGUILayout.LabelField("Densidade : " + reagent.Density.ToString());
            EditorGUILayout.LabelField("Pureza : " + reagent.Purity.ToString());
            EditorGUILayout.LabelField("Polaridade: " + reagent.Polarizability.ToString());
            EditorGUILayout.LabelField("Condutividade: " + reagent.Conductibility.ToString());
            EditorGUILayout.LabelField("Solubilidade: " + reagent.Solubility.ToString());

            if (!reagent.IsSolid)
            {
                EditorGUILayout.LabelField("Ph : " + (reagent as Compound).PH.ToString());
                EditorGUILayout.LabelField("Turbilidade: " + (reagent as Compound).Turbidity.ToString());
                EditorGUILayout.LabelField("Refratometro: " + (reagent as Compound).Refratometer.ToString());
                EditorGUILayout.LabelField("Espectro de Chama: " + reagent.FlameSpecter.ToString());

                if ((reagent as Compound).hplc != null)
                {
                    EditorGUILayout.LabelField("HPLC : " + (reagent as Compound).hplc);
                }
                else
                {
                    EditorGUILayout.LabelField("HPLC : ");
                }
            }

            if (reagent.uvSpecter != null)
            {
                EditorGUILayout.LabelField("Espectro UV : " + reagent.uvSpecter.name);
            }
            else
            {
                EditorGUILayout.LabelField("Espectro UV : ");
            }

            if (reagent.irSpecter != null)
            {
                EditorGUILayout.LabelField("Espectro IR : " + reagent.irSpecter.name);
            }
            else
            {
                EditorGUILayout.LabelField("Espectro IR : ");
            }



            /*if(reagent.texture != null)
             * {
             *      EditorGUILayout.LabelField("Textura: " + reagent.texture.name);
             * }
             * else
             * {
             *      EditorGUILayout.LabelField("Textura: ");
             * }
             * EditorGUILayout.ColorField("Cor: ", reagent.color);*/
        }

        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
    }
Exemplo n.º 24
0
    //! Uses of reagent liquid in all machines.
    public void Use(string reagent, float concentration)
    {
        Compound realReagent = CompoundFactory.GetInstance().GetCupboardCompound(reagent) as Compound;

        if (realReagent == null)
        {
            Debug.LogWarning("Reagent not seted in database");
            return;
        }

        switch (myType)
        {
        case MACHINES.PHMETER:
        {
            resultFloat      = realReagent.PH;
            allowShowFloat   = true;
            allowShowTexture = false;
        }
        break;

        case MACHINES.CONDUTIVIMETER:
        {
            resultFloat      = realReagent.Conductibility - setupFloat;
            allowShowFloat   = true;
            allowShowTexture = false;
        }
        break;

        case MACHINES.SPCTROPHOTOMETER_UV:
        {
            resultTexture    = realReagent.uvSpecter;
            allowShowFloat   = false;
            allowShowTexture = true;
        }
        break;

        case MACHINES.SPCTROPHOTOMETER_IR:
        {
            resultTexture    = realReagent.irSpecter;
            allowShowFloat   = false;
            allowShowTexture = true;
        }
        break;

        case MACHINES.SPCTROPHOTOMETER_FLAME:
        {
            resultTexture = Resources.Load <Texture2D>("specter/grafico_sem_fitting");
            //resultTexture = realReagent.flameSpecter;
            allowShowFloat   = false;
            allowShowTexture = true;
        }
        break;

        case MACHINES.POLARIMETER:
        {
            resultFloat      = realReagent.Polarizability;
            allowShowFloat   = true;
            allowShowTexture = false;
        }
        break;

        case MACHINES.HPLC:
        {
            resultTexture    = realReagent.hplc;
            allowShowFloat   = false;
            allowShowTexture = true;
        }
        break;

        case MACHINES.REFRATOMETER:
        {
            resultFloat      = realReagent.Refratometer;
            allowShowFloat   = true;
            allowShowTexture = false;
        }
        break;

        case MACHINES.TURBIDOMETER:
        {
            resultFloat      = realReagent.Turbidity - setupFloat;
            allowShowFloat   = true;
            allowShowTexture = false;
        }
        break;
        }

        InventoryController inventory = FindObjectOfType(typeof(InventoryController)) as InventoryController;

        //!Prints the chart
        if (allowShowTexture)
        {
            resultTexture = ChartGenerator.GenerateWithTextureConectingDots(resultTexture, concentration, 0.8f);
            GameObject.FindObjectOfType <PrinterUse>().SendFileToPrinter(setupTexture);

            HudText.SetText("O grafico foi Impresso!");
            timeToShowPrintTextAcc = Time.time;
        }

        if (allowShowFloat)
        {
            resultFloat *= concentration;
        }
    }