public void onClick(int index)
    {
        if (item is Glassware)
        {
            switch (actualIDs[index])
            {
            case 0:
                if (!item.GetComponent <Glassware>().hasReagents())
                {
                    GameObject temp = null;
                    for (int i = 0; i < prefabs.Count; i++)
                    {
                        if (((item as Glassware).gl.Contains(prefabs[i].GetComponent <Glassware>().name)))
                        {
                            temp = prefabs[i];
                        }
                    }
                    GameObject.Find("InventoryManager").GetComponent <InventoryManager>().AddGlasswareToInventory(temp.GetComponent <Glassware>());
                    Destroy(item.gameObject);
                }
                else
                {
                    if (GetComponentInParent <WorkBench>().equipmentController != null && item.transform.parent == GetComponentInParent <WorkBench>().positionGlassEquipament)
                    {
                        GetComponentInParent <WorkBench>().equipmentController.RemoveObjectInEquipament(item.gameObject);
                    }
                    GameObject.Find("InventoryManager").GetComponent <InventoryManager>().AddProductToInventory(item.gameObject);
                }
                break;

            case 1:
                GetComponentInParent <WorkBench>().PutGlassInEquip(item.gameObject);
                break;

            case 2:
                GetComponentInParent <WorkBench>().PutItemFromEquip(item.gameObject);
                break;
            }
        }

        if (item is ReagentPot)
        {
            switch (actualIDs[index])
            {
            case 0:
                ItemInventoryBase reagent = new ItemInventoryBase();
                Compound          r       = (item as ReagentPot).reagent.Clone() as Compound;
                reagent.addReagent(r);
                int prefabIndex = reagent.getItemType() == ItemType.Liquids?0:1;
                GameObject.Find("InventoryManager").GetComponent <InventoryManager>().AddReagentToInventory(prefabs[prefabIndex].GetComponent <ReagentPot>(), r);

                Destroy(item.gameObject);
                break;
            }
        }

        ui_manager.CloseAll();
    }
Example #2
0
    //! Actions for when the State ends.
    /*! Disable the Camera inside the state, deactivate. */
    public override void OnStopRun()
    {
        gameController.closeAlert();
        //cameraState.depth = -1;
        //cameraState.enabled = false;
        //cameraState.GetComponent<AudioListener> ().enabled = false;


        if (spatula != null)
        {
            spatula.OnStopRun();
        }

        if (pipette != null)
        {
            pipette.OnStopRun();
        }

        if (washBottle != null)
        {
            washBottle.OnStopRun();
        }

        stateUIManager.CloseAll();
    }