internal bool IsPinch()
        {
            if (mHand.gameObject.GetComponent <Hi5_Glove_Property>() != null)
            {
                if (!mHand.gameObject.GetComponent <Hi5_Glove_Property>().Property_Data.IsPinch)
                {
                    return(false);
                }
            }

            List <int> pinchs;
            int        ObjectId = -1;
            bool       isPinch  = mHand.mState.mJudgeMent.IsPinch(out pinchs, out ObjectId);

            if (isPinch && !(mHand.GetRecognitionState() == Hi5_Glove_Gesture_Recognition_State.EFist) && !(mHand.GetRecognitionState() == Hi5_Glove_Gesture_Recognition_State.EIndexPoint))
            {
                Hi5_Glove_Interaction_Item item = Hi5_Interaction_Object_Manager.GetObjectManager().GetItemById(ObjectId);
                if (item != null &&
                    item.mObjectType == EObject_Type.ECommon &&
                    item.mstatemanager != null &&
                    item.mstatemanager.GetMoveState() != null &&
                    (item.state == E_Object_State.EStatic ||
                     item.state == E_Object_State.EPinch ||
                     item.state == E_Object_State.EFlyLift ||
                     item.state == E_Object_State.EClap ||
                     (item.state == E_Object_State.EMove && item.mstatemanager.GetMoveState().mMoveType == Hi5ObjectMoveType.EPlaneMove)))
                {
                    Hi5_Interaction_Message.GetInstance().DispenseMessage(Hi5_MessageKey.messagePinchObject, pinchs, mHand, ObjectId);
                    //isPinchCollider
                    Hi5_Glove_State_Base baseState = mState.GetBaseState(E_Hand_State.EPinch);
                    if (baseState != null)
                    {
                        (baseState as Hi5_Glove_State_Pinch).isPinchCollider = true;
                        (baseState as Hi5_Glove_State_Pinch).objectId        = ObjectId;
                    }
                    if (item != null && item.state == E_Object_State.EMove &&
                        (item.mstatemanager.GetMoveState().mMoveType == Hi5ObjectMoveType.EThrowMove || item.mstatemanager.GetMoveState().mMoveType == Hi5ObjectMoveType.EFree) &&
                        !item.mstatemanager.GetMoveState().IsProtectionFly())
                    {
                        bool  ContactIsSelf = false;
                        float distance      = Hi5_Interaction_Const.GetDistance(mHand.mPalm.transform, item, out ContactIsSelf);
                        if (ContactIsSelf)
                        {
                            Vector3 offset = new Vector3(mHand.mPalm.transform.position.x - item.transform.position.x,
                                                         mHand.mPalm.transform.position.y - item.transform.position.y,
                                                         mHand.mPalm.transform.position.z - item.transform.position.z).normalized;
                            offset = offset * distance;
                        }
                    }
                    item.CleanRecord();
                    Hi5_Glove_Interaction_Hand handTemp = mHand;
                    mHand.mGestureRecognition.CleanRecord();
                    mState.ChangeState(E_Hand_State.EPinch);

                    {
                        Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(item.idObject,
                                                                                                                        item.mObjectType,
                                                                                                                        handTemp.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight,
                                                                                                                        EEventObjectType.EPinch);
                        Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null);
                    }

                    {
                        Hi5_Glove_Interaction_Hand_Event_Data data = Hi5_Glove_Interaction_Hand_Event_Data.Instance(item.idObject,
                                                                                                                    handTemp.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight,
                                                                                                                    EEventHandType.EPinch);
                        Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageHandEvent, (object)data, null);
                    }
                    return(true);;
                }
                return(false);
            }
            return(false);
        }
Ejemplo n.º 2
0
        internal bool IsPinch()
        {
            List <int> pinchs;
            int        ObjectId = -1;
            bool       isPinch  = mHand.mState.mJudgeMent.IsPinch(out pinchs, out ObjectId);

            if (isPinch)
            {
                Hi5_Glove_Interaction_Item item = Hi5_Interaction_Object_Manager.GetObjectManager().GetItemById(ObjectId);
                if (item != null &&
                    item.mObjectType == EObject_Type.ECommon &&
                    item.mstatemanager != null &&
                    item.mstatemanager.GetMoveState() != null &&
                    (item.state == E_Object_State.EStatic ||
                     item.state == E_Object_State.EPinch ||
                     item.state == E_Object_State.EFlyLift ||
                     item.state == E_Object_State.EClap ||
                     (item.state == E_Object_State.EMove && item.mstatemanager.GetMoveState().mMoveType == Hi5ObjectMoveType.EPlaneMove)))
                {
                    Hi5_Interaction_Message.GetInstance().DispenseMessage(Hi5_MessageKey.messagePinchObject, pinchs, mHand, ObjectId);
                    //isPinchCollider
                    Hi5_Glove_State_Base baseState = mState.GetBaseState(E_Hand_State.EPinch);
                    if (baseState != null)
                    {
                        (baseState as Hi5_Glove_State_Pinch).isPinchCollider = true;
                        (baseState as Hi5_Glove_State_Pinch).objectId        = ObjectId;
                    }

                    //Hi5_Glove_Interraction_Item item = Hi5_Interaction_Object_Manager.GetObjectManager().GetItemById(ObjectId);
                    if (item != null && item.state == E_Object_State.EMove &&
                        (item.mstatemanager.GetMoveState().mMoveType == Hi5ObjectMoveType.EThrowMove || item.mstatemanager.GetMoveState().mMoveType == Hi5ObjectMoveType.EFree) &&
                        !item.mstatemanager.GetMoveState().IsProtectionFly())
                    {
                        bool  ContactIsSelf = false;
                        float distance      = Hi5_Interaction_Const.GetDistance(mHand.mPalm.transform, item, out ContactIsSelf);
                        if (ContactIsSelf)
                        {
                            Vector3 offset = new Vector3(mHand.mPalm.transform.position.x - item.transform.position.x,
                                                         mHand.mPalm.transform.position.y - item.transform.position.y,
                                                         mHand.mPalm.transform.position.z - item.transform.position.z).normalized;
                            offset = offset * distance;
                            //item.transform.position = new Vector3(item.transform.position.x + offset.x,
                            //    item.transform.position.y + offset.y,
                            //    item.transform.position.z + offset.z);
                        }
                    }
                    item.CleanRecord();
                    Hi5_Glove_Interaction_Hand handTemp = mHand;
                    mState.ChangeState(E_Hand_State.EPinch);

//					if (handTemp.m_IsLeftHand)
//					{
//						Debug.Log ("Left pinch");
//					}
                    {
                        Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(item.idObject,
                                                                                                                        item.mObjectType,
                                                                                                                        handTemp.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight,
                                                                                                                        EEventObjectType.EPinch);
                        Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null);
                    }

                    {
                        Hi5_Glove_Interaction_Hand_Event_Data data = Hi5_Glove_Interaction_Hand_Event_Data.Instance(item.idObject,
                                                                                                                    handTemp.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight,
                                                                                                                    EEventHandType.EPinch);
                        Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageHandEvent, (object)data, null);
                    }
                    //Hi5_Glove_Interaction_Object_Event_Data data = new Hi5_Glove_Interaction_Object_Event_Data();
                    //if (Hand.m_IsLeftHand)
                    //    data.mHandType = EHandType.EHandLeft;
                    //else
                    //    data.mHandType = EHandType.EHandRight;
                    //data.mObjectType = item.mObjectType;
                    //data.mEventType = EEventType.EPinch;
                    //data.mObjectId = item.idObject;
                    //Hi5InteractionManger.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null);

                    return(true);;
                }
                return(false);
            }
            return(false);
        }