void UpdateGrabPosition(APEdgeGrab oGrab, ref Vector3 grabHandle, Color color, float radius)
    {
        Vector3 pointPos = oGrab.transform.TransformPoint(grabHandle);

        color.a       = 0.5f;
        Handles.color = color;
        Vector3 newPos = Handles.FreeMoveHandle(pointPos, Quaternion.identity, radius * 2f, Vector3.zero, Handles.SphereHandleCap);

        if (newPos != pointPos)
        {
            Undo.RecordObject(oGrab, "Move grab handle");
            grabHandle = oGrab.transform.InverseTransformPoint(newPos);

            // mark object as dirty
            EditorUtility.SetDirty(oGrab);
        }
    }
    public void OnSceneGUI()
    {
        APEdgeGrab oGrab = (APEdgeGrab)target;

        // draw handle
        if (oGrab.enabled)
        {
            if (oGrab.m_grabFromTop.m_enabled)
            {
                UpdateGrabPosition(oGrab, ref oGrab.m_grabFromTop.m_handle, Color.cyan, oGrab.m_grabFromTop.m_handleRadius);
            }

            if (oGrab.m_grabInAir.m_enabled)
            {
                UpdateGrabPosition(oGrab, ref oGrab.m_grabInAir.m_handle, Color.magenta, oGrab.m_grabInAir.m_handleRadius);
            }
        }
    }
    void HandleEdgeGrab(Collider2D otherCollider)
    {
        // Early exit
        if (!m_character || !m_character.m_edgeGrab.m_enabled || m_character.IsNewStateRequested() || m_character.IsControlled)
        {
            return;
        }

        APEdgeGrab compEdgeGrab = otherCollider.GetComponent <APEdgeGrab>();

        if (compEdgeGrab == null)
        {
            return;
        }

        // List of allowed from state
        APCharacterController.State[] allowedStates = { APCharacterController.State.Crouch, APCharacterController.State.Standard,  APCharacterController.State.Attack,
                                                        APCharacterController.State.Glide,  APCharacterController.State.WallSlide, APCharacterController.State.Shift };
        APCharacterController.State   curState = m_character.GetState();
        bool bAllowed = false;

        foreach (APCharacterController.State testState in allowedStates)
        {
            if (curState == testState)
            {
                bAllowed = true;
                break;
            }
        }

        if (bAllowed)
        {
            // we are touching a edge grab zone, give control if allowed
            compEdgeGrab.TryTakeControl(m_character, otherCollider);
        }
    }
Esempio n. 4
0
 public virtual void OnEdgeGrabEnd(APEdgeGrab grabObject)
 {
 }
Esempio n. 5
0
 public virtual void OnEdgeGrabStart(APEdgeGrab grabObject)
 {
 }