Esempio n. 1
0
    public bool StockAliment(GrabableObject _grabable, bool _sendOnline)
    {
        if (haveObject == false)
        {
            Debug.Log("Gastro");
            Aliment newAliment = _grabable.GetComponent <Aliment>();
            if (newAliment != null && _grabable.Grab(null, transform, false))
            {
                Debug.Log("Take");
                alimentStocked = newAliment;
                alimentStocked.transform.position = posAliment.transform.position;
                alimentStocked.transform.rotation = posAliment.transform.rotation;

                haveObject = true;
                isClean    = false;

                if (_sendOnline)
                {
                    photonView.RPC("NetworkStockAliment", RpcTarget.Others, _grabable.photonView.ViewID);
                }
                return(true);
            }
            return(false);
        }

        return(false);
    }
Esempio n. 2
0
 private void TryGrab(Interactable _targetObject, Transform _handTransform, ref GrabableObject _grabbedObject)
 {
     if (_targetObject is GrabableObject)
     {
         if (_targetObject && !_grabbedObject)
         {
             GrabableObject obj = _targetObject as GrabableObject;
             _grabbedObject = obj.Grab(_handTransform);
         }
     }
 }
Esempio n. 3
0
    private void NetworkStockAliment(int _alimentViewID)
    {
        PhotonView     objPhotonView  = PhotonView.Find(_alimentViewID);
        Aliment        newAliment     = objPhotonView.GetComponent <Aliment>();
        GrabableObject grabableObject = objPhotonView.GetComponent <GrabableObject>();

        if (newAliment != null && grabableObject.Grab(null, transform, false))
        {
            alimentStocked = newAliment;
            alimentStocked.transform.position = posAliment.transform.position;
            alimentStocked.transform.rotation = posAliment.transform.rotation;
            haveObject = true;
            isClean    = false;
        }
    }
    void OnTriggerStay(Collider other)
    {
        GrabableObject obj = other.GetComponent <GrabableObject>();

        //Checks if the object is already being held and grabs it if not
        if (obj != null && obj.Parent == null)
        {
            if (obj.Grab(this.gameObject))
            {
                m_storedObject = obj.gameObject;
                //Disables the collider from grabbing other object
                m_collider.enabled = !m_collider.enabled;
            }
        }
        else
        {
            Debug.Log("Not Grabbable");
        }
    }