コード例 #1
0
    public void Release()
    {
        state             = GrappleHookFSM.UNHOOKED;
        ropeJoint.enabled = lineRenderer.enabled = false;
        if (onRelease != null)
        {
            onRelease(hookedOn);
        }

        // Stop listening for keypresses to alter rope length.
        InputManager.instance.onUpPressed   -= Contract;
        InputManager.instance.onDownPressed -= Loosen;

        StopCoroutine(HoldOn());
        if (hookedOn)
        {
            //get rid of this
            //check and call de-grapple events

            /*
             * Event target = hookedOn.GetComponent<Event>();
             * if (target)
             *  if(target.type == EEventType.ON_RELEASE)
             *      target.target.SendMessage(target.function);
             */
            hookedOn.Release();
            hookedOn = null;
        }
    }
コード例 #2
0
    public void Fire()
    {
        hookedOn = hookPicker.getBestHook();
        if (hookedOn)
        {
            if (hookedOn.Grapple())
            {
                state = GrappleHookFSM.HOOKED;
            }
            if (state == GrappleHookFSM.UNHOOKED)
            {
                return;
            }

            if (onSuccessfulGrapple != null)
            {
                onSuccessfulGrapple(hookedOn);
            }

            // Start listening for keypresses to alter rope length.
            InputManager.instance.onUpPressed   += Contract;
            InputManager.instance.onDownPressed += Loosen;

            //enable the rope physics
            ropeJoint.distance      = Vector2.Distance(transform.position, hookedOn.transform.position);
            ropeJoint.connectedBody = hookedOn.GetComponent <Rigidbody2D>();
            ropeJoint.enabled       = true;

            //draw the rope
            lineRenderer.enabled = true;
            StartCoroutine(HoldOn());

            // get rid of this
            //check and call grapple events

            /*
             * Event target = hookedOn.GetComponent<Event>();
             * if (target)
             *  if (target.type == EEventType.ON_GRAPPLE)
             *      target.target.SendMessage(target.function);
             */
            //MAKE IT HANDLE MULTIPLE EVENTS ON 1 GO
        }
    }