Esempio n. 1
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.I))
     {
         if (toggleInventory)                    //turning inventory OFF
         {
             if (heldItem == im.FindItemByID(0)) //if no item is held
             {
                 toggleInventory = false;
                 st.mamAimMode();
             }
             else
             {
                 closeInventory    = true;
                 dropHeldItemCheck = true;
             }
         }
         else             //turning inventory ON
         {
             toggleInventory = true;
             st.mamGuiMode();
         }
     }
 }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
//		if(Input.GetKeyDown(KeyCode.LeftAlt) && st.workbench == null)
//		{
//			st.mamToggle();
//		}

        if (Input.GetKeyDown(KeyCode.I))
        {
            if (isInventoryOn)            //turning inventory OFF
            {
                isInventoryOn = false;
                if (st.isPlayerCameraSet == true)
                {
                    st.mamAimMode();
                }
            }
            else             //turning inventory ON
            {
                isInventoryOn = true;
                st.mamGuiMode();
            }
        }

        if (st.workbench != null && st.workbench.GetComponent <Workbench>().isUsingWorkbench)
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (craftObject == null)
                {
                    RaycastHit tempHit;
                    Ray        tempRay = GetComponent <Camera>().ScreenPointToRay(Input.mousePosition);
                    if (Physics.Raycast(tempRay, out tempHit))
                    {
                        if (tempHit.collider.transform.parent.tag == "Item")
                        {
                            craftObject = tempHit.collider.transform.parent.gameObject;
                            foreach (Transform trans in craftObject.GetComponentsInChildren <Transform>(true))
                            {
                                trans.gameObject.layer = 12;
                            }
                            //craftObject.rigidbody.isKinematic = true;
                        }
                    }
                }
                else if (craftObject != null)
                {
                    foreach (Transform trans in craftObject.GetComponentsInChildren <Transform>(true))
                    {
                        trans.gameObject.layer = 0;
                    }
                    //craftObject.rigidbody.isKinematic = false;
                    craftObject = null;
                }
            }
            else if (Input.GetMouseButtonDown(1))
            {
                if (craftObject == null)
                {
                    RaycastHit tempHit;
                    Ray        tempRay = GetComponent <Camera>().ScreenPointToRay(Input.mousePosition);
                    if (Physics.Raycast(tempRay, out tempHit))
                    {
                        if (tempHit.collider.transform.parent.tag == "Item")
                        {
                            st.workbench.GetComponent <Workbench>().addRemove(tempHit.collider.transform.parent.gameObject);
                        }
                    }
                }
            }

            if (craftObject != null)
            {
                RaycastHit hitobj;
                Ray        ray       = GetComponent <Camera>().ScreenPointToRay(Input.mousePosition);
                int        layerMask = 1 << 12;
                layerMask = ~layerMask;
                if (Physics.Raycast(ray, out hitobj, 10.0f, layerMask))
                {
                    craftObject.transform.position = hitobj.point;
                }
            }
        }
    }