protected void init(Hi5_Glove_Interaction_Hand hand)
        {
            mJudgeMent = new Hi5_Object_JudgeMent();
            mDecision  = new Hi5_Glove_Decision(mJudgeMent, hand, this);
            Hi5_Glove_State_Pinch pinchState = new Hi5_Glove_State_Pinch();

            pinchState.Init(hand, this, mDecision);
            Hi5_Glove_State_Release releaseState = new Hi5_Glove_State_Release();

            releaseState.Init(hand, this, mDecision);
            Hi5_Glove_State_Pinch2 pinch2 = new Hi5_Glove_State_Pinch2();

            pinch2.Init(hand, this, mDecision);
            Hi5_Glove_State_Clap clap = new Hi5_Glove_State_Clap();

            clap.Init(hand, this, mDecision);

            Hi5_Glove_State_Lift Lift = new Hi5_Glove_State_Lift();

            Lift.Init(hand, this, mDecision);
            mDicState.Add(E_Hand_State.EClap, clap);
            mDicState.Add(E_Hand_State.ELift, Lift);
            mDicState.Add(E_Hand_State.EPinch, pinchState);
            mDicState.Add(E_Hand_State.ERelease, releaseState);
            mDicState.Add(E_Hand_State.EPinch2, pinch2);
            mCurrentState = releaseState;

            mJudgeMent.mStateManager = this;
            mJudgeMent.Hand          = hand;
        }
コード例 #2
0
        internal bool IsFlyPinch()
        {
            List <int> pinchs4;
            //isPinch = Hand.mState.mJudgeMent.IsPinch(out pinchs4, out ObjectId);
            //if(!isPinch)
            int  ObjectId = -1000;
            bool isPinch  = mHand.mState.mJudgeMent.IsFlyIngPinch(out pinchs4, out ObjectId);

            if (isPinch)
            {
                Hi5_Glove_Interaction_Item item = Hi5_Interaction_Object_Manager.GetObjectManager().GetItemById(ObjectId);
                float dis = Mathf.Abs(item.PlaneY - item.transform.position.y);
                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() && dis > (0.1f * item.GetHeight()))
                {
                    if (item.mObjectType == EObject_Type.ECommon)
                    {
                        Hi5_Interaction_Message.GetInstance().DispenseMessage(Hi5_MessageKey.messageFlyPinchObject, pinchs4, mHand, ObjectId);
                        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;
                        }

                        item.transform.position = mHand.GetThumbAndMiddlePoin();


                        item.CleanRecord();
                        mState.ChangeState(E_Hand_State.EPinch);
                        Hi5_Glove_Interaction_Hand handTemp = mHand;

//						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);
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }
 internal protected void ChangeState(E_Hand_State state)
 {
     mCurrentState.End();
     State = state;
     if (mDicState.ContainsKey(state))
     {
         mDicState[state].Start();
         mCurrentState = mDicState[state];
     }
 }
        public void  GetGloveState <T>(E_Hand_State hand_type, out T backValue) where T : Hi5_Glove_State_Base
        {
            backValue = null;

            Hi5_Glove_State_Base item = GetBaseState(hand_type);

            if (item != null)
            {
                T scrip = item as T;
                backValue = scrip;
            }
        }
コード例 #5
0
        internal bool IsPinch2()
        {
            List <int> pinchs2;
            List <Hi5_Glove_Interaction_Finger> fingers = null;
            int  ObjectId = -1000;
            bool isPinch2 = mHand.mState.mJudgeMent.IsPinch2(out pinchs2, out fingers, out ObjectId);

            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) ||
                 (item.state == E_Object_State.EMove && item.mstatemanager.GetMoveState().mMoveType == Hi5ObjectMoveType.EFree)))
            {
                if (isPinch2 && pinchs2 != null && pinchs2.Count > 0 && fingers != null)
                {
                    foreach (Hi5_Glove_Interaction_Finger tempItem in fingers)
                    {
                        tempItem.NotifyEnterPinch2State();
                    }
                    Hi5_Interaction_Message.GetInstance().DispenseMessage(Hi5_MessageKey.messagePinchObject2, pinchs2, mHand, ObjectId);
                    Hi5_Glove_State_Base baseState = mState.GetBaseState(E_Hand_State.EPinch2);
                    if (baseState != null)
                    {
                        (baseState as Hi5_Glove_State_Pinch2).objectId = ObjectId;
                    }

                    item.CleanRecord();
                    Hi5_Glove_Interaction_Hand handTemp = mHand;
                    mState.ChangeState(E_Hand_State.EPinch2);
                    {
                        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
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);
        }