Esempio n. 1
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (currentGrappleState == GrapplingState.Reeling)
     {
         //Debug.Log("collision check");
         rb_Component.velocity = Vector2.zero;
         currentGrappleState   = GrapplingState.Holding;
     }
 }
Esempio n. 2
0
    private void OnCollisionStay2D(Collision2D collision)
    {
        //Debug.Log("currently colliding");

        if (currentGrappleState == GrapplingState.Reeling && rb_Component.velocity.magnitude <= .1f && holding == false && Time.time >= reelStartTime)
        {
            //Debug.Log("collision check");
            rb_Component.velocity = Vector2.zero;
            currentGrappleState   = GrapplingState.Holding;
        }
    }
Esempio n. 3
0
 void CheckCooldown()
 {
     // check end of cooldown
     if (currentGrappleState == GrapplingState.Cooldown)
     {
         if (Time.time >= grappleRechargeTime)
         {
             currentGrappleState = GrapplingState.Ready;
         }
     }
 }
Esempio n. 4
0
    public void HookBreak()
    {
        //break hook manually
        currentGrappleState = GrapplingState.Cooldown;
        //rb_Component.isKinematic = false;

        rb_Component.gravityScale = 1;

        grappleRechargeTime = Time.time + grappleCooldown;
        Destroy(currentRope);
        Destroy(currentHook);
        Destroy(currentBase);
        anim.SetBool("Grapple", false);
    }
Esempio n. 5
0
 public void StopGrapple()
 {
     showRope         = false;
     grapplingState   = GrapplingState.Normal;
     lr.positionCount = 0;
     Destroy(joint);
     handsAnimator.ResetTrigger("Grappling");
     handsAnimator.SetTrigger("StopGrappling");
     crosshair.RevertCrossHairSize();
     crosshair.RevertCrosshairColor();
     if (lastGrapple != null)
     {
         lastGrapple.GetComponent <MeshRenderer>().material.SetColor("_EmissionColor", original * 0.0150f);
     }
 }
Esempio n. 6
0
 public void StartGrapple()
 {
     anim.SetBool("Grapple", true);
     //begin hold, start shooting
     holding             = true;
     currentGrappleState = GrapplingState.Shooting;
     // delay shoot if there is a delay, otherwise, shoot
     if (grappleShootDelay > 0)
     {
         Invoke("ShootGrapple", grappleShootDelay);
     }
     else
     {
         ShootGrapple();
     }
 }
Esempio n. 7
0
    /*  void StartGrapple()
     * {
     *    if (grapplingState == GrapplingState.Normal)
     *    {
     *        GameObject close;
     *
     *        if (Physics.Raycast(cameraTransform.position, cameraTransform.forward, out grappleHit, maxDistance, whatIsGrappleable))
     *        {
     *            showRope = true;
     *            lr.positionCount = 2;
     *            autoAim = false;
     *            aimPoint.transform.position = grappleHit.point;
     *            aimPoint.SetActive(true);
     *            StartGrappleHelper(grappleHit.collider.gameObject);
     *            grapplePoint = grappleHit.point;
     *        }
     *        else if (playerControl.GetGrapplingAutoAimStatus() && (close = FindGrapplePoint()) != null)
     *        {
     *            // should i make it actually shoot to the player
     *            showRope = true;
     *            lr.positionCount = 2;
     *            autoAim = true;
     *            aimPoint.transform.position = close.transform.position;
     *            aimPoint.SetActive(true);
     *            StartGrappleHelper(close.gameObject);
     *            grapplePoint = lastGrapple.transform.position;
     *        }
     *    }
     *    else
     *    {
     *        aimPoint.SetActive(false);
     *    }
     * } */

    void StartGrappleHelper(GameObject g)
    {
        grapplingState = GrapplingState.Grappling;

        // Wait for the counter to hit zero before the grapple takes place.
        ropeShootCounter = ropeShootLength;

        // Only animate the hands if you shoot the grappling gun.
        handsAnimator.ResetTrigger("StopGrappling");
        handsAnimator.SetTrigger("Grappling");
        soundManager.PlayGrapplingSound();
        lastGrapple = g;
        g.GetComponent <MeshRenderer>().material.SetColor("_EmissionColor", neonGreen * 0.0150f);

        crosshair.ChangeCrossHairColor();
    }
Esempio n. 8
0
    void HoldCheck()
    {
        // end hook hold
        if (!holding && currentGrappleState == GrapplingState.Holding)
        {
            currentGrappleState = GrapplingState.Cooldown;
            //rb_Component.isKinematic = false;

            rb_Component.gravityScale = 1;

            grappleRechargeTime = Time.time + grappleCooldown;
            Destroy(currentRope);
            Destroy(currentHook);
            Destroy(currentBase);
            anim.SetBool("Grapple", false);
        }
    }
Esempio n. 9
0
    public void Reel()
    {
        // if reeling,
        if (currentGrappleState == GrapplingState.Reeling)
        {
            // get direction to the hook, create velocity in that direction
            Vector3 newVelocity;
            newVelocity           = (currentHook.GetComponent <Hook>().lockPoint.transform.position - this.transform.position);
            newVelocity           = Vector3.Normalize(newVelocity) * grappleReelSpeed;
            rb_Component.velocity = newVelocity;

            // if going to overshoot the lockpoint, lock onto the lockpoint
            if ((Vector2.Distance(this.transform.position, currentHook.GetComponent <Hook>().lockPoint.transform.position)) <= (grappleReelSpeed * Time.fixedDeltaTime))
            {
                // Debug.Log("lockpoint check");
                rb_Component.velocity = Vector2.zero;
                rb_Component.position = currentHook.GetComponent <Hook>().lockPoint.transform.position;
                currentGrappleState   = GrapplingState.Holding;
            }
        }
    }
Esempio n. 10
0
 public void BeginReel()
 {
     // set reel state
     currentGrappleState = GrapplingState.Reeling;
     reelStartTime       = Time.time + reelStartLeniency;
 }