Exemplo n.º 1
0
 internal void RemovePullableObject(Pullable pullable)
 {
     lock (pullableSpaceObjects)
     {
         pullableSpaceObjects.Remove(pullable);
     }
 }
Exemplo n.º 2
0
 internal void AddPullableObject(Pullable pullable)
 {
     lock (pullableSpaceObjects)
     {
         pullableSpaceObjects.Add(pullable);
     }
 }
    void OnCollisionStay(Collision collision)
    {
        Pullable pullable = collision.gameObject.GetComponent <Pullable> ();

        Utility.GESTURE m_GestureHand = gestureManager.GestureLeftHand;
        Hand            hand          = gestureManager.LeftHand;

        if (pullable != null && !m_objectInHand)
        {
            if (m_GestureHand != null && m_GestureHand == pullable.howPull)
            {
                float actualXPosition = hand.PalmPosition.ToVector3().x;

                if (m_PrevPalmPositionX == Mathf.Infinity)
                {
                    m_PrevPalmPositionX = actualXPosition;
                    return;
                }

                float direction          = m_PrevPalmPositionX - actualXPosition;
                float differencePosition = Mathf.Abs(direction);
                differencePosition = differencePosition * 1000;
                if (differencePosition > 1.2)
                {
                    if (direction < 0)
                    {
                        pullable.PullOut(differencePosition * 0.5f);
                    }
                    else
                    {
                        pullable.PullOut(-(differencePosition * 0.5f));
                    }
                }

                m_PrevPalmPositionX = actualXPosition;
            }
            else if (m_PrevPalmPositionX != Mathf.Infinity)
            {
                m_PrevPalmPositionX = Mathf.Infinity;
            }
        }

        else if (collision.gameObject.tag.Equals("Door") && m_GestureHand == Utility.GESTURE.GRAB_HAND)
        {
            Debug.Log(hand.Rotation);
            if (collision.gameObject.GetComponent <DoorManager>().Opened&& hand.Rotation.z < 0)
            {
                Animator anim = collision.gameObject.transform.parent.parent.gameObject.GetComponent <Animator> ();
                anim.Play("Door_Open");                                                                 //collision.gameObject.transform.parent.parent.GetComponent<Collider> ().isTrigger = true;
            }
        }
    }
    void OnTriggerStay(Collider collision)
    {
        Pickable pickable     = collision.gameObject.GetComponent <Pickable> ();
        Switch   objectSwitch = collision.gameObject.GetComponent <Switch>();

        Utility.GESTURE m_GestureHand = gestureManager.GestureLeftHand;
        Pullable        pullable      = collision.gameObject.GetComponent <Pullable> ();


        if (pullable != null && !m_objectInHand)
        {
            Hand hand = gestureManager.LeftHand;
            if (m_GestureHand != null && m_GestureHand == pullable.howPull)
            {
                float actualXPosition = hand.PalmPosition.ToVector3().x;

                if (m_PrevPalmPositionX == Mathf.Infinity)
                {
                    m_PrevPalmPositionX = actualXPosition;
                    return;
                }

                float direction          = m_PrevPalmPositionX - actualXPosition;
                float differencePosition = Mathf.Abs(direction);
                differencePosition = differencePosition * 1000;
                if (differencePosition > 1.2)
                {
                    if (direction < 0)
                    {
                        pullable.PullOut(differencePosition * 0.5f);
                    }
                    else
                    {
                        pullable.PullOut(-(differencePosition * 0.5f));
                    }
                }

                m_PrevPalmPositionX = actualXPosition;
            }
            else if (m_PrevPalmPositionX != Mathf.Infinity)
            {
                m_PrevPalmPositionX = Mathf.Infinity;
            }
        }

        if (pickable != null && !m_objectInHand)
        {
            if (m_GestureHand != null && m_GestureHand == pickable.howPick)
            {
                m_objectInHand                 = pickable.PickUp(transform);
                m_Collider.isTrigger           = true;
                GestureManager.OnOpenHandLeft += LeaveObject;
            }
        }

        if (objectSwitch != null && !m_objectInHand)
        {
            if (m_GestureHand != null && m_GestureHand == Utility.GESTURE.PINCH)
            {
                if (m_Next)
                {
                    m_Next = false;
                    objectSwitch.SwitchLight();
                    StartCoroutine(WaitForNextAction());
                }
            }
        }

        ColliderCandleManager candle = collision.gameObject.GetComponent <ColliderCandleManager> ();

        if (candle != null)
        {
            if (m_GestureHand == Utility.GESTURE.PINCH)
            {
                candle.FireOff();
            }
        }
    }