public void OnUnplug(Jackable jack) { var thisCall = activeCalls.Find(a => a.Caller == jack.id); if (thisCall != null) { jack.currently_plugged_in.ParentWire.plug_a.GetComponent <WireGrabObject>().currently_plugged_in_to.set_light_state(0); if (jack.currently_plugged_in.ParentWire.plug_b.GetComponent <WireGrabObject>().currently_plugged_in_to != null) { jack.currently_plugged_in.ParentWire.plug_b.GetComponent <WireGrabObject>().currently_plugged_in_to.set_light_state(0); } } else { jack.set_light_state(0); } if (jack.id >= 0) { foreach (Call c in activeCalls) { if (c.Caller == jack.id || c.Callee == jack.id) { jack.currently_plugged_in.ParentWire.plug_a.GetComponent <WireGrabObject>().currently_plugged_in_to.set_light_state(0); jack.currently_plugged_in.ParentWire.plug_b.GetComponent <WireGrabObject>().currently_plugged_in_to.set_light_state(0); OnBadConnection(c); break; } } } BellAudioSource.Stop(); }
void Start() { rb = GetComponent <Rigidbody>(); plug_list = new List <Jackable>(); currently_plugged_in_to = null; jackingin = GetComponent <AudioSource>(); }
public override void grab(GameObject controller) { grabber = controller.transform; rb.isKinematic = true; //Plug in jack if (currently_plugged_in_to != null) { sceneManager.OnUnplug(currently_plugged_in_to); currently_plugged_in_to.unplug(); currently_plugged_in_to = null; } }
public override void release() { rb.isKinematic = false; rb.velocity = grabber.gameObject.GetComponent <Rigidbody>().velocity; rb.angularVelocity = grabber.gameObject.GetComponent <Rigidbody>().angularVelocity; grabber = null; //Plug in jack foreach (Jackable j in plug_list) { if (j.plug_try_the_waters()) { j.plugin(this); currently_plugged_in_to = j; sceneManager.OnPlugIn(ParentWire, currently_plugged_in_to); jackingin.Stop(); int r = Random.Range(0, 2); if (r == 0) { jackingin.clip = jackin0; } else if (r == 1) { jackingin.clip = jackin1; } else { jackingin.clip = jackin2; } jackingin.Play(); break; } } }
public void OnPlugIn(Wire wire, Jackable jack) { Jackable a_jack = wire.plug_a.GetComponent <WireGrabObject>().currently_plugged_in_to; Jackable b_jack = wire.plug_b.GetComponent <WireGrabObject>().currently_plugged_in_to; if (a_jack == null || b_jack == null) { var thisCall = activeCalls.Find(a => (a_jack == null) ? a.Caller == b_jack.id : a.Caller == a_jack.id); if (thisCall != null) { if (jack.id == thisCall.Caller) { jack.set_light_state(1); } } } else { Jackable otherEndOfWire = jack.id == a_jack.id ? b_jack : a_jack; var thisCall = activeCalls.Find(a => a.Caller == a_jack.id || a.Caller == b_jack.id); if (thisCall != null) { if (jack.id == thisCall.Caller) { jack.set_light_state(1); otherEndOfWire.set_light_state(1); } else { if (otherEndOfWire.id == thisCall.Caller) { jack.set_light_state(1); } } } if (thisCall != null) { if (jack.id == -1 || otherEndOfWire.id == -1) { OnBellConnection(thisCall); if (thisCall.call.state == IncomingCalls.CallState.unanswered) { thisCall.call.state = IncomingCalls.CallState.answered; } } else if (jack.id == thisCall.Callee || otherEndOfWire.id == thisCall.Callee) { OnSuccessfulConnection(thisCall); thisCall.call.state = IncomingCalls.CallState.connected; } else { jack.set_light_state(0); otherEndOfWire.set_light_state(0); OnBadConnection(thisCall); } } } }