Esempio n. 1
0
    public override void InteractWith(InteractiveThing thing)
    {
        var _rigidbody = GetComponent<Rigidbody>();

        _rigidbody.isKinematic = false;
        _rigidbody.useGravity = true;

        var force = throwForce;

        if (thing.GetComponent<ForceOverrider> ()) {
            force = thing.GetComponent<ForceOverrider>().newForce;
        }

        _rigidbody.AddForce((King.visitor.sight.facingVector + Vector3.up * 1.5f) * force, ForceMode.Impulse);

        StartCoroutine(UnblockCo());
    }
Esempio n. 2
0
    public override void InteractWith(InteractiveThing thing)
    {
        var _rigidbody = GetComponent <Rigidbody>();

        _rigidbody.isKinematic = false;
        _rigidbody.useGravity  = true;

        var force = throwForce;

        if (thing.GetComponent <ForceOverrider> ())
        {
            force = thing.GetComponent <ForceOverrider>().newForce;
        }

        _rigidbody.AddForce((King.visitor.sight.facingVector + Vector3.up * 1.5f) * force, ForceMode.Impulse);

        StartCoroutine(UnblockCo());
    }
    IEnumerator OpenLockCo(InteractiveThing thing)
    {
        var tempLock = thing.GetComponent <TempLock>();

        // Rotate the lock toward the key.
        var lockLookRotation = Quaternion.LookRotation(transform.position - tempLock.transform.position);

        LeanTween.rotate(tempLock.gameObject, lockLookRotation.eulerAngles, 0.5f);

        yield return(new WaitForSeconds(0.5f));

        // Move the key towards the lock.
        LeanTween.move(gameObject, tempLock.keyOutsidePoint.position, 2f).setEase(LeanTweenType.easeOutSine);
        LeanTween.rotate(gameObject, tempLock.keyOutsidePoint.rotation.eulerAngles, 1f).setEase(LeanTweenType.easeOutSine);

        yield return(new WaitForSeconds(2f + 0.25f));

        // Move the key inside the lock.
        LeanTween.move(gameObject, tempLock.keyInsidePoint.position, 0.25f).setEase(LeanTweenType.easeOutSine);

        if (_audioSource != null)
        {
            _audioSource.Play();
        }

        yield return(new WaitForSeconds(0.25f));

        // Rotate the key in the lock.
        LeanTween.rotate(gameObject, tempLock.keyInsidePoint.eulerAngles, 0.5f);

        yield return(new WaitForSeconds(0.5f));

        tempLock.receiver.Interact();

        transform.parent = tempLock.transform;

        LeanTween.move(tempLock.gameObject, tempLock.transform.position + tempLock.transform.forward * 0.25f, 1f).setEase(LeanTweenType.easeOutSine);

        yield return(new WaitForSeconds(1f));

        GetComponent <Rigidbody>().detectCollisions                 = false;
        tempLock.GetComponent <Rigidbody>().isKinematic             = false;
        tempLock.GetComponent <InteractiveThing>().isAbleToInteract = false;
    }
Esempio n. 4
0
    IEnumerator OpenLockCo(InteractiveThing thing)
    {
        var tempLock = thing.GetComponent<TempLock>();

        // Rotate the lock toward the key.
        var lockLookRotation = Quaternion.LookRotation(transform.position - tempLock.transform.position);
        LeanTween.rotate(tempLock.gameObject, lockLookRotation.eulerAngles, 0.5f);

        yield return new WaitForSeconds(0.5f);

        // Move the key towards the lock.
        LeanTween.move(gameObject, tempLock.keyOutsidePoint.position, 2f).setEase(LeanTweenType.easeOutSine);
        LeanTween.rotate(gameObject, tempLock.keyOutsidePoint.rotation.eulerAngles, 1f).setEase(LeanTweenType.easeOutSine);

        yield return new WaitForSeconds(2f + 0.25f);

        // Move the key inside the lock.
        LeanTween.move(gameObject, tempLock.keyInsidePoint.position, 0.25f).setEase(LeanTweenType.easeOutSine);

        if (_audioSource != null)
            _audioSource.Play();

        yield return new WaitForSeconds(0.25f);

        // Rotate the key in the lock.
        LeanTween.rotate(gameObject, tempLock.keyInsidePoint.eulerAngles, 0.5f);

        yield return new WaitForSeconds(0.5f);

        tempLock.receiver.Interact();

        transform.parent = tempLock.transform;

        LeanTween.move(tempLock.gameObject, tempLock.transform.position + tempLock.transform.forward * 0.25f, 1f).setEase(LeanTweenType.easeOutSine);

        yield return new WaitForSeconds(1f);

        GetComponent<Rigidbody>().detectCollisions = false;
        tempLock.GetComponent<Rigidbody>().isKinematic = false;
        tempLock.GetComponent<InteractiveThing>().isAbleToInteract = false;
    }