Exemplo n.º 1
0
    void OnTriggerStay(Collider coll)
    {
        if (grabbed)
        {
            return;
        }
        var g = coll.GetComponentInParent <Socketable>();

        if (g)
        {
            if (grabCandidate)
            {
                if (g.priority > grabCandidate.priority || grabCandidate.IsRetainedByScrews() && !g.IsRetainedByScrews())
                {
                    grabCandidate.highlighter.OnHoverEnd();
                }
                else
                {
                    return;
                }
            }
            grabCandidate = g;
            g.highlighter.OnHoverBegin();
        }
    }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     draw = false;
     if (grabber.grabbed)
     {
         Socketable s = grabber.grabbed.GetComponent <Socketable>();
         if (s && s.currentSocket)
         {
             draw = true;
         }
     }
     if (draw || test)
     {
         if (!indicator.gameObject.activeInHierarchy)
         {
             indicator.gameObject.SetActive(true);
         }
         indicator.Rotate(new Vector3(0, Time.deltaTime * spinSpeed, 0));
         bobV += bobSpeed * Time.deltaTime;
         indicator.localPosition += Vector3.up * Mathf.Sin(bobV) * bobAmount;
     }
     if (!test && !draw && indicator.gameObject.activeInHierarchy)
     {
         indicator.gameObject.SetActive(false);
     }
 }
Exemplo n.º 3
0
 private void OnTriggerExit(Collider other)
 {
     if (other.gameObject == socketable.gameObject)
     {
         meshRenderer.enabled = true;
         socketable           = null;
     }
 }
Exemplo n.º 4
0
    void OnTriggerExit(Collider other)
    {
        Socketable s = other.GetComponent <Socketable>();

        if (s && s == driver.currentScrew)
        {
            driver.currentScrew = null;
        }
    }
Exemplo n.º 5
0
    void OnTriggerEnter(Collider other)
    {
        Socketable s = other.GetComponent <Socketable>();

        if (s && s.socketType == Socket.SocketType.Screw && s.currentSocket)
        {
            driver.currentScrew = s;
        }
    }
Exemplo n.º 6
0
 public void TryDrop()
 {
     if (grabbed)
     {
         myRenderer.enabled = true;
         grabbed.Drop();
         grabbed = null;
         rotateH = 0;
         rotateV = 0;
     }
 }
Exemplo n.º 7
0
 public bool TryGrab()
 {
     if (grabCandidate && grabCandidate.CanBeRemoved())
     {
         grabbed = grabCandidate;
         grabCandidate.highlighter.OnHoverEnd();
         myRenderer.enabled = false;
         grabbed.Grab(this);
         return(true);
     }
     return(false);
 }
Exemplo n.º 8
0
    void OnTriggerExit(Collider coll)
    {
        if (grabbed)
        {
            return;
        }
        var g = coll.GetComponentInParent <Socketable>();

        if (g && g == grabCandidate)
        {
            grabCandidate = null;
            g.highlighter.OnHoverEnd();
        }
    }
Exemplo n.º 9
0
 public void CanStore(UnityAction onFailed, Socketable socketable, Socket socket)
 {
     //filter out what can and can't be socketed
     if (AllowedIds != null && AllowedIds.Length > 0)
     {
         var type = socketable.GetComponent <SocketableType>();
         if (type == null || HashedString.DoNotContain(AllowedIds, type.TypeName.Hash))
         {
             //let the inventory know that things are not well
             onFailed();
             return;
         }
     }
 }
Exemplo n.º 10
0
    private void OnTriggerEnter(Collider other)
    {
        // Try to find a socketable
        socketable = other.GetComponent <Socketable>();

        // If there isn't one, exit the method
        if (socketable == null)
        {
            return;
        }

        // If this isn't a type we accept, exit the method
        if (socketable.Type != acceptedSocketableType)
        {
            return;
        }

        // find the grabbable
        OVRGrabbable grabbable = other.GetComponent <OVRGrabbable>();

        if (grabbable != null && grabbable.isGrabbed)
        {
            // Whatever this grabbable is grabbed by
            // force it to release this grabbable
            grabbable.grabbedBy.ForceRelease(grabbable);
        }

        meshRenderer.enabled = false;
        socketable.GetComponent <Rigidbody>().isKinematic = true;

        if (doTween)
        {
            StartCoroutine(MoveIntoPlace(socketable.transform, duration));
        }
        else
        {
            socketable.transform.position = this.transform.position;
            socketable.transform.rotation = this.transform.rotation;
        }
    }
Exemplo n.º 11
0
 // Start is called before the first frame update
 void Start()
 {
     mySocketable = GetComponent <Socketable>();
 }