void OnTriggerStay(Collider collision) { FlowerPetalsPickable flowerPickable = collision.gameObject.GetComponent <FlowerPetalsPickable> (); Switch objectSwitch = collision.gameObject.GetComponent <Switch>(); Utility.GESTURE m_GestureHand = gestureManager.GestureRightHand; Hand hand = gestureManager.RightHand; if (flowerPickable != null && !m_objectInHand) { if (m_GestureHand != null && m_GestureHand == flowerPickable.howPick) { m_objectInHand = flowerPickable.PickUp(transform); m_Collider.isTrigger = true; GestureManager.OnOpenHandRight += 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()); } } } else if (collision.gameObject.tag.Equals("Door") && m_GestureHand == Utility.GESTURE.GRAB_HAND) { DoorManager door = collision.gameObject.transform.parent.parent.GetComponent <DoorManager> (); if (door.IsOpened && hand.Rotation.z < -0.70f) { door.TryOpenDoor(); } else if (!door.IsOpened && hand.Rotation.z < -0.70f) { manager.ActiveHint("La porta è chiusa a chiave"); door.TryOpenDoor(); StartCoroutine(HideHint()); } } ColliderCandleManager candle = collision.gameObject.GetComponent <ColliderCandleManager> (); if (candle != null) { if (m_GestureHand == Utility.GESTURE.PINCH) { candle.FireOff(); } } }
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(); } } }