Esempio n. 1
0
 public void ResetTarget()
 {
     target = null;
     hitInfo = new RaycastHit();
     reticle.ResetTargetBodyScale();
     focusOnTargetWithoutInterruptionSec = 0;
 }
Esempio n. 2
0
    IEnumerator SummonHeartCo(InteractiveThing thing)
    {
        if (this.name == "skull1")
        {
            LeanTween.move(this.gameObject, new Vector3(ring1.transform.position.x, ring1.transform.position.y + 0.3f, ring1.transform.position.z), 2f).setEase(LeanTweenType.easeOutSine);
            LeanTween.rotate(this.gameObject, new Vector3(0, 0, 0), 2f).setEase(LeanTweenType.easeOutSine);
            skullCount++;
        }
        else if (this.name == "skull2")
        {
            LeanTween.move(this.gameObject, new Vector3(ring2.transform.position.x, ring2.transform.position.y + 0.3f, ring2.transform.position.z), 2f).setEase(LeanTweenType.easeOutSine);
            LeanTween.rotate(this.gameObject, new Vector3(0, 0, 0), 2f).setEase(LeanTweenType.easeOutSine);
            skullCount++;
        }
        else if (this.name == "skull3")
        {
            LeanTween.move(this.gameObject, new Vector3(ring3.transform.position.x, ring3.transform.position.y + 0.3f, ring3.transform.position.z), 2f).setEase(LeanTweenType.easeOutSine);
            LeanTween.rotate(this.gameObject, new Vector3(0, 0, 0), 2f).setEase(LeanTweenType.easeOutSine);
            skullCount++;
        }

        if (skullCount >= 3)
        {
            darkhole.SetActive(true);
            LeanTween.scale(darkhole.gameObject, darkhole_scale, 2f).setEase(LeanTweenType.easeOutSine);
            yield return(new WaitForSeconds(1.5f));

            LeanTween.move(heart.gameObject, heart_pos, 2f).setEase(LeanTweenType.easeOutSine);
        }


        yield return(new WaitForSeconds(0.2f));

        //gameObject.SetActive(false);
    }
Esempio n. 3
0
 public void ResetTarget()
 {
     target  = null;
     hitInfo = new RaycastHit();
     reticle.ResetTargetBodyScale();
     focusOnTargetWithoutInterruptionSec = 0;
 }
Esempio n. 4
0
    public void Add(InteractiveThing thing)
    {
        if (!(thing is ObtainableItem))
            return;

        items.Add(thing as ObtainableItem);
    }
Esempio n. 5
0
    public override void InteractWith(InteractiveThing thing)
    {
        if (!IsAbleToInteractWith(thing))
            return;

        StartCoroutine(OpenLockCo(thing));
    }
Esempio n. 6
0
    void Start()
    {
        interactiveThing = GetComponent<InteractiveThing>();
        interactiveThing.isAbleToInteract = false;
        King.visitor.sight.enabled = false;

        StartCoroutine(ActivateAfterSec(activateAfterSec));
    }
Esempio n. 7
0
    void Start()
    {
        interactiveThing = GetComponent <InteractiveThing>();
        interactiveThing.isAbleToInteract = false;
        King.visitor.sight.enabled        = false;

        StartCoroutine(ActivateAfterSec(activateAfterSec));
    }
Esempio n. 8
0
    public void Add(InteractiveThing thing)
    {
        if (!(thing is ObtainableItem))
        {
            return;
        }

        items.Add(thing as ObtainableItem);
    }
    public override void InteractWith(InteractiveThing thing)
    {
        if (!IsAbleToInteractWith(thing))
        {
            return;
        }

        StartCoroutine(OpenLockCo(thing));
    }
Esempio n. 10
0
    public override void InteractWith(InteractiveThing thing)
    {
        if (!IsAbleToInteractWith(thing)) {
            Debug.Log(this+" can't interact with "+thing);
            return;
        }

        thing.isAbleToInteract = false;

        StartCoroutine(OpenKeyhole(thing));
    }
Esempio n. 11
0
    public override void InteractWith(InteractiveThing thing)
    {
        if (!IsAbleToInteractWith(thing))
        {
            Debug.Log(this + " can't interact with " + thing);
            return;
        }

        thing.isAbleToInteract = false;

        StartCoroutine(OpenKeyhole(thing));
    }
Esempio n. 12
0
    public bool IsAbleToInteractWith(InteractiveThing thing)
    {
        if (!thing.isAbleToInteract)
            return false;

        foreach (Interaction interaction in interactions) {
            if (interaction.IsAbleToInteractWith(thing)) {
                return true;
            }
        }

        return false;
    }
Esempio n. 13
0
    public bool Interact(InteractiveThing thing)
    {
        Debug.Log("Visitor tries to use "+this+" with "+thing);

        // Use interaction script to determin if this thing can interact with an object.
        foreach (Interaction interaction in interactions) {
            if (interaction.IsAbleToInteractWith(thing)) {
                interaction.InteractWith(thing);
                isAbleToInteract = false;
            }
        }

        return true;
    }
Esempio n. 14
0
    public override bool IsAbleToInteractWith(InteractiveThing thing)
    {
        //if (HName.GetPure(thing.name) != "lock")
        if (thing.name != "Lock")
            return false;

        var targetLock = thing.interactions.Find(it => it is TempLock) as TempLock;

        if (targetLock != null && targetLock.lockID == lockID)
            return true;
        else
            return false;

        //return HName.GetPure(thing.name) == "lock" && (thing as ObtainableItem).;
    }
Esempio n. 15
0
    IEnumerator KnifeThrowCo(InteractiveThing thing)
    {
        LeanTween.rotate(this.gameObject, new Vector3(90, 0, -30), 2f).setEase(LeanTweenType.easeOutSine);
        yield return(new WaitForSeconds(3f));

        LeanTween.move(this.gameObject, thing.transform.position, 1.5f).setEase(LeanTweenType.easeOutSine);
        yield return(new WaitForSeconds(1.2f));

        webstring.SetActive(false);
        spider.GetComponent <ObtainableItem>().isAbleToInteract = true;
        spider.GetComponent <Rigidbody>().isKinematic           = false;
        spider.GetComponent <Rigidbody>().useGravity            = true;
        LeanTween.rotate(spider.gameObject, new Vector3(0, 0, 0), 1f).setEase(LeanTweenType.easeOutSine);
        yield return(null);
    }
    public bool Interact(InteractiveThing thing)
    {
        Debug.Log("Visitor tries to use " + this + " with " + thing);

        // Use interaction script to determin if this thing can interact with an object.
        foreach (Interaction interaction in interactions)
        {
            if (interaction.IsAbleToInteractWith(thing))
            {
                interaction.InteractWith(thing);
                isAbleToInteract = false;
            }
        }

        return(true);
    }
    public bool IsAbleToInteractWith(InteractiveThing thing)
    {
        if (!thing.isAbleToInteract)
        {
            return(false);
        }

        foreach (Interaction interaction in interactions)
        {
            if (interaction.IsAbleToInteractWith(thing))
            {
                return(true);
            }
        }

        return(false);
    }
Esempio n. 18
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. 19
0
    IEnumerator OpenKeyhole(InteractiveThing thing)
    {
        var options = new Hashtable ();
        options.Add ("ease", "easeOutCubic");

        LeanTween.move(gameObject, thing.transform.position, 2f).setEase(LeanTweenType.easeOutSine);
        LeanTween.rotate(gameObject, thing.transform.rotation.eulerAngles, 1f).setEase(LeanTweenType.easeOutSine);

        yield return new WaitForSeconds(2f);

        if (target != null) {
            target.SendMessage("OnKeyUse");
        } else {
            Debug.LogError(this+" doesn't have a target door");
        }

        //transform.parent.SendMessage("OnPointCollect", SendMessageOptions.DontRequireReceiver);
    }
Esempio n. 20
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 MakePopcornCo(InteractiveThing thing)
    {
        LeanTween.move(gameObject, thing.transform.position, 2f).setEase(LeanTweenType.easeOutSine);

        yield return(new WaitForSeconds(3f));

        var currentScale = initScale;

        for (int i = 0; i < popcorn.Length; i++)
        {
            var pop = popcorn[i];
            pop.gameObject.SetActive(true);

            var prevScale = currentScale;
            currentScale = currentScale * 0.9f;

            soundPlayer.PlayOneShot(i);

            LeanTween.scale(cornBody, currentScale, 0.1f).setEase(LeanTweenType.easeInCirc);
            yield return(new WaitForSeconds(0.1f));

            var randomForce = Random.Range(0.1f, 0.2f);

            pop.GetComponent <Rigidbody>().useGravity  = true;
            pop.GetComponent <Rigidbody>().isKinematic = false;
            pop.GetComponent <Rigidbody>().AddForce(Vector3.back * randomForce, ForceMode.Impulse);

            LeanTween.scale(cornBody, prevScale, 0.1f).setEase(LeanTweenType.easeInOutCirc);
            yield return(new WaitForSeconds(0.25f));
        }

        /*
         * popcorn.gameObject.SetActive(true);
         *
         * popcorn.GetComponent<Rigidbody>().useGravity = true;
         * popcorn.GetComponent<Rigidbody>().isKinematic = false;
         * popcorn.GetComponent<Rigidbody>().AddForce(Vector3.back * 0.25f, ForceMode.Impulse);
         */

        LeanTween.scale(cornBody, Vector3.zero, 0.2f).setEase(LeanTweenType.easeInCirc);
        yield return(new WaitForSeconds(0.2f));

        gameObject.SetActive(false);
    }
    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. 23
0
    IEnumerator MakePopcornCo(InteractiveThing thing)
    {
        LeanTween.move(gameObject, thing.transform.position, 2f).setEase(LeanTweenType.easeOutSine);

        yield return new WaitForSeconds(3f);

        var currentScale = initScale;

        for (int i = 0; i < popcorn.Length; i++) {
            var pop = popcorn[i];
            pop.gameObject.SetActive(true);

            var prevScale = currentScale;
            currentScale = currentScale * 0.9f;

            soundPlayer.PlayOneShot(i);

            LeanTween.scale(cornBody, currentScale, 0.1f).setEase(LeanTweenType.easeInCirc);
            yield return new WaitForSeconds (0.1f);

            var randomForce = Random.Range(0.1f, 0.2f);

            pop.GetComponent<Rigidbody>().useGravity = true;
            pop.GetComponent<Rigidbody>().isKinematic = false;
            pop.GetComponent<Rigidbody>().AddForce(Vector3.back * randomForce, ForceMode.Impulse);

            LeanTween.scale(cornBody, prevScale, 0.1f).setEase(LeanTweenType.easeInOutCirc);
            yield return new WaitForSeconds (0.25f);
        }
        /*
        popcorn.gameObject.SetActive(true);

        popcorn.GetComponent<Rigidbody>().useGravity = true;
        popcorn.GetComponent<Rigidbody>().isKinematic = false;
        popcorn.GetComponent<Rigidbody>().AddForce(Vector3.back * 0.25f, ForceMode.Impulse);
        */

        LeanTween.scale(cornBody, Vector3.zero, 0.2f).setEase(LeanTweenType.easeInCirc);
        yield return new WaitForSeconds (0.2f);

        gameObject.SetActive(false);
    }
Esempio n. 24
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;
    }
    public override bool IsAbleToInteractWith(InteractiveThing thing)
    {
        //if (HName.GetPure(thing.name) != "lock")
        if (thing.name != "Lock")
        {
            return(false);
        }

        var targetLock = thing.interactions.Find(it => it is TempLock) as TempLock;

        if (targetLock != null && targetLock.lockID == lockID)
        {
            return(true);
        }
        else
        {
            return(false);
        }

        //return HName.GetPure(thing.name) == "lock" && (thing as ObtainableItem).;
    }
Esempio n. 26
0
    IEnumerator OpenKeyhole(InteractiveThing thing)
    {
        var options = new Hashtable();

        options.Add("ease", "easeOutCubic");

        LeanTween.move(gameObject, thing.transform.position, 2f).setEase(LeanTweenType.easeOutSine);
        LeanTween.rotate(gameObject, thing.transform.rotation.eulerAngles, 1f).setEase(LeanTweenType.easeOutSine);

        yield return(new WaitForSeconds(2f));

        if (target != null)
        {
            target.SendMessage("OnKeyUse");
        }
        else
        {
            Debug.LogError(this + " doesn't have a target door");
        }

        //transform.parent.SendMessage("OnPointCollect", SendMessageOptions.DontRequireReceiver);
    }
Esempio n. 27
0
 public virtual bool IsAbleToInteractWith(InteractiveThing thing)
 {
     return(false);
 }
Esempio n. 28
0
 public override bool IsAbleToInteractWith(InteractiveThing thing)
 {
     return(thing.name == ("heartRing"));
 }
Esempio n. 29
0
 public override bool IsAbleToInteractWith(InteractiveThing thing)
 {
     return false;
 }
Esempio n. 30
0
 public virtual bool IsAbleToInteractWith(InteractiveThing thing)
 {
     return false;
 }
Esempio n. 31
0
 public override bool IsAbleToInteractWith(InteractiveThing thing)
 {
     return thing.name == "ThrowingSurface";
 }
Esempio n. 32
0
 public override void InteractWith(InteractiveThing thing)
 {
     StartCoroutine(KnifeThrowCo(thing));
 }
 public override bool IsAbleToInteractWith(InteractiveThing thing)
 {
     return(false);
 }
Esempio n. 34
0
 public override bool IsAbleToInteractWith(InteractiveThing thing)
 {
     return(thing is SurfaceForItems);
 }
Esempio n. 35
0
 public override bool IsAbleToInteractWith(InteractiveThing thing)
 {
     return(thing.name == "Keyhole");
 }
Esempio n. 36
0
 public override bool IsAbleToInteractWith(InteractiveThing thing)
 {
     return thing.name == "Fireplace";
 }
Esempio n. 37
0
    void Start()
    {
        target = target == null?GetComponent <InteractiveThing>() : target;

        StartCoroutine(ActivateAfterSecCo());
    }
Esempio n. 38
0
 public override bool IsAbleToInteractWith(InteractiveThing thing)
 {
     return thing.name == "Keyhole";
 }
Esempio n. 39
0
    public override void InteractWith(InteractiveThing thing)
    {
        var cauldron = thing as Cauldron;

        cauldron.Add(GetComponent<ObtainableItem>());
    }
Esempio n. 40
0
    public override void InteractWith(InteractiveThing thing)
    {
        var surface = thing as SurfaceForItems;

        surface.AddItem(GetComponent <ObtainableItem>());
    }
 public override void InteractWith(InteractiveThing thing)
 {
 }
Esempio n. 42
0
 public override void InteractWith(InteractiveThing thing)
 {
     StartCoroutine(MakePopcornCo(thing));
 }
Esempio n. 43
0
 public override bool IsAbleToInteractWith(InteractiveThing thing)
 {
     return(thing.name == "ThrowingSurface");
 }
Esempio n. 44
0
    void UpdateInteractions()
    {
        if (!sight.enabled || sight.target == null || !sight.target.isAbleToInteract)
        {
            return;
        }

        InteractiveThing target = sight.target;
        var focusTimeSec        = target.hasItsOwnFocusTime ? target.focusTimeSec : defaultFocusTimeSec;

        if (itemInHand != null && itemInHand.isAbleToInteract)
        {
            if (target != null && target != itemInHand && sight.focusOnTargetWithoutInterruptionSec > focusTimeSec)
            {
                if (itemInHand.IsAbleToInteractWith(target))
                {
                    itemInHand.Interact(target);

                    /*
                     * itemInHand = null;
                     * sight.reticle.SetBody(0);
                     * sight.ResetTarget();
                     */
                    Drop(itemInHand);
                }

                if (target is InventorySpot)
                {
                    var inventorySpot = target as InventorySpot;
                    if (inventorySpot.item == null)
                    {
                        inventorySpot.Add(itemInHand);

                        /*
                         * itemInHand = null;
                         * sight.reticle.SetBody(0);
                         * sight.ResetTarget();
                         */
                        Drop(itemInHand);
                    }
                }
            }
        }
        else if (itemInHand == null)
        {
            if (target != null && sight.focusOnTargetWithoutInterruptionSec > focusTimeSec)
            {
                if (target is ObtainableItem)
                {
                    Take(target as ObtainableItem);
                }
                else if (target is InteractiveObject)
                {
                    var interactiveObject = target as InteractiveObject;
                    if (interactiveObject.isAbleToBeActivatedOnItsOwn)
                    {
                        //Debug.Log("Visitor activates "+target);
                        interactiveObject.Activate();
                    }
                }
            }
        }
    }
Esempio n. 45
0
    void UpdateTarget()
    {
        if (hitInfo.collider == null) {
            target = null;
            return;
        }

        var thing = GetInteractiveThing(hitInfo.collider);

        if (thing == null && hitInfo.rigidbody != null) {
            thing = GetInteractiveThing(hitInfo.rigidbody);
        }

        target = thing;
    }
 public override void InteractWith(InteractiveThing thing)
 {
     StartCoroutine(MakePopcornCo(thing));
 }
Esempio n. 47
0
 public virtual void InteractWith(InteractiveThing thing)
 {
 }
Esempio n. 48
0
 public override bool IsAbleToInteractWith(InteractiveThing thing)
 {
     return(thing is Cauldron);
 }
Esempio n. 49
0
 public override void InteractWith(InteractiveThing thing)
 {
 }
Esempio n. 50
0
    public override void InteractWith(InteractiveThing thing)
    {
        var cauldron = thing as Cauldron;

        cauldron.Add(GetComponent <ObtainableItem>());
    }
Esempio n. 51
0
    InteractiveThing GetInteractiveThing(Component component)
    {
        var thing = component.GetComponent<InteractiveThing>();

        if (thing != null) {
            target = thing;
        } else {
            var link = component.GetComponent<LinkToInteractiveThing>();
            thing = link != null ? link.target : null;
        }

        return thing;
    }
Esempio n. 52
0
 public override bool IsAbleToInteractWith(InteractiveThing thing)
 {
     return (thing is Cauldron);
 }
Esempio n. 53
0
 public override void InteractWith(InteractiveThing thing)
 {
     StartCoroutine(SummonHeartCo(thing));
 }
Esempio n. 54
0
 public virtual void InteractWith(InteractiveThing thing)
 {
 }