Exemplo n.º 1
0
    public void ActionBoth(Dagger other)
    {
        if (TargetRigidbody != null && other.TargetRigidbody == TargetRigidbody)
        {
            if (TargetRigidbody.tag == "Enemy")
            {
                TargetRigidbody.GetComponentInParent <Guard>().Explode();
            }

            var retractionForce = (Vector3.up + transform.forward * -1f).normalized * RETRACT_PULL_FORCE;
            TargetRigidbody.AddForce(retractionForce, ForceMode.Impulse);
        }

        Action();
    }
Exemplo n.º 2
0
    IEnumerator Fire()
    {
        var        ray = camera.ScreenPointToRay(Mouse.current.position.ReadValue());
        RaycastHit hit;

        if (!Physics.Raycast(ray, out hit, RANGE, mask) || Vector3.Distance(hit.point, transform.position) <= PICKUP_RADIUS)
        {
            State = DaggerState.Holstered;
            yield break;
        }

        State = DaggerState.Firing;

        transform.parent = null;
        target           = hit.point;

        rope.enabled = true;

        interceptTrigger.enabled = true;

        audio.PlayOneShot(sounds.fire);

        while (interceptTrigger.enabled && !MoveToTarget(target, TRAVEL_SPEED))
        {
            rotationParent.Rotate(Vector3.forward, TRAVEL_ROTATION * Time.deltaTime, Space.Self);

            yield return(null);
        }

        State = DaggerState.Embedded;

        interceptTrigger.enabled = false;

        if (TargetRigidbody == null)
        {
            TargetRigidbody = hit.rigidbody;
        }

        if (TargetRigidbody && TargetRigidbody.tag == "Enemy")
        {
            TargetRigidbody.GetComponentInParent <Guard>().Die();
        }

        embedDistance = Vector3.Distance(originalParent.position, target) + EMBED_EXTRA_SLACK_DISTANCE;
    }