public override bool AttachTo(GrabTarget gt, bool turnAround = true)
 {
     legGrabTarget.gameObject.SetActive(true);
     runAI     = false;
     waitTimer = 0;
     return(base.AttachTo(gt, turnAround));
 }
Пример #2
0
 public void Target(GrabTarget grabTarget)
 {
     if (grabTarget != null)
     {
         targetGrabTarget = grabTarget;
         target           = grabTarget.gameObject;
         //Debug.Log("Targeting " + target.name);
     }
 }
 private void ResetVars()
 {
     targetNum        = 0;
     numDetected      = 0;
     targetManager    = null;
     successNode      = "";
     failNode         = "";
     targetGrabTarget = null;
     targetTrick      = "";
     detecting        = false;
 }
Пример #4
0
 public bool Deattach()
 {
     if (grabTarget == null)
     {
         return(false);
     }
     grabTarget.joint.connectedBody = null;
     grabTarget.joint.enabled       = false;
     lastGrabTarget = grabTarget;
     grabTarget     = null;
     SetState(EnumPTrapezeState.InAir);
     return(true);
 }
Пример #5
0
 private bool TryGetTarget(XRRayInteractor interactor, out GrabTarget target)
 {
     if (interactor.GetCurrentRaycastHit(out var hit))
     {
         if (hit.transform.TryGetComponent(out GrabTarget grabTarget))
         {
             target = grabTarget;
             return(true);
         }
     }
     target = null;
     return(false);
 }
Пример #6
0
 protected void DoInAir()
 {
     if (target != null)
     {
         if (target.transform.position.y > head.transform.position.y ||
             (goingRight && target.transform.position.x + grabRangeTargetingOffest < torsoRB.position.x) ||
             (!goingRight && target.transform.position.x - grabRangeTargetingOffest > torsoRB.position.x))
         {
             Debug.Log(gameObject.name + " gave up on targeting " + targetGrabTarget.gameObject.name);
             if (target.transform.position.y > head.transform.position.y)
             {
                 Debug.Log("Because target.transform.position.y " + target.transform.position.y + " > head.transform.position.y " + head.transform.position.y);
             }
             else if (goingRight && target.transform.position.x + grabRangeTargetingOffest < torsoRB.position.x)
             {
                 Debug.Log("Because goingRight && target.transform.position.x + grabRangeTargetingOffest < torsoRB.position.x");
             }
             else
             {
                 Debug.Log("Because !goingRight && target.transform.position.x-grabRangeTargetingOffest > torsoRB.position.x");
             }
             target           = null;
             targetGrabTarget = null;
         }
         else
         {
             torsoRB.MovePosition(Vector2.MoveTowards(torsoRB.position, target.transform.position, targetMoveSpeed * Time.deltaTime));
             upperArmsRB.MovePosition(Vector2.MoveTowards(upperArmsRB.position, target.transform.position, targetMoveSpeed * Time.deltaTime));
             if (Mathf.Abs(upperArmsRB.position.x - target.transform.position.x) <= grabRange &&
                 Mathf.Abs(upperArmsRB.position.y - target.transform.position.y) <= grabRange)
             {
                 Debug.Log(gameObject.name + " is attempting to attach to " + targetGrabTarget.gameObject.name); //+ " returned "+ AttachTo(targetGrabTarget));
                 AttachTo(targetGrabTarget);
             }
         }
     }
     if (jumpX - headRB.position.y >= fallDis)
     {
         if (punishFall)
         {
             TrickGUI.GetInstance().DecreaseScore(10);
         }
         AttachToInitial();
     }
     //Debug.Log(jumpX - headRB.position.x);
 }
    public void DetectAttachTo(string target, string grabTarget, string nextNode)
    {
        Debug.Log("Detect grab");
        if (detecting)
        {
            return;
        }
        detecting = true;
        //Debug.Log("Detect grab made it to past detecting check");
        SetTarget(target);
        //Debug.Log("grabTarget == " + grabTarget + ", is right? " + (grabTarget.Equals("right")));
        if (grabTarget.Equals("right"))
        {
            targetGrabTarget = rightTrapezeTarget;
        }
        else if (grabTarget.Equals("left"))
        {
            targetGrabTarget = leftTrapezeTarget;
        }
        else if (grabTarget.Equals("donna"))
        {
            targetGrabTarget = donnaLegTarget;
        }
        else if (grabTarget.Equals("player"))
        {
            targetGrabTarget = playerLegTarget;
        }
        else
        {
            return;
        }
        //Debug.Log("Detect grab made it to past grab target check");
        if (targetManager == null)
        {
            return;
        }
        //Debug.Log("Detect grab made it to past target check");
        successNode = nextNode;
        targetManager.OnAttachTo += this.InvokeAttachToDetected;

        //Debug.Log("Detect grab made it to end");
    }
Пример #8
0
    public virtual bool AttachTo(GrabTarget gt, bool turnAround = true)
    {
        Joint2D joint2D = gt.joint;

        /*Debug.Log("Joint2d is null?" + (joint2D == null));
         * Debug.Log("Connected body is not null?" + (joint2D.connectedBody != null));*/
        if (joint2D == null || joint2D.connectedBody != null)
        {
            return(false);
        }
        if (canSloMo && gm.IsSloMoAllowed() && gm.InSloMo())
        {
            gm.ToggleSloMo();
        }
        if (jumpX - headRB.position.y >= fallDis)
        {
            MassTeleport(joint2D.gameObject.transform.position);
        }
        ClearForce();
        target           = null;
        targetGrabTarget = null;
        jumpX            = 0;
        if (initGrabTarget == null)
        {
            initGrabTarget = gt;
            lastGrabTarget = gt;
        }
        grabTarget            = gt;
        joint2D.enabled       = true;
        joint2D.connectedBody = upperArmsRB;
        SetState(EnumPTrapezeState.OnTrapeze);
        if (grabTarget != lastGrabTarget)
        {
            OnAttachTo();
        }
        if (turnAround && grabTarget != lastGrabTarget)
        {
            TurnAround();
        }
        return(true);
    }
Пример #9
0
 private void Awake()
 {
     m_grabStyles = (GrabStyle[])Enum.GetValues(typeof(GrabStyle));
     m_target     = null;
 }