public void OpenOptionDialogEquipment()
 {
     if (CursorManager.GetCurrentState() != MouseState.ms_interacting)
     {
         optionDialogEquipment.SetActive(true);
         CursorManager.SetMouseState(MouseState.ms_interacting);
     }
 }
    //! Handles actions when on hovering the mouse
    //  Shows the infoCanvas (setting its position correctly), and makes the object glow when interaction is possible
    public void OnHoverIn()
    {
        if (GameObject.Find("GameController").GetComponent <GameController> ().GetCurrentState() !=
            GameObject.Find("GameController").GetComponent <GameController> ().gameStates [0])
        {
            infoCanvas.gameObject.SetActive(true);

            //Glowing state machine
            if (CursorManager.GetCurrentState() != MouseState.ms_interacting)
            {
                switch (CursorManager.GetCurrentState())
                {
                /*case MouseState.ms_default:       //Default -> Pot
                 *      potMesh.renderer.material.color = Color.white;
                 *      break;*/
                case MouseState.ms_pipette:                             //Pipette -> Pot
                    if (!isSolid)
                    {
                        //glow
                        potMesh.GetComponent <Renderer>().material.color = Color.white;
                    }
                    break;

                case MouseState.ms_filledPipette:                       // Filled Pipette -> Pot.
                    if (!isSolid && (GameObject.Find("GameController").GetComponent <GameController> ().GetCurrentState() as WorkBench).pipette.reagentInPipette.Formula == this.reagent.Formula)
                    {
                        //glow
                        potMesh.GetComponent <Renderer>().material.color = Color.white;
                    }
                    break;

                case MouseState.ms_spatula:                             // Spatula -> Pot.
                    if (isSolid)
                    {
                        potMesh.GetComponent <Renderer>().material.color = Color.white;
                    }
                    break;

                case MouseState.ms_filledSpatula:                       // Filled Spatula -> Pot.
                    if (isSolid && (GameObject.Find("GameController").GetComponent <GameController> ().GetCurrentState() as WorkBench).spatula.reagentInSpatula.Formula == this.reagent.Formula)
                    {
                        //glow
                        potMesh.GetComponent <Renderer>().material.color = Color.white;
                    }
                    break;

                default:
                    break;
                }
            }
        }
    }
    public void CloseAll()
    {
        optionDialogGlass.SetActive(false);
        optionDialogReagent.SetActive(false);
        optionDialogEquipment.SetActive(false);
        glasswareLabelEditor.SetActive(false);

        if (CursorManager.GetCurrentState() == MouseState.ms_interacting)
        {
            CursorManager.SetMouseState(MouseState.ms_default);
            CursorManager.SetCursorToDefault();
        }
    }
Example #4
0
    //! Close the interaction box
    public void CloseInteractionBox()
    {
        toggle.SetAllTogglesOff();
        boxToChooseSpatula.SetActive(false);
        boxToFillSpatula.SetActive(false);
        boxToUnfillSpatula.SetActive(false);

        if (CursorManager.GetCurrentState() == MouseState.ms_interacting)
        {
            CursorManager.SetMouseState(MouseState.ms_default);
            CursorManager.SetCursorToDefault();
        }
    }
Example #5
0
    //! 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 OpenOptionDialog(ItemToInventory item)
    {
        if (CursorManager.GetCurrentState() != MouseState.ms_interacting)
        {
            CursorManager.SetMouseState(MouseState.ms_interacting);
            if (item is Glassware)
            {
                if (gameObject.GetComponentInParent <WorkBench> ().positionGlassEquipament != null &&
                    gameObject.GetComponentInParent <WorkBench> ().positionGlassEquipament.childCount != 0 &&
                    item.gameObject.Equals(gameObject.GetComponentInParent <WorkBench> ().positionGlassEquipament.GetChild(0).gameObject))
                {
                    List <int> ids = new List <int> ();
                    ids.Add(0);
                    ids.Add(2);
                    optionDialogGlass.GetComponent <OptionDialogBehaviour> ().changeIDs(ids);
                }
                else
                {
                    List <int> ids = new List <int> ();
                    ids.Add(0);
                    ids.Add(1);
                    optionDialogGlass.GetComponent <OptionDialogBehaviour> ().changeIDs(ids);
                }
                optionDialogGlass.SetActive(true);
                optionDialogGlass.GetComponent <OptionDialogBehaviour> ().setCurrentItem(item);
                if (item.GetComponent <Glassware>().content == null)                 //Enabling or disabling the edit label button. TODO: Refactor later
                {
                    optionDialogGlass.GetComponent <OptionDialogBehaviour> ().editLabelButton.enabled     = false;
                    optionDialogGlass.GetComponent <OptionDialogBehaviour> ().editLabelButton.image.color = Color.grey;
                }
                else
                {
                    optionDialogGlass.GetComponent <OptionDialogBehaviour> ().editLabelButton.enabled     = true;
                    optionDialogGlass.GetComponent <OptionDialogBehaviour> ().editLabelButton.image.color = Color.white;
                }
                glasswareLabelEditor.GetComponent <OptionDialogBehaviour> ().setCurrentItem(item);
                return;
            }

            if (item is ReagentPot)
            {
                optionDialogReagent.SetActive(true);
                optionDialogReagent.GetComponent <OptionDialogBehaviour> ().setCurrentItem(item);

                return;
            }
        }
    }
Example #7
0
 void Update()
 {
     if (hoverName.Length == 0 && GetComponentInParent <WorkbenchInteractive> () != null)
     {
         hoverName = GetComponentInParent <WorkbenchInteractive> ().hoverName;
     }
     if (hovering)
     {
         if (CursorManager.GetCurrentState() == MouseState.ms_interacting)
         {
             cursorExit();
         }
         else
         {
             hover.position = Input.mousePosition + new Vector3(7f, 3f);
         }
     }
 }
Example #8
0
    //! 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();
        }
    }
Example #9
0
 //! Set cursor when mouse hover.
 public void cursorEnter()
 {
     if (CursorManager.GetCurrentState() != MouseState.ms_interacting && GameObject.Find("GameController").GetComponent <GameController>().currentStateIndex != 0)
     {
         if (hoverName.Length != 0)
         {
             hover.gameObject.SetActive(true);
             hover.GetComponentInChildren <Text> ().text = hoverName;
             float y = Input.mousePosition.x > 0 ? 180f : 0f;
             hover.rotation = Quaternion.Euler(0f, y, 0f);
             hover.GetComponentInChildren <Text> ().rectTransform.localRotation = Quaternion.Euler(0f, y, 0f);
             hovering = true;
         }
         if (changeIconeEnter)
         {
             if ((changeIconIfOnlyDefault && CursorManager.UsingDefaultCursor()) || !changeIconIfOnlyDefault)
             {
                 CursorManager.SetToInteractiveCursor(cursorTexture, hotSpot);
             }
         }
     }
 }
Example #10
0
    //! Holds the events for when the interactive pipette on the Workbench is clicked
    public override void OnClick()
    {
        if (GameObject.Find("GameController").GetComponent <GameController> ().GetCurrentState() !=
            GameObject.Find("GameController").GetComponent <GameController> ().gameStates [0])
        {
            MouseState currentState = CursorManager.GetCurrentState();

            switch (currentState)
            {
            case MouseState.ms_default:                         //Default -> Pipette: prepares the pipette for use
                //ChoosePipetteBox
                OnStartInteraction();
                break;

            case MouseState.ms_pipette:                         //Pipette -> Pipette: put back the pipette
                CursorManager.SetMouseState(MouseState.ms_default);
                CursorManager.SetCursorToDefault();
                break;

            case MouseState.ms_filledPipette:                   // Filled Pipette -> Pipette: nothing
                break;

            case MouseState.ms_spatula:                         // Spatula -> Piepette: change to pipette state
                OnStartInteraction();
                break;

            case MouseState.ms_filledSpatula:                   // Filled Spatula -> Pipette: nothing
                break;

            case MouseState.ms_washBottle:                      // Wash Bottle -> Pipette: change to pipette state
                OnStartInteraction();
                break;

            case MouseState.ms_interacting:                             // Unable to click somewhere else
                break;
            }
        }
    }
    //! Holds the events for when the interactive reagent pot on the Workbench is clicked
    public void OnClick()
    {
        if (GameObject.Find("GameController").GetComponent <GameController>().GetCurrentState() !=
            GameObject.Find("GameController").GetComponent <GameController>().gameStates [0])
        {
            MouseState currentState = CursorManager.GetCurrentState();
            Spatula    spatula      = (GameObject.Find("GameController").GetComponent <GameController> ().GetCurrentState() as WorkBench).spatula;
            Pipette    pipette      = (GameObject.Find("GameController").GetComponent <GameController> ().GetCurrentState() as WorkBench).pipette;

            switch (currentState)
            {
            case MouseState.ms_default:                         //Default -> Solid Reagent: open interaction box to take the reagent to the inventory?
                (GameObject.Find("GameController").GetComponent <GameController> ().GetCurrentState() as WorkBench).stateUIManager.OpenOptionDialog(this);
                break;

            case MouseState.ms_pipette:                         //Pipette -> Solid Reagent: nothing
                if (!isSolid)
                {
                    if (reagent.FumeHoodOnly)                                                                          //In case it should be use at the Fume Hood
                    {
                        if (GameObject.Find("GameController").GetComponent <GameController> ().currentStateIndex != 4) // If it is the FumeHoodState
                        {
                            GameObject.Find("GameController").GetComponent <GameController> ().sendAlert("Este reagente libera gases prejudiciais.\nDirija-se à capela");
                        }
                        else                             //Sub-case: being use at the fume hood.
                        {
                            if (pipette.graduated)
                            {
                                pipette.OpenGraduatedFillingBox(this.reagent);
                            }
                            else
                            {
                                pipette.FillVolumetricPipette(this.reagent.Name);
                            }
                        }
                    }
                    else                         //Case: doesn't need fume hood
                    {
                        if (pipette.graduated)
                        {
                            pipette.OpenGraduatedFillingBox(this.reagent);
                        }
                        else
                        {
                            pipette.FillVolumetricPipette(this.reagent.Name);
                        }
                    }
                }
                break;

            case MouseState.ms_filledPipette:                   // Filled Spatula -> Solid Reagent: nothing
                if (pipette.reagentInPipette.Name == this.reagent.Name)
                {
                    if (pipette.graduated)
                    {
                        pipette.OpenGraduatedUnfillingBox(this.reagent);
                    }
                    else
                    {
                        pipette.UnfillVolumetricPipette();
                    }
                }
                break;

            case MouseState.ms_spatula:                         // Spatula -> Solid Reagent: fill the spatula with the reagent clicked
                //spatula.OpenInteractionBox(true);
                //spatula.FillSpatula ((Compound)this.reagent.Clone ());
                if (isSolid)
                {
                    if (reagent.FumeHoodOnly)                                                                          //In case it should be use at the Fume Hood
                    {
                        if (GameObject.Find("GameController").GetComponent <GameController> ().currentStateIndex != 4) // If it is the FumeHoodState
                        {
                            GameObject.Find("GameController").GetComponent <GameController> ().sendAlert("Este reagente libera gases prejudiciais.\nDirija-se à capela");
                        }
                        else                             //Sub-case: being use at the fume hood.
                        {
                            spatula.FillSpatula(reagent.Name);
                        }
                    }
                    else                         //Case: doesn't need fume hood
                    {
                        spatula.FillSpatula(reagent.Name);
                    }
                }
                break;

            case MouseState.ms_filledSpatula:                   // Filled Spatula -> Solid Reagent: put back the content if it is the same reagent
                if (spatula.reagentInSpatula.Name == this.reagent.Name)
                {
                    spatula.UnfillSpatula();
                }
                //else
                //	GameObject.Find("GameController").GetComponent<GameController>().GetCurrentState().GetComponent<WorkBench>().differentReagentErrorBox.SetActive(true);
                break;

            case MouseState.ms_washBottle:                      // Wash Bottle -> Solid Reagent: nothing
                break;

            case MouseState.ms_interacting:                             // Unable to click somewhere else TODO:is this necessary?
                break;
            }
        }
    }
    //! Handles actions when on hovering the mouse
    //  Shows the infoCanvas (setting its position correctly), and makes the object glow when interaction is possible
    public void OnHoverIn()
    {
        //Checking where the infoCanvas is, and depending on that, sets it to a pre-defined position to make sure it's not out of the screen
        if (gameController.GetCurrentState() != gameController.gameStates [0])
        {
            if (CursorManager.GetCurrentState() != MouseState.ms_interacting)
            {
                if (content != null && (gameController.GetCurrentState() == gameController.gameStates [1] || gameController.GetCurrentState() == gameController.gameStates [4]) && infoCanvas != null)
                {
                    if (gameController.GetCurrentState().cameraState.WorldToScreenPoint(infoCanvas.position).x > (2 * gameController.GetCurrentState().cameraState.pixelWidth / 3))
                    {
                        infoCanvas.localPosition = new Vector3(otherX, infoCanvas.localPosition.y, infoCanvas.localPosition.z);
                    }
                    if (gameController.GetCurrentState().cameraState.WorldToScreenPoint(infoCanvas.position).y > gameController.GetCurrentState().cameraState.pixelHeight / 3)
                    {
                        infoCanvas.localPosition = new Vector3(infoCanvas.localPosition.x, infoCanvas.localPosition.y, otherZ);
                    }
                    if (content is Mixture)
                    {
                        tabValues [0].text = (content as Mixture).Leftover1Formula() + " + " + (content as Mixture).Leftover2Formula();
                        tabValues [1].text = "Massa Molar: ??";
                    }
                    else if (content is Compound)
                    {
                        tabValues [0].text = (content as Compound).Formula;

                        tabValues [1].gameObject.SetActive(true);
                        tabValues [1].text = "Massa Molar: " + string.Format("{0:0.00}", (content as Compound).MolarMass);
                    }
                    //infoCanvas.gameObject.SetActive (true);
                }

                //Glowing state machine
                switch (CursorManager.GetCurrentState())
                {
                /*case MouseState.ms_default:       //Default -> Glassware
                 *      glasswareMesh.renderer.material.color = Color.white;
                 *      break;*/
                case MouseState.ms_pipette:                             //Pipette -> Glassware
                    if (hasLiquid)
                    {
                        //glow
                        glasswareMesh.GetComponent <Renderer>().material.color = Color.white;
                    }
                    break;

                case MouseState.ms_filledPipette:                       // Filled Pipette -> Glassware.
                    if (this.GetLiquidVolume() < maxVolume)
                    {
                        //glow
                        glasswareMesh.GetComponent <Renderer>().material.color = Color.white;
                    }
                    break;

                case MouseState.ms_spatula:                             // Spatula -> Glassware.
                    if (hasSolid)
                    {
                        glasswareMesh.GetComponent <Renderer>().material.color = Color.white;
                    }
                    break;

                case MouseState.ms_filledSpatula:                       // Filled Spatula -> Glassware.
                    if (currentVolume < maxVolume)
                    {
                        //glow
                        glasswareMesh.GetComponent <Renderer>().material.color = Color.white;
                    }
                    break;

                case MouseState.ms_washBottle:                          // Washe Bottle -> Glassware.
                    if (this.GetLiquidVolume() < maxVolume)
                    {
                        //glow
                        glasswareMesh.GetComponent <Renderer>().material.color = Color.white;
                    }
                    break;

                default:
                    break;
                }
            }
        }
    }
    //! Holds the events for when the interactive spatula on the Workbench is clicked
    public void OnClick()
    {
        if (gameController.GetCurrentState() != gameController.gameStates [0])
        {
            MouseState currentState = CursorManager.GetCurrentState();

            if (content is Mixture)               //TODO:PROVISORIO!
            {
                if (currentState == MouseState.ms_default)
                {
                    (GameObject.Find("GameController").GetComponent <GameController> ().GetCurrentState() as WorkBench).stateUIManager.OpenOptionDialog(this);
                }
                else
                {
                    gameController.sendAlert("Este tipo de interação não está habilitada após uma possível reação");
                }
            }
            else
            {
                switch (currentState)
                {
                case MouseState.ms_default:                             //Default -> Glassware: show the interaction options
                    (GameObject.Find("GameController").GetComponent <GameController> ().GetCurrentState() as WorkBench).stateUIManager.OpenOptionDialog(this);
                    break;

                case MouseState.ms_pipette:                             //Pipette -> Glassware: gets the liquid, if there's only liquid inside. So, opens the pipette's interaction box.
                    Pipette pipette = (GameObject.Find("GameController").GetComponent <GameController> ().GetCurrentState() as WorkBench).pipette;
                    if (hasLiquid)
                    {
                        if (pipette.graduated)
                        {
                            pipette.OpenGraduatedFillingBox(currentVolume, this);
                            RefreshContents();
                        }
                        else
                        {
                            pipette.FillVolumetricPipette(this);
                            RefreshContents();
                        }
                    }
                    break;

                case MouseState.ms_filledPipette:                       // Filled Pipette -> Glassware: pours the pipette's contents into the glassware
                    Pipette filledPipette = (GameObject.Find("GameController").GetComponent <GameController> ().GetCurrentState() as WorkBench).pipette;
                    //filledPipette.UnfillPipette(this);
                    if (filledPipette.graduated)
                    {
                        filledPipette.OpenGraduatedUnfillingBox(maxVolume - currentVolume, this);
                    }
                    else
                    {
                        filledPipette.UnfillVolumetricPipette(this);
                        RefreshContents();
                    }
                    break;

                case MouseState.ms_spatula:                             // Spatula -> Glassware: gets the solids, if there's only solid inside. So, opens the spatula's interaction box
                    Spatula spatula = (GameObject.Find("GameController").GetComponent <GameController> ().GetCurrentState() as WorkBench).spatula;
                    Debug.Log("Spatula clickou no Glassware");
                    if (content != null)
                    {
                        Debug.Log("Glassware nao esta vazio");
                        if (content is Compound && (content as Compound).IsSolid)
                        {
                            Debug.Log("Enchendo a espatula");
                            spatula.FillSpatula(this);
                        }
                    }
                    break;

                case MouseState.ms_filledSpatula:                       // Filled Spatula -> Glassware: unloads the spatula into the glassare
                    Spatula filledSpatula = (GameObject.Find("GameController").GetComponent <GameController> ().GetCurrentState() as WorkBench).spatula;
                    //filledSpatula.OpenInteractionBox(maxVolume - currentVolume, this);
                    filledSpatula.UnfillSpatula(maxVolume - currentVolume, this);
                    break;

                case MouseState.ms_washBottle:                          // Washe Bottle -> Glassware: pours water into the glassware
                    WashBottle washBottle = (GameObject.Find("GameController").GetComponent <GameController> ().GetCurrentState() as WorkBench).washBottle;
                    washBottle.ActivateWashBottle(this.maxVolume - this.GetLiquidVolume(), this);
                    break;

                case MouseState.ms_interacting:                                 // Unable to click somewhere else
                    break;
                }
            }

            if (gameController.GetCurrentState() == gameController.gameStates[6])
            {
                (gameController.GetCurrentState().GetEquipmentController() as TurbidimeterController).bucketCanvas.SetActive(false);
            }
        }
    }