Exemple #1
0
    protected override void OnGripUp()
    {
        if (!grabEnabled)
        {
            return;
        }

        animator.SetBool("choking", false);

        if (coroutine != null)
        {
            StopCoroutine(coroutine);
            coroutine = null;
        }

        if (grabbedTarget != null) // note that this can be null when the target was killed while being grabbed
        {
            grabbedTarget.setFree();
            grabbedTarget.transform.SetParent(null);
            // let her shoot again
            var shootPlayer = grabbedTarget.gameObject.GetComponent <ShootPlayer>();
            if (shootPlayer != null)
            {
                shootPlayer.enabled = true;
            }
            grabbedTarget = null;
        }
    }
Exemple #2
0
    void Start()
    {
        rigidbody = GetComponent <Rigidbody>();

        platform = GameObject.FindGameObjectWithTag("Platform").transform;

        throwable = GetComponent <Throwable_OBJ>();
    }
Exemple #3
0
    protected override void OnGripUp()
    {
        if (!activated)
        {
            return;
        }

        activated = false;
        DisableUlti();

        float moveHeightEnd = (leftHand.position.y + rightHand.position.y) / 2;

        //Check if the controllers are [distance] higher as the position before OnGripsDown()
        if (moveHeightEnd - startMoveHeightL > 0.3f)
        {
            Debug.Log("Ultimate-Tracking successfull! #For_Lev OnGripUp()");
            //--> Do the Levitate!
            Collider[]      cols       = Physics.OverlapSphere(transform.position, rangeL);
            Throwable_OBJ[] behaviours = new Throwable_OBJ[cols.Length];
            int             counter    = 0;
            foreach (Collider col in cols)
            {
                if (col.tag == "Enemy")
                {
                    this.Delayed(0.1f, () => col.attachedRigidbody.AddRelativeForce(0, forceStrengthL, 0, ForceMode.Acceleration));
                    Throwable_OBJ obj = col.gameObject.GetComponent <Throwable_OBJ>();
                    obj.setGrabbed();//Enemy-Behaviours disablen?
                    behaviours[counter] = obj;
                }
            }
            ActivateEffect <Levitate_Reset>(10).init(behaviours);

            //DisableUlti();
        }
        else
        {
            Debug.Log("Ultimate-Tracking failed! #For_Lev OnGripUp()");
        }
    }
Exemple #4
0
    protected override void OnGripDown()
    {
        if (!grabEnabled || IsCoolingDown || isPushing) // don't allow grab while pushing
        {
            return;
        }

        if (grabbedTarget == null)
        {
            RaycastHit?   hit;
            Throwable_OBJ target = GetAimedAtTarget(out hit);

            if (hit == null)
            {
                return;
            }

            if (target.IsGrabbed())
            {
                return; // do not grab twice
            }
            animator.SetBool("choking", true);

            grabbedTarget = target;
            playGrabAudio();
            grabbedTarget.transform.SetParent(transform, true);
            grabbedTarget.setGrabbed();
            coroutine = Drain();
            StartCoroutine(coroutine);
            // prevent shooting
            var shootPlayer = grabbedTarget.gameObject.GetComponent <ShootPlayer>();
            if (shootPlayer != null)
            {
                shootPlayer.enabled = false;
            }
        }
    }
Exemple #5
0
    void LateUpdate()
    {
        if (!grabEnabled)
        {
            return;
        }

        if (grabbedTarget == null && !IsCoolingDown && !isPushing)
        {
            RaycastHit?   hit;
            Throwable_OBJ target = GetAimedAtTarget(out hit);

            aimPreview.enabled = true;
            aimPreview.SetPosition(0, nozzle.position);

            if (hit == null)
            {
                aimPreview.sharedMaterial = aimPreviewStandardMaterial;
                aimPreview.SetPosition(1, nozzle.TransformPoint(grabRange * Vector3.forward));
            }
            else
            {
                var     collider = target.GetComponent <Collider>();
                Vector3 pos      = (collider != null ? collider.bounds.center : target.transform.position);

                aimPreview.sharedMaterial = aimPreviewHighlightMaterial;
                aimPreview.SetPosition(1, pos);
                //Debug.Log("aiming at " + hit.Value.point, hit.Value.collider.gameObject);
            }
        }
        else if (aimPreview.enabled)
        {
            // disable preview while grabbing
            aimPreview.enabled = false;
        }
    }