Exemplo n.º 1
0
    void Update()
    {
        var device = SteamVR_Controller.Input(index);

        /*
         * foreach (var buttonId in buttonIds)
         * {
         *  if (SteamVR_Controller.Input(index).GetPressDown(buttonId))
         *  {
         *
         *  }
         *  if (SteamVR_Controller.Input(index).GetPressUp(buttonId))
         *  {
         *
         *  }
         *  if (SteamVR_Controller.Input(index).GetPress(buttonId))
         *  {
         *
         *  }
         * }
         */

        foreach (var buttonId in axisIds)
        {
            if (SteamVR_Controller.Input(index).GetTouchDown(buttonId))
            {
                //Debug.Log(buttonId + " touch down");
            }
            if (SteamVR_Controller.Input(index).GetTouchUp(buttonId))
            {
                if (buttonId == EVRButtonId.k_EButton_SteamVR_Trigger)
                {
                    DropItem(device);
                }
            }
            if (SteamVR_Controller.Input(index).GetTouch(buttonId))
            {
                var axis = SteamVR_Controller.Input(index).GetAxis(buttonId);

                if (buttonId == EVRButtonId.k_EButton_SteamVR_Trigger)
                {
                    if (itemInHand == null && axis.x >= grabThreshold && GetComponentInChildren <GrabTrigger>().things.Count > 0)
                    {
                        var thing = GetComponentInChildren <GrabTrigger>().things[0];
                        var item  = thing as ObtainableItem;

                        if (item != null)
                        {
                            itemInHand = item;
                            itemInHand.Dispatch(ObtainableItemEventType.OnPickUp, this);
                        }
                        else
                        {
                            Actium.Dispatch("ViveHandInteractsWith_" + thing.name, this);
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    IEnumerator AddItemCo(ObtainableItem item, Vector3 point)
    {
        //Debug.Log(item+" has been added to the cauldron.");
        item.transform.parent = transform;

        var itemRigidbody = item.GetComponent<Rigidbody>();
        itemRigidbody.useGravity = false;
        itemRigidbody.isKinematic = true;

        LeanTween.cancel(item.gameObject);
        LeanTween.move(item.gameObject, point + Vector3.up * 1f, 1f).setEase(LeanTweenType.easeOutCubic);
        LeanTween.rotate(item.gameObject, surface.transform.rotation.eulerAngles, 1f).setEase(LeanTweenType.easeInCubic);

        yield return new WaitForSeconds(1f);

        itemRigidbody.useGravity = true;
        itemRigidbody.isKinematic = false;

        yield return new WaitForSeconds(2f);

        items.Add(item);
        item.isAbleToInteract = true;

        //itemRigidbody.useGravity = false;
        //itemRigidbody.isKinematic = true;
    }
Exemplo n.º 3
0
    IEnumerator AddItemCo(ObtainableItem item, Vector3 point)
    {
        //Debug.Log(item+" has been added to the cauldron.");
        item.transform.parent = transform;

        var itemRigidbody = item.GetComponent <Rigidbody>();

        itemRigidbody.useGravity  = false;
        itemRigidbody.isKinematic = true;

        LeanTween.cancel(item.gameObject);
        LeanTween.move(item.gameObject, point + Vector3.up * 1f, 1f).setEase(LeanTweenType.easeOutCubic);
        LeanTween.rotate(item.gameObject, surface.transform.rotation.eulerAngles, 1f).setEase(LeanTweenType.easeInCubic);

        yield return(new WaitForSeconds(1f));

        itemRigidbody.useGravity  = true;
        itemRigidbody.isKinematic = false;

        yield return(new WaitForSeconds(2f));

        items.Add(item);
        item.isAbleToInteract = true;

        //itemRigidbody.useGravity = false;
        //itemRigidbody.isKinematic = true;
    }
Exemplo n.º 4
0
    public void OnItemAdd(ObtainableItem item)
    {
        if (items == null)
            items = new List<ObtainableItem>();

        StartCoroutine(AddItemCo(item, surface.transform.position));
    }
Exemplo n.º 5
0
    IEnumerator RemoveItemCo(ObtainableItem item)
    {
        items.Remove(item);

        surface.isAbleToInteract = false;

        var targetPosition = item.transform.position + Vector3.up * 1f;

        var itemRigidbody = item.GetComponent <Rigidbody>();

        itemRigidbody.useGravity  = false;
        itemRigidbody.isKinematic = true;

        LeanTween.cancel(item.gameObject);
        LeanTween.move(item.gameObject, targetPosition, 1f).setEase(LeanTweenType.easeOutCubic);

        yield return(new WaitForSeconds(1f));

        item.isAbleToInteract = true;
        item = null;

        yield return(new WaitForSeconds(1.5f));

        // Activate the surface with delay after removing an item,
        // so the item wont get back to inventory if Player continues to point at the spot after getting the item in hand.
        surface.isAbleToInteract = true;
    }
Exemplo n.º 6
0
 public void OnItemTakeByVisitor(ObtainableItem item)
 {
     if (paintingHoop.hoopIndex == -1)
     {
         paintingHoop.NextHoop();
         paintingHoop.targetBall = GetComponent <Basketball>();
     }
 }
Exemplo n.º 7
0
 public void Drop(ObtainableItem item)
 {
     //Debug.Log("Visitor drops "+item);
     itemInHand.Frees();
     itemInHand = null;
     sight.ResetTarget();
     sight.reticle.SetBody(0);
 }
Exemplo n.º 8
0
    public void RegisterItem(ObtainableItem item)
    {
        if (items == null)
        {
            items = new List <ObtainableItem>();
        }

        items.Add(item);
    }
Exemplo n.º 9
0
    public void OnItemTakeByVisitor(ObtainableItem item)
    {
        dropIsInitiated = false;
        targetPosition = Vector3.zero;

        if (GetComponent<ChangesSoundPitchOnRequest>() != null) {
            GetComponent<ChangesSoundPitchOnRequest>().FadeIn(1.5f);
        }
    }
Exemplo n.º 10
0
    public void OnItemAdd(ObtainableItem item)
    {
        if (items == null)
        {
            items = new List <ObtainableItem>();
        }

        StartCoroutine(AddItemCo(item, surface.transform.position));
    }
Exemplo n.º 11
0
    public void OnItemTakeByVisitor(ObtainableItem item)
    {
        dropIsInitiated = false;
        targetPosition  = Vector3.zero;

        if (GetComponent <ChangesSoundPitchOnRequest>() != null)
        {
            GetComponent <ChangesSoundPitchOnRequest>().FadeIn(1.5f);
        }
    }
Exemplo n.º 12
0
    public void Add(ObtainableItem item)
    {
        var recipeItem = recipe.items.Find(i => HName.GetPure(i.itemName) == HName.GetPure(item.name));

        if (recipeItem != null) {
            StartCoroutine(AddItemCo(item, recipeItem));
        } else {
            StartCoroutine(RejectItemCo(item));
        }
    }
Exemplo n.º 13
0
    IEnumerator RejectItemCo(ObtainableItem item)
    {
        Debug.Log(item + " has been rejected by the cauldron.");

        var itemRigidbody = item.GetComponent <Rigidbody>();

        if (itemRigidbody != null)
        {
            itemRigidbody.useGravity  = false;
            itemRigidbody.isKinematic = true;
        }

        LeanTween.move(item.gameObject, transform.position + Vector3.up * 1f, 1f).setEase(LeanTweenType.easeOutCubic);

        yield return(new WaitForSeconds(1f));

        var targetPosition = pointOnSurface.position;

        LeanTween.move(item.gameObject, targetPosition, 0.5f);

        yield return(new WaitForSeconds(0.5f));

        if (GetComponent <PlaysAudioRemarkOnRadio>())
        {
            var maxIndex = GetComponent <PlaysAudioRemarkOnRadio>().remarks.Count;
            GetComponent <PlaysAudioRemarkOnRadio>().Play(Random.Range(2, maxIndex));
        }

        audioPlayer.PlayOneShot(1);

        foreach (GameObject subscriber in subscribers)
        {
            subscriber.SendMessage("OnRejectFromCauldron", item, SendMessageOptions.DontRequireReceiver);
        }

        LeanTween.move(item.gameObject, transform.position + Vector3.up * 1f, 1f).setEase(LeanTweenType.easeOutCubic);

        yield return(new WaitForSeconds(1f));

        LeanTween.move(item.gameObject, pointForRejected.position, 1f).setEase(LeanTweenType.easeOutCubic);

        yield return(new WaitForSeconds(1f));

        if (itemRigidbody != null)
        {
            itemRigidbody.useGravity  = true;
            itemRigidbody.isKinematic = false;
        }

        item.isAbleToInteract = true;

        yield return(new WaitForSeconds(1.5f));

        itemRigidbody.isKinematic = true;
    }
Exemplo n.º 14
0
    public void AddItem(ObtainableItem item)
    {
        if (receiver == null && transform.parent != null)
            receiver = transform.parent.gameObject;

        ItemAddingToSurfaceInfo info;
        info.item = item;
        info.point = King.visitor.sight.hitInfo.point;

        receiver.gameObject.SendMessage("OnItemAdd", info);
    }
    void DropItem(SteamVR_Controller.Device device)
    {
        if (itemInHand != null)
        {
            itemInHand.Dispatch(ObtainableItemEventType.OnDropOff, this);
            itemInHand.owner = null;

            itemInHand.GetComponent <Rigidbody>().velocity = device.velocity * 1.4f;

            itemInHand = null;
        }
    }
    void DropItem(SteamVR_Controller.Device device)
    {
        if (itemInHand != null)
        {
            itemInHand.Dispatch(ObtainableItemEventType.OnDropOff, this);
            itemInHand.owner = null;

            itemInHand.GetComponent<Rigidbody>().velocity = device.velocity * 1.4f;

            itemInHand = null;
        }
    }
Exemplo n.º 17
0
    public void RemoveItem(ObtainableItem item)
    {
        var spotWithItem = spots.Find(s => s.item == item);

        if (spotWithItem == null)
        {
            Debug.LogWarning("Couldn't find " + item + " in any of the InventorySpots");
            return;
        }

        spotWithItem.RemoveItem();
    }
Exemplo n.º 18
0
    public void Take(ObtainableItem item)
    {
        //Debug.Log("Visitor takes "+item);
        itemInHand = item;
        item.Obtains();
        sight.ResetTarget();
        sight.reticle.SetBody(1);

        if (soundPlayer != null)
        {
            soundPlayer.PlayOneShot(0);
        }
    }
Exemplo n.º 19
0
    public void Add(ObtainableItem item)
    {
        var recipeItem = recipe.items.Find(i => HName.GetPure(i.itemName) == HName.GetPure(item.name));

        if (recipeItem != null)
        {
            StartCoroutine(AddItemCo(item, recipeItem));
        }
        else
        {
            StartCoroutine(RejectItemCo(item));
        }
    }
Exemplo n.º 20
0
    public void AddItem(ObtainableItem item)
    {
        if (receiver == null && transform.parent != null)
        {
            receiver = transform.parent.gameObject;
        }

        ItemAddingToSurfaceInfo info;

        info.item  = item;
        info.point = King.visitor.sight.hitInfo.point;

        receiver.gameObject.SendMessage("OnItemAdd", info);
    }
Exemplo n.º 21
0
    public void Add(ObtainableItem item)
    {
        if (this.item != null)
            return;

        this.item = item;
        prevItemParent = item.transform.parent;
        item.transform.parent = transform;
        transform.parent.SendMessage("RegisterItem", item);

        _collider.enabled = false;

        Debug.Log(this.item+" has been added to the inventory.");

        StartCoroutine(AddItemCo());
    }
Exemplo n.º 22
0
    public bool HasItem(string name)
    {
        ObtainableItem item = ItemList.FirstOrDefault(i => i.Name == name);

        if (item == default(ObtainableItem))
        {
            if (DebugMode)
            {
                Debug.LogWarning("Could not find item " + name + " in the listing; the player dosen't have it!");
            }

            return(false);
        }

        return(item.Owned);
    }
Exemplo n.º 23
0
    IEnumerator AddItemCo(ObtainableItem item, RecipeItem recipeItem)
    {
        Debug.Log(item + " has been added to the cauldron.");
        ingredientsUsed      += 1;
        recipeItem.collected += 1;

        var itemRigidbody = item.GetComponent <Rigidbody>();

        if (itemRigidbody != null)
        {
            itemRigidbody.useGravity  = false;
            itemRigidbody.isKinematic = true;
        }

        LeanTween.move(item.gameObject, transform.position + Vector3.up * 1f, 1f).setEase(LeanTweenType.easeOutCubic);

        yield return(new WaitForSeconds(1f));

        var targetPosition = pointInside.position;

        LeanTween.move(item.gameObject, targetPosition, 0.5f);

        audioPlayer.PlayOneShotAfterSec(0, 0.25f);

        if (ingredientsUsed == 1 && GetComponent <PlaysAudioRemarkOnRadio>() != null && !potionIsReady)
        {
            GetComponent <PlaysAudioRemarkOnRadio>().Play(0);
        }

        yield return(new WaitForSeconds(0.5f));

        foreach (GameObject subscriber in subscribers)
        {
            subscriber.SendMessage("OnAddToCauldron", recipeItem, SendMessageOptions.DontRequireReceiver);
        }

        item.gameObject.SetActive(false);
        isAbleToInteract = true;


        if (potionIsReady)
        {
            GivePotion();
        }
    }
Exemplo n.º 24
0
    public void Add(ObtainableItem item)
    {
        if (this.item != null)
        {
            return;
        }

        this.item             = item;
        prevItemParent        = item.transform.parent;
        item.transform.parent = transform;
        transform.parent.SendMessage("RegisterItem", item);

        _collider.enabled = false;

        Debug.Log(this.item + " has been added to the inventory.");

        StartCoroutine(AddItemCo());
    }
Exemplo n.º 25
0
    public void AddItem(ObtainableItem item)
    {
        if (spots.Find(s => s.item == item) != null)
        {
            Debug.LogWarning("Item is already is in one of the inventory spots.");
            return;
        }

        var freeSpot = spots.Find(s => s.item == null);

        if (freeSpot == null)
        {
            Debug.LogWarning("There isn't any free InventorySpot available.");
            return;
        }

        freeSpot.Add(item);
    }
Exemplo n.º 26
0
    public void Play(ObtainableItem item)
    {
        CloseFlap();

        item.transform.position = cassettePoint.position;
        item.transform.parent = transform;
        item.GetComponent<Rigidbody>().isKinematic = true;
        item.GetComponent<Rigidbody>().detectCollisions = false;

        var cassette = item.GetComponent<Cassette>();

        if (cassette == null)
            return;

        speakers.clip = cassette.audioClip;

        Invoke("Play", 1.5f);
    }
Exemplo n.º 27
0
    IEnumerator RemoveItemCo()
    {
        isAbleToInteract = false;

        var targetPosition = transform.position + Vector3.up * 0.5f;

        LeanTween.move(item.gameObject, targetPosition, 1f).setEase(LeanTweenType.easeOutCubic);

        yield return(new WaitForSeconds(1f));

        item.isAbleToInteract = true;
        item = null;

        yield return(new WaitForSeconds(3f));

        // Activate the spot with delay after removing an item,
        // so the item wont get back to inventory if Player continues to point at the spot after getting the item in hand.
        isAbleToInteract = true;
    }
Exemplo n.º 28
0
    public void Play(ObtainableItem item)
    {
        CloseFlap();

        item.transform.position = cassettePoint.position;
        item.transform.parent   = transform;
        item.GetComponent <Rigidbody>().isKinematic      = true;
        item.GetComponent <Rigidbody>().detectCollisions = false;

        var cassette = item.GetComponent <Cassette>();

        if (cassette == null)
        {
            return;
        }

        speakers.clip = cassette.audioClip;

        Invoke("Play", 1.5f);
    }
Exemplo n.º 29
0
    void OnExitHoop(object sender)
    {
        lastItemPassedThrough = sender as ObtainableItem;

        /*
         * if (lastItemPassedThrough.lastOwner == null)
         * return;
         */

        /*
         * var visitor = lastItemPassedThrough.lastOwner.GetComponent<Visitor>();
         *
         * if (visitor == null)
         * return;
         *
         * if (visitor.avatar.face.GetComponent<Renderer>().material.color == DisplayColor)
         * {
         * Score += 1;
         * }
         */

        Score += 1;
    }
Exemplo n.º 30
0
    void OnExitHoop(object sender)
    {
        lastItemPassedThrough = sender as ObtainableItem;

        /*
        if (lastItemPassedThrough.lastOwner == null)
            return;
        */

        /*
        var visitor = lastItemPassedThrough.lastOwner.GetComponent<Visitor>();

        if (visitor == null)
            return;

        if (visitor.avatar.face.GetComponent<Renderer>().material.color == DisplayColor)
        {
            Score += 1;
        }
        */

        Score += 1;
    }
Exemplo n.º 31
0
    private string FormatItemLine()
    {
        StringBuilder builder = new StringBuilder("Items:");

        // Format of line:
        // Items:A|B|C|E|F|G
        for (int i = 0; i < _ambassador.ItemList.Count; i++)
        {
            ObtainableItem current = _ambassador.ItemList[i];
            if (!current.Owned)
            {
                continue;
            }

            builder.Append(current.Name);
            if (i < _ambassador.ItemList.Count - 1)
            {
                builder.Append("|");
            }
        }

        return(builder.ToString());
    }
Exemplo n.º 32
0
    IEnumerator AddItemCo(ObtainableItem item, RecipeItem recipeItem)
    {
        Debug.Log(item+" has been added to the cauldron.");
        ingredientsUsed += 1;
        recipeItem.collected += 1;

        var itemRigidbody = item.GetComponent<Rigidbody>();
        if (itemRigidbody != null) {
            itemRigidbody.useGravity = false;
            itemRigidbody.isKinematic = true;
        }

        LeanTween.move(item.gameObject, transform.position + Vector3.up * 1f, 1f).setEase(LeanTweenType.easeOutCubic);

        yield return new WaitForSeconds(1f);

        var targetPosition = pointInside.position;

        LeanTween.move(item.gameObject, targetPosition, 0.5f);

        audioPlayer.PlayOneShotAfterSec(0, 0.25f);

        if (ingredientsUsed == 1 && GetComponent<PlaysAudioRemarkOnRadio>() != null && !potionIsReady)
            GetComponent<PlaysAudioRemarkOnRadio>().Play(0);

        yield return new WaitForSeconds(0.5f);

        foreach (GameObject subscriber in subscribers) {
            subscriber.SendMessage("OnAddToCauldron", recipeItem, SendMessageOptions.DontRequireReceiver);
        }

        item.gameObject.SetActive(false);
        isAbleToInteract = true;

        if (potionIsReady)
            GivePotion();
    }
Exemplo n.º 33
0
    public void GainItem(string name)
    {
        ObtainableItem item = ItemList.FirstOrDefault(i => i.Name == name);

        if (item == default(ObtainableItem))
        {
            if (DebugMode)
            {
                Debug.LogWarning("Could not find item " + name + " in the listing; adding it as owned!");
            }

            ItemList.Add(new ObtainableItem {
                Name = name, Owned = true
            });
            return;
        }

        if (DebugMode)
        {
            Debug.Log("Adding ownership of item " + name);
        }

        item.Owned = true;
    }
Exemplo n.º 34
0
    public override void PerformSegue(ObtainableItem item)
    {
        base.PerformSegue (item);

        item.GetComponent<Rigidbody>().isKinematic = true;
        item.GetComponent<Rigidbody>().detectCollisions = false;

        radio.OpenFlap();

        item.transform.parent = radio.transform;

        var cassettePoint = radio.cassettePoint;
        var cassetterUpPosition = cassettePoint.transform.localPosition + (cassettePoint.up + -cassettePoint.forward) * 0.2f;

        LeanTween.rotateLocal(item.gameObject, cassettePoint.localRotation.eulerAngles, 1f).setEase(LeanTweenType.easeInSine);

        LeanTween.moveLocal(item.gameObject, cassetterUpPosition, 1f).setOnComplete(delegate() {
            LeanTween.moveLocal(item.gameObject, cassettePoint.localPosition, 1f).setOnComplete(delegate() {
                radio.Play(item);
            }).setEase(LeanTweenType.easeInSine);
        }).setEase(LeanTweenType.easeInSine);

        //radio.Play(item);
    }
Exemplo n.º 35
0
    public override void PerformSegue(ObtainableItem item)
    {
        base.PerformSegue(item);

        item.GetComponent <Rigidbody>().isKinematic      = true;
        item.GetComponent <Rigidbody>().detectCollisions = false;

        radio.OpenFlap();

        item.transform.parent = radio.transform;

        var cassettePoint       = radio.cassettePoint;
        var cassetterUpPosition = cassettePoint.transform.localPosition + (cassettePoint.up + -cassettePoint.forward) * 0.2f;

        LeanTween.rotateLocal(item.gameObject, cassettePoint.localRotation.eulerAngles, 1f).setEase(LeanTweenType.easeInSine);

        LeanTween.moveLocal(item.gameObject, cassetterUpPosition, 1f).setOnComplete(delegate() {
            LeanTween.moveLocal(item.gameObject, cassettePoint.localPosition, 1f).setOnComplete(delegate() {
                radio.Play(item);
            }).setEase(LeanTweenType.easeInSine);
        }).setEase(LeanTweenType.easeInSine);

        //radio.Play(item);
    }
Exemplo n.º 36
0
 public void OnItemTakeByVisitor(ObtainableItem item)
 {
     enabled = false;
 }
Exemplo n.º 37
0
 public void OnItemTakeByVisitor(ObtainableItem item)
 {
     StartCoroutine(GoToSleepInSecCo(goToSleepAfterSec));
 }
Exemplo n.º 38
0
 public void OnItemFreeByVisitor(ObtainableItem item)
 {
     StartCoroutine(FadeOutMusicAfterFreeingCo());
 }
Exemplo n.º 39
0
 public void OnItemFreeByVisitor(ObtainableItem item)
 {
     StartCoroutine(FadeOutMusicAfterFreeingCo());
 }
Exemplo n.º 40
0
 public void OnItemTakeByVisitor(ObtainableItem item)
 {
     barrel.GetComponent<PlaysAnimationOnSight>().isAbleToInteractAfterAnimation = false;
 }
Exemplo n.º 41
0
    IEnumerator RemoveItemCo(ObtainableItem item)
    {
        items.Remove(item);

        surface.isAbleToInteract = false;

        var targetPosition = item.transform.position + Vector3.up * 1f;

        var itemRigidbody = item.GetComponent<Rigidbody>();
        itemRigidbody.useGravity = false;
        itemRigidbody.isKinematic = true;

        LeanTween.cancel(item.gameObject);
        LeanTween.move(item.gameObject, targetPosition, 1f).setEase(LeanTweenType.easeOutCubic);

        yield return new WaitForSeconds(1f);

        item.isAbleToInteract = true;
        item = null;

        yield return new WaitForSeconds(1.5f);
        // Activate the surface with delay after removing an item,
        // so the item wont get back to inventory if Player continues to point at the spot after getting the item in hand.
        surface.isAbleToInteract = true;
    }
Exemplo n.º 42
0
 public void DeregisterItem(ObtainableItem item)
 {
     items.Remove(item);
 }
 public void OnItemTakeByVisitor(ObtainableItem item)
 {
     var _animator = GetComponent <Animator>();
 }
Exemplo n.º 44
0
    IEnumerator RejectItemCo(ObtainableItem item)
    {
        Debug.Log(item+" has been rejected by the cauldron.");

        var itemRigidbody = item.GetComponent<Rigidbody>();
        if (itemRigidbody != null) {
            itemRigidbody.useGravity = false;
            itemRigidbody.isKinematic = true;
        }

        LeanTween.move(item.gameObject, transform.position + Vector3.up * 1f, 1f).setEase(LeanTweenType.easeOutCubic);

        yield return new WaitForSeconds(1f);

        var targetPosition = pointOnSurface.position;

        LeanTween.move(item.gameObject, targetPosition, 0.5f);

        yield return new WaitForSeconds(0.5f);

        if (GetComponent<PlaysAudioRemarkOnRadio>()) {
            var maxIndex = GetComponent<PlaysAudioRemarkOnRadio>().remarks.Count;
            GetComponent<PlaysAudioRemarkOnRadio>().Play(Random.Range(2, maxIndex));
        }

        audioPlayer.PlayOneShot(1);

        foreach (GameObject subscriber in subscribers) {
            subscriber.SendMessage("OnRejectFromCauldron", item, SendMessageOptions.DontRequireReceiver);
        }

        LeanTween.move(item.gameObject, transform.position + Vector3.up * 1f, 1f).setEase(LeanTweenType.easeOutCubic);

        yield return new WaitForSeconds(1f);

        LeanTween.move(item.gameObject, pointForRejected.position, 1f).setEase(LeanTweenType.easeOutCubic);

        yield return new WaitForSeconds(1f);

        if (itemRigidbody != null) {
            itemRigidbody.useGravity = true;
            itemRigidbody.isKinematic = false;
        }

        item.isAbleToInteract = true;

        yield return new WaitForSeconds(1.5f);

        itemRigidbody.isKinematic = true;
    }
Exemplo n.º 45
0
 public virtual void PerformSegue(ObtainableItem item)
 {
 }
Exemplo n.º 46
0
 public void OnItemTakeByVisitor(ObtainableItem item)
 {
     StartCoroutine(EatCo());
 }
Exemplo n.º 47
0
 public void OnItemTakeByVisitor(ObtainableItem item)
 {
     barrel.GetComponent <PlaysAnimationOnSight>().isAbleToInteractAfterAnimation = false;
 }
Exemplo n.º 48
0
 public void OnItemTakeByVisitor(ObtainableItem item)
 {
     StartCoroutine(RemoveItemCo(item));
 }
Exemplo n.º 49
0
    IEnumerator RemoveItemCo()
    {
        isAbleToInteract = false;

        var targetPosition = transform.position + Vector3.up * 0.5f;
        LeanTween.move(item.gameObject, targetPosition, 1f).setEase(LeanTweenType.easeOutCubic);

        yield return new WaitForSeconds(1f);

        item.isAbleToInteract = true;
        item = null;

        yield return new WaitForSeconds(3f);
        // Activate the spot with delay after removing an item,
        // so the item wont get back to inventory if Player continues to point at the spot after getting the item in hand.
        isAbleToInteract = true;
    }
Exemplo n.º 50
0
 public void OnItemTakeByVisitor(ObtainableItem item)
 {
     StartCoroutine(GoToPlaceInSec(moveAfterSec));
 }
 public void OnItemTakeByVisitor(ObtainableItem item)
 {
     var _animator = GetComponent<Animator>();
 }
Exemplo n.º 52
0
 public void OnItemTakeByVisitor(ObtainableItem item)
 {
     StartCoroutine(RemoveItemCo(item));
 }
Exemplo n.º 53
0
    void Update()
    {
        var device = SteamVR_Controller.Input(index);

        /*
        foreach (var buttonId in buttonIds)
        {
            if (SteamVR_Controller.Input(index).GetPressDown(buttonId))
            {

            }
            if (SteamVR_Controller.Input(index).GetPressUp(buttonId))
            {

            }
            if (SteamVR_Controller.Input(index).GetPress(buttonId))
            {

            }
        }
        */

        foreach (var buttonId in axisIds)
        {
            if (SteamVR_Controller.Input(index).GetTouchDown(buttonId))
            {
                //Debug.Log(buttonId + " touch down");
            }
            if (SteamVR_Controller.Input(index).GetTouchUp(buttonId))
            {
                if (buttonId == EVRButtonId.k_EButton_SteamVR_Trigger)
                {
                    DropItem(device);
                }
            }
            if (SteamVR_Controller.Input(index).GetTouch(buttonId))
            {
                var axis = SteamVR_Controller.Input(index).GetAxis(buttonId);

                if (buttonId == EVRButtonId.k_EButton_SteamVR_Trigger)
                {
                    if (itemInHand == null && axis.x >= grabThreshold && GetComponentInChildren<GrabTrigger>().things.Count > 0)
                    {
                        var thing = GetComponentInChildren<GrabTrigger>().things[0];
                        var item = thing as ObtainableItem;

                        if (item != null)
                        {
                            itemInHand = item;
                            itemInHand.Dispatch(ObtainableItemEventType.OnPickUp, this);
                        }
                        else
                        {
                            Actium.Dispatch("ViveHandInteractsWith_" + thing.name, this);
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 54
0
 public virtual void PerformSegue(ObtainableItem item)
 {
 }
    void Update()
    {
        foreach (var index in controllerIndices)
        {
            //var controllerState = SteamVR_Controller.Input((int)index).GetState();
            //var t = transform;
            //var baseTransform = new SteamVR_Utils.RigidTransform(t);

            var device = SteamVR_Controller.Input(index);

            // TODO: why it does return the position and rotation with a quite noticeable delay to a real position?
            /*
            transform.position = device.transform.pos;
            transform.rotation = device.transform.rot;
            */

            foreach (var buttonId in buttonIds)
            {
                if (SteamVR_Controller.Input(index).GetPressDown(buttonId))
                {
                    if (buttonId == EVRButtonId.k_EButton_SteamVR_Trigger)
                    {
                        //Debug.Log("GRAB");
                    }
                }
                if (SteamVR_Controller.Input(index).GetPressUp(buttonId))
                {
                    /*
                    Debug.Log(buttonId + " press up");
                    if (buttonId == EVRButtonId.k_EButton_SteamVR_Trigger)
                    {
                        SteamVR_Controller.Input(index).TriggerHapticPulse();
                        PrintControllerStatus(index);
                    }
                    */
                }
                if (SteamVR_Controller.Input(index).GetPress(buttonId))
                {
                    //Debug.Log(buttonId);
                }
            }

            foreach (var buttonId in axisIds)
            {
                if (SteamVR_Controller.Input(index).GetTouchDown(buttonId))
                {
                    //Debug.Log(buttonId + " touch down");
                }
                if (SteamVR_Controller.Input(index).GetTouchUp(buttonId))
                {
                    DropItem(device);
                }
                if (SteamVR_Controller.Input(index).GetTouch(buttonId))
                {
                    var axis = SteamVR_Controller.Input(index).GetAxis(buttonId);

                    if (buttonId == EVRButtonId.k_EButton_SteamVR_Trigger)
                    {
                        if (axis.x >= grabThreshold && GetComponentInChildren<GrabTrigger>().things.Count > 0)
                        {
                            var thing = GetComponentInChildren<GrabTrigger>().things[0];

                            if (thing != null && thing.GetComponent<ObtainableItem>() != null && thing.GetComponent<ObtainableItem>().IsObtainable)
                            {
                                itemInHand = thing.GetComponent<ObtainableItem>();
                                itemInHand.Dispatch(ObtainableItemEventType.OnPickUp, this);
                            }

                        }
                        else
                        {
                            DropItem(device);
                        }
                    }
                }
            }
        }
    }