示例#1
0
        public void RemovePlug()
        {
            if (connectedPlug != null)
            {
                if (onUnplugged != null)
                {
                    onUnplugged();
                }

                CustomObject customObject = connectedPlug.GetComponentInParent <CustomObject>();
                customObject.transform.parent = null;

                connectedPlug = null;

                removePlugSound.Play();
            }
        }
示例#2
0
        public bool TryInsertPlug(Plug plug)
        {
            bool success = false;

            if (
                connectedPlug == null &&
                shape != SocketPlugShape.None &&
                plug.GetShape() == shape
                )
            {
                CustomObject customObject = plug.GetComponentInParent <CustomObject>();
                if (customObject != null)
                {
                    success = true;

                    connectedPlug = plug;
                    customObject.transform.parent = transform;

                    AnimatePlugTowardsUs(customObject);

                    insertPlugSound.Play();

                    Handable handable = GetComponentInParent <Handable>();
                    if (handable != null && handable.handHoldingMe != null)
                    {
                        handable.handHoldingMe.Vibrate(VibrationForce.Hard);
                    }

                    if (onPlugged != null)
                    {
                        onPlugged(plug);
                    }
                }
            }
            return(success);
        }