コード例 #1
0
    //! 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;
            }
        }
    }
コード例 #2
0
    //! 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);
            }
        }
    }