示例#1
0
    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();
    }
示例#2
0
    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);
                }
            }
        }
    }