Beispiel #1
0
 public void Deactivate()
 {
     tracking  = false;
     activated = false;
     attachedObject.SetBusy(false);
     attachedObjectMover.transform.SetParent(null);
     attachedObjectMover.SetMoveMode(1);
     attachedObject.IgnoreCollision(this.GetComponent <BoxCollider>(), false);
     attachedObjectGrabbedBy.Grab(attachedObjectMover);
     attachedObjectTrigger = null;
     Debug.Log("Deactivated!");
     owningObject.SetBusy(false);
 }
Beispiel #2
0
    private void OnTriggerEnter(Collider other)
    {
        if (!activated && owningObject != null && !owningObject.GetBusy() && (owningObject.GetObjectMover().GetGrabbed() || owningObject.GetAttached()))
        {
            AttachmentTrigger trigger = other.GetComponent <AttachmentTrigger>();
            if (trigger)
            {
                Debug.Log("Plug: " + this.gameObject.name + ", collided with trigger: " + trigger.gameObject.name);
            }

            if (trigger && !trigger.GetOwningObject().GetBusy() &&
                trigger.attachmentType == this.attachmentType && trigger.GetOwningObject().GetObjectMover().GetGrabbed())
            {
                Debug.Log("Activating plug" + this.name + " via trigger: " + trigger.name);
                Activate(trigger);
            }
        }
    }
Beispiel #3
0
    public void Activate(AttachmentTrigger trigger)
    {
        activated = true;

        if (trigger != null)
        {
            attachedObjectTrigger   = trigger;
            attachedObject          = trigger.GetOwningObject();
            attachedObjectMover     = attachedObject.GetObjectMover();
            attachedObjectGrabbedBy = attachedObjectMover.GetGrabbedBy();
        }

        if (attachedObject != null && attachedObjectMover && attachedObjectGrabbedBy)
        {
            attachedObject.SetBusy(true);
            inlineRot = GetLocalInlineRotation(attachedObjectMover.transform);
            attachedObjectGrabbedBy.Release();
            //attachedObjectMover.SetMoveMode(2);
            //attachedObjectGrabbedBy.Grab(attachedObjectMover);
            moveGuide.SetParent(this.transform);
            moveGuide.SetPositionAndRotation(attachedObjectTrigger.transform.position, attachedObjectTrigger.transform.rotation);
            attachedObject.KillCollision();
            attachedObject.KillPhysics();
            attachedObject.IgnoreCollision(owningObject.GetGameObject().GetComponent <BoxCollider>(), true);
            attachedObjectMover.transform.localRotation = inlineRot;
            //moveObjectOffeset = Vector3.Magnitude(attachedObjectMover.transform.position - attachedObjectGrabbedBy.transform.position);
            attachedObjectMover.transform.SetParent(moveGuide);

            //attachedObjectMover.transform.SetParent(moveGuide);
            tracking = true;
            owningObject.SetBusy(true);
        }
        else
        {
            Deactivate();
        }
    }