예제 #1
0
 internal void SetPinchHand(Hi5_Object_Pinch_Type handType, Hi5_Glove_Interaction_Hand hand)
 {
     if (mPinchType == Hi5_Object_Pinch_Type.ENone)
     {
         mPinchType = handType;
     }
     else if (mPinchType == Hi5_Object_Pinch_Type.EDouble)
     {
     }
     else if (mPinchType == handType)
     {
     }
     else
     {
         mPinchType = Hi5_Object_Pinch_Type.EDouble;
     }
     if (handType == Hi5_Object_Pinch_Type.ELeft)
     {
         m_left_hand = hand;
     }
     else if (handType == Hi5_Object_Pinch_Type.ERight)
     {
         m_right_hand = hand;
     }
 }
        internal static Hi5_Glove_Interaction_State CreateState(Hi5_Glove_Interaction_Hand hand)
        {
            Hi5_Glove_Interaction_State state = new Hi5_Glove_Interaction_State();

            state.init(hand);
            return(state);
        }
예제 #3
0
 private void Update()
 {
     if (mLeftGlove == null)
     {
         Hi5_Glove_Interaction_Hand[] temps = gameObject.GetComponentsInChildren <Hi5_Glove_Interaction_Hand>();
         if (temps != null && temps.Length > 0)
         {
             for (int i = 0; i < temps.Length; i++)
             {
                 if (temps[i].m_IsLeftHand)
                 {
                     mLeftGlove = temps[i];
                 }
             }
         }
     }
     if (mRightGlove == null)
     {
         Hi5_Glove_Interaction_Hand[] temps = gameObject.GetComponentsInChildren <Hi5_Glove_Interaction_Hand>();
         if (temps != null && temps.Length > 0)
         {
             for (int i = 0; i < temps.Length; i++)
             {
                 if (!temps[i].m_IsLeftHand)
                 {
                     mRightGlove = temps[i];
                 }
             }
         }
     }
 }
        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;
        }
        void Pinch2Object(string messageKey, object param1, object param2, object param3, object param4)
        {
            if (messageKey.CompareTo(Hi5_MessageKey.messagePinchObject2) == 0)
            {
                List <int> objectIds            = param1 as List <int>;
                Hi5_Glove_Interaction_Hand hand = param2 as Hi5_Glove_Interaction_Hand;
                int objectId = (int)param3;
                if (mObjectDic.ContainsKey(objectId))
                {
                    //ruige 加入判断
                    Hi5_Glove_Interaction_Item pinchObject = mObjectDic[objectId];
                    if (pinchObject != null && pinchObject.mObjectType == EObject_Type.ECommon)
                    {
                        hand.AddPinch2Object(pinchObject.transform, hand.mVisibleHand.palm);

                        pinchObject.SetIsKinematic(true);
                        pinchObject.ChangeState(E_Object_State.EPinch);
                        Hi5_Object_State_Base state = pinchObject.mstatemanager.GetState(E_Object_State.EPinch);
                        if (state != null && (state is Hi5_Object_State_Pinch))
                        {
                            Hi5_Object_State_Pinch pinchState = state as Hi5_Object_State_Pinch;
                            if (hand.m_IsLeftHand)
                            {
                                pinchState.SetPinchHand(Hi5_Object_Pinch_Type.ELeft, hand);
                            }
                            else
                            {
                                pinchState.SetPinchHand(Hi5_Object_Pinch_Type.ERight, hand);
                            }
                        }
                    }
                }
            }
        }
        internal bool IsClap()
        {
            if (mHand.gameObject.GetComponent <Hi5_Glove_Property>() != null)
            {
                if (!mHand.gameObject.GetComponent <Hi5_Glove_Property>().Property_Data.IsClap)
                {
                    return(false);
                }
            }
            int objectId = 0;
            Hi5_Glove_Interaction_Finger_Type fingTypeOne;
            Hi5_Glove_Interaction_Finger_Type fingTypeTwo;
            bool isClap = mHand.mState.mJudgeMent.IsClap(out objectId, out fingTypeOne, out fingTypeTwo);

            Hi5_Glove_Interaction_Item item = Hi5_Interaction_Object_Manager.GetObjectManager().GetItemById(objectId);

            if (item != null && (item.state == E_Object_State.EStatic || item.state == E_Object_State.EPoke))
            {
                Hi5_Object_State_Clap clapState = item.mstatemanager.GetState(E_Object_State.EClap) as Hi5_Object_State_Clap;
                clapState.fingerTypeOne = fingTypeOne;
                clapState.fingerTypeTwo = fingTypeTwo;
                clapState.hand          = mHand;
                if (mHand.m_IsLeftHand)
                {
                    clapState.handType = Hi5_Object_State_Clap.Hi5_Object_Clap_Type.ELeft;
                }
                else
                {
                    clapState.handType = Hi5_Object_State_Clap.Hi5_Object_Clap_Type.ERight;
                }
                Hi5_Glove_Interaction_Hand handTemp = mHand;
                item.mstatemanager.ChangeState(E_Object_State.EClap);
                Hi5_Glove_State_Clap handState = null;
                mState.GetGloveState <Hi5_Glove_State_Clap> (E_Hand_State.EClap, out handState);
                if (handState != null)
                {
                    handState.objectId = objectId;
                }

                mState.ChangeState(E_Hand_State.EClap);
                {
                    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.EClap);
                    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.EClap);
                    Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageHandEvent, (object)data, null);
                }

                return(true);
            }
            return(false);
        }
예제 #7
0
 internal protected void Init(Hi5_Glove_Interaction_Hand hand,
                              Hi5_Glove_Interaction_State state,
                              Hi5_Glove_Decision decision)
 {
     Hand      = hand;
     mState    = state;
     mDecision = decision;
 }
예제 #8
0
        override public void End()
        {
            hand.mState.ChangeState(E_Hand_State.ERelease);


            hand = null;
            mRecord.RecordClean();
        }
예제 #9
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);
        }
예제 #10
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);
        }
예제 #11
0
 void PichOtherHandRealse(string messageKey, object param1, object param2, object param3, object param4)
 {
     if (messageKey.CompareTo(Hi5_MessageKey.messagePichOtherHandRealse) == 0)
     {
         Hi5_Glove_Interaction_Hand hand = param1 as Hi5_Glove_Interaction_Hand;
         if (this != hand)
         {
             mState.ChangeState(E_Hand_State.ERelease);
             mPinchObjectId = -1;
         }
     }
 }
예제 #12
0
        internal bool IsLift()
        {
            int objectId = 0;
            // Hi5_Glove_Interaction_Finger_Type fingType;
            bool islift = mHand.mState.mJudgeMent.IsLift(out objectId);

            Hi5_Glove_Interaction_Item item = Hi5_Interaction_Object_Manager.GetObjectManager().GetItemById(objectId);

            if (item != null &&
                item.mObjectType == EObject_Type.ECommon &&
                (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)) &&
                islift)
            {
                Hi5_Glove_State_Lift liftState = mHand.mState.GetBaseState(E_Hand_State.ELift) as Hi5_Glove_State_Lift;
                liftState.objectId = objectId;
                Hi5_Glove_Interaction_Hand handTemp = mHand;
                Hi5_Interaction_Message.GetInstance().DispenseMessage(Hi5_MessageKey.messageLiftObject, mHand, objectId);
                if (Hi5_Interaction_Const.TestChangeState)
                {
                    mState.ChangeState(E_Hand_State.ELift);
                }
                {
                    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.ELift);
                    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.ELift);
                    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.ELift;
                //data.mObjectId = item.idObject;
                //Hi5InteractionManger.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null);
                return(true);
            }
            return(false);
        }
        override public void End()
        {
//			if (Hi5_Interaction_Const.TestLift)
//			{
//				if(ObjectItem.state != E_Object_State.EPinch)
//					ObjectItem.transform.parent = Hi5_Interaction_Object_Manager.GetObjectManager ().transform;
//			}
            ///mObjectItem.ChangeColor (mObjectItem.orgColor);
            if (Hi5_Interaction_Const.TestChangeState)
            {
                hand.mState.ChangeState(E_Hand_State.ERelease);
            }
            hand.mPalm.OpenPhyCollider(false);
            hand = null;
            mRecord.RecordClean();
        }
        void FlyPinchObject(string messageKey, object param1, object param2, object param3, object param4)
        {
            if (messageKey.CompareTo(Hi5_MessageKey.messageFlyPinchObject) == 0)
            {
                List <int> objectIds            = param1 as List <int>;
                Hi5_Glove_Interaction_Hand hand = param2 as Hi5_Glove_Interaction_Hand;
                int objectId = (int)param3;

                if (mObjectDic.ContainsKey(objectId))
                {
                    // Debug.Log("FlyPinchObject");
                    Hi5_Glove_Interaction_Item pinchObject = mObjectDic[objectId];
                    if (pinchObject != null && pinchObject.mObjectType == EObject_Type.ECommon)
                    {
                        hand.AddPinchObject(pinchObject.transform, hand.mVisibleHand.palm);
                        pinchObject.SetIsKinematic(true);

                        //pinchObject.transform.position = hand.mPalm.transform.position;
                        pinchObject.ChangeState(E_Object_State.EPinch);
                        Hi5_Object_State_Base state = pinchObject.mstatemanager.GetState(E_Object_State.EPinch);
                        if (state != null && (state is Hi5_Object_State_Pinch))
                        {
                            Hi5_Object_State_Pinch pinchState = state as Hi5_Object_State_Pinch;
                            //pinchState.isTestRelease = true;
                            if (hand.m_IsLeftHand)
                            {
                                pinchState.SetPinchHand(Hi5_Object_Pinch_Type.ELeft, hand);
                            }
                            else
                            {
                                pinchState.SetPinchHand(Hi5_Object_Pinch_Type.ERight, hand);
                            }
                        }
                    }
                }
                //if (objectIds != null && objectIds.Count > 0 && mObjectDic.ContainsKey(objectIds[0]))
                //{
                //    Hi5_Glove_Interraction_Item pinchObject = mObjectDic[objectIds[0]];
                //    hand.AddPinchObject(pinchObject.transform);
                //    pinchObject.SetIsKinematic(true);
                //    pinchObject.ChangeState(E_Object_State.EPinch);
                //}
            }
        }
예제 #15
0
        public override void End()
        {
            fingerTypeOne = Hi5_Glove_Interaction_Finger_Type.ENone;
            fingerTypeTwo = Hi5_Glove_Interaction_Finger_Type.ENone;
            handType      = Hi5_Object_Clap_Type.ENone;

            //if (Hi5_Interaction_Const.TestChangeState)
            {
                if (hand != null)
                {
                    hand.mState.ChangeState(E_Hand_State.ERelease);
                }
            }
            hand = null;
//			ObjectItem.SetIsKinematic (false);
//			ObjectItem.SetUseGravity (true);
//			ObjectItem.SetIsLockYPosition (false);
            //ObjectItem.ChangeColor(ObjectItem.orgColor);
        }
예제 #16
0
        void PinchObject(string messageKey, object param1, object param2, object param3, object param4)
        {
            if (messageKey.CompareTo(Hi5_MessageKey.messagePinchObject) == 0)
            {
                List <int> objectIds            = param1 as List <int>;
                Hi5_Glove_Interaction_Hand hand = param2 as Hi5_Glove_Interaction_Hand;
                int objectId = (int)param3;
                if (mObjectDic.ContainsKey(objectId))
                {
                    Hi5_Glove_Interaction_Item pinchObject = mObjectDic[objectId];
                    hand.AddPinchObject(pinchObject.transform);
                    pinchObject.SetIsKinematic(true);

                    pinchObject.ChangeState(E_Object_State.EPinch);

                    Hi5_Object_State_Base state = pinchObject.mstatemanager.GetState(E_Object_State.EPinch);
                    if (state != null && (state is Hi5_Object_State_Pinch))
                    {
                        Hi5_Object_State_Pinch pinchState = state as Hi5_Object_State_Pinch;
                        if (hand.m_IsLeftHand)
                        {
                            pinchState.SetPinchHand(Hi5_Object_Pinch_Type.ELeft, hand);
                        }
                        else
                        {
                            pinchState.SetPinchHand(Hi5_Object_Pinch_Type.ERight, hand);
                        }
                    }
                }
                //if (objectIds != null && objectIds.Count > 0 && mObjectDic.ContainsKey(objectIds[0]))
                //{
                //    Hi5_Glove_Interraction_Item pinchObject = mObjectDic[objectIds[0]];
                //    hand.AddPinchObject(pinchObject.transform);
                //    pinchObject.SetIsKinematic(true);
                //    pinchObject.ChangeState(E_Object_State.EPinch);
                //}
            }
        }
 void LiftObject(string messageKey, object param1, object param2, object param3, object param4)
 {
     //Debug.Log("LiftObject");
     // Hi5_MessageKey.messageLiftObject, Hand, ObjectId
     if (messageKey.CompareTo(Hi5_MessageKey.messageLiftObject) == 0)
     {
         Hi5_Glove_Interaction_Hand hand = param1 as Hi5_Glove_Interaction_Hand;
         int id = (int)param2;
         if (mObjectDic.ContainsKey(id))
         {
             Hi5_Glove_Interaction_Item pinchObject = mObjectDic[id];
             if (pinchObject != null && pinchObject.mObjectType == EObject_Type.ECommon)
             {
                 Hi5_Object_State_Base state = pinchObject.mstatemanager.GetState(E_Object_State.EFlyLift);
                 if (state is Hi5_Object_State_Fly_Lift)
                 {
                     (state as Hi5_Object_State_Fly_Lift).hand = hand;
                 }
                 pinchObject.mstatemanager.ChangeState(E_Object_State.EFlyLift);
             }
         }
     }
 }
예제 #18
0
        override public void Update(float deltaTime)
        {
            FollowpalmMove(deltaTime);
            mRecord.RecordPosition(Time.deltaTime, mObjectItem.transform);
            if (mObjectItem.GetComponent <BoxCollider>() != null)
            {
                //  mObjectItem.transform.localPosition = offset;
            }
            //if (test2)
            //{
            //Vector3 tempParentPosition = parentTransform.position;
            //mObjectItem.transform.localPosition = parentPosition;
            //parentPosition = parentTransform.position;
            //}

            bool  IsRelease = false;
            float distance  = Vector3.Distance(hand.mPalm.transform.position, mObjectItem.transform.position);

            if (distance > Hi5_Interaction_Const.liftChangeMoveDistance)
            {
                IsRelease = true;
            }
            //
            float angle = Vector3.Angle(Hi5_Interaction_Object_Manager.GetObjectManager().transform.up, -hand.mPalm.transform.up);

            if (!IsRelease && angle > 40.0f && angle > 0.0f)
            {
                IsRelease = true;
            }
            if (!IsRelease && !mObjectItem.IsLiftTrigger())
            {
                //Debug.Log("lis release");
                //if(!Hi5_Interaction_Const.TestLiftRelease)
                //    IsRelease = true;
            }
            if (IsRelease)
            {
                mObjectItem.GetComponent <Rigidbody>().constraints = preConstraints;
                hand.mPalm.OpenPhyCollider(false);
                Transform temp = hand.mPalm.transform;
                ObjectItem.transform.parent = Hi5_Interaction_Object_Manager.GetObjectManager().transform;
                if (mObjectItem.mObjectType == EObject_Type.ECommon)
                {
                    Hi5_Glove_Interaction_Hand handTemp = hand;
                    mObjectItem.ChangeState(E_Object_State.EMove);
                    //if(mObjectItem.mstatemanager != null && mObjectItem.mstatemanager.GetMoveState() != null)
                    mObjectItem.mstatemanager.GetMoveState().SetFreeMove(temp);
                    {
                        Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(ObjectItem.idObject,
                                                                                                                        ObjectItem.mObjectType,
                                                                                                                        handTemp.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight,
                                                                                                                        EEventObjectType.EMove);
                        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(ObjectItem.idObject,
                                                                                                                    handTemp.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight,
                                                                                                                    EEventHandType.ERelease);
                        Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageHandEvent, (object)data, null);
                    }
                }
            }
            //}
        }
 internal Hi5_Glove_Decision(Hi5_Object_JudgeMent judgement, Hi5_Glove_Interaction_Hand hand, Hi5_Glove_Interaction_State state)
 {
     mJudgeMent = judgement;
     mHand      = hand;
     mState     = state;
 }
예제 #20
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);
        }
 internal void CacullateThrowMove(Queue <Hi5_Position_Record> records, Transform handPalm, Hi5_Glove_Interaction_Hand hand)
 {
     if (mDicState[E_Object_State.EMove] is Hi5_Object_State_Move)
     {
         if ((mDicState[E_Object_State.EMove] as Hi5_Object_State_Move).Move != null)
         {
             (mDicState[E_Object_State.EMove] as Hi5_Object_State_Move).Move.CacullateThrowMove(records, handPalm, hand);
         }
     }
 }
        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);
        }
        //GameObject Clone = null;
        internal void CalculateThrowMove(Queue <Hi5_Position_Record> records, Transform handPalm, Hi5_Glove_Interaction_Hand hand)
        {
            mIsFlyMovePause = false;
            int     index            = 0;
            int     weightPointCount = 0;
            float   timeCount        = 0.0f;
            Vector3 distanceVector   = Vector3.zero;

            foreach (Hi5_Position_Record item in records)
            {
                if (Hi5_Interaction_Const.RecordPositionWeight.Length > index)
                {
                    int weight = Hi5_Interaction_Const.RecordPositionWeight[index];
                    weightPointCount += weight;
                    timeCount        += item.mIntervalTime * weight;
                    distanceVector   += item.mMoveVector * weight;
                }
                index++;
            }
            if (index <= 1)
            {
//				mMoveData = new ObjectMoveData();
//				mMoveData.mDirection = new Vector3 (0.0f, 0.08598139f, 0.0f);
//				mMoveData.y = mMoveData.mDirection.y;
//				mMoveData.ySpeed = mMoveData.mDirection.y;
                //Debug.Log("index <= 1");
                Vector3 temp = hand.MoveAnchor.position - hand.mPalm.transform.position;
                temp.Normalize();
                mMoveData            = new ObjectMoveData();
                mMoveData.mDirection = temp * 0.3998139f;
                mMoveData.y          = mMoveData.mDirection.y;
                mMoveData.ySpeed     = mMoveData.mDirection.y;

//				mMoveData = new ObjectMoveData();
//				mMoveData.mDirection = distanceVector / timeCount* Hi5_Interaction_Const.ThrowSpeed;
//				mMoveData.y = mMoveData.mDirection.y;
//				mMoveData.ySpeed = mMoveData.mDirection.y;

                Hi5_Interaction_Const.WriteItemMoveXml(records, mMoveData);
            }
            else
            {
                //Debug.Log("index > 1");
                mMoveData            = new ObjectMoveData();
                mMoveData.mDirection = distanceVector / timeCount * Hi5_Interaction_Const.ThrowSpeed;
                mMoveData.y          = mMoveData.mDirection.y;
                mMoveData.ySpeed     = mMoveData.mDirection.y;
                Hi5_Interaction_Const.WriteItemMoveXml(records, mMoveData);
            }

            //if (Hi5_Interaction_Const.TestPhycis)
            //if (Hi5_Interaction_Const.TestModifyConstraints)
            {
                //mItem.SetIsKinematic (false);
                //mItem.SetUseGravity (true);
                //mItem.CleanLock ();

                if (mItem.GetComponent <Hi5_Object_Property>() != null &&
                    mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.AirMoveProperty != null)
                {
                    mItem.SetIsKinematic(false);
                    mItem.SetUseGravity(true);
                    mItem.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None;
                    mItem.GetComponent <Hi5_Object_Property>().SetRotation(mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.AirMoveProperty.ConstraintsFreezeRotation,
                                                                           mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.AirMoveProperty.ConstraintsFreezeRotation,
                                                                           mItem.GetComponent <Hi5_Object_Property>().ObjectProperty.AirMoveProperty.ConstraintsFreezeRotation);
                }
                else
                {
                    mItem.SetIsKinematic(false);
                    mItem.SetUseGravity(true);
                    mItem.CleanLock();
                }
            }

            mMoveType          = Hi5ObjectMoveType.EThrowMove;
            protectedTransform = handPalm;
            IsProtectFly       = true;
        }
 internal protected void SetHi5Hand(Hi5_Glove_Interaction_Hand hand)
 {
     mHand = hand;
 }
 internal Hi5_Glove_Gesture_Recognition(Hi5_Glove_Interaction_Hand hand)
 {
     mRecord = new Hi5_Glove_Gesture_Recognition_Record();
     mHand   = hand;
 }
        override public void Update(float deltaTime)
        {
            FollowpalmMove(deltaTime);


            mRecord.RecordPosition(Time.deltaTime, mObjectItem.transform);

//			if (!Hi5_Interaction_Const.TestLift) {
//				if (hand != null && hand.mPalm != null) {
//					float distance = Vector3.Distance (hand.mPalm.transform.position, mObjectItem.transform.position);
//					if (distance > Hi5_Interaction_Const.liftChangeMoveDistance) {
//						Transform temp = hand.mPalm.transform;
//						if (mObjectItem.mObjectType == EObject_Type.ECommon) {
//							Hi5_Glove_Interaction_Hand handtemp = hand;
//							mObjectItem.ChangeState (E_Object_State.EMove);
//							//if(mObjectItem.mstatemanager != null && mObjectItem.mstatemanager.GetMoveState() != null)
//							mObjectItem.mstatemanager.GetMoveState ().SetFreeMove (temp);
//							{
//								Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance (ObjectItem.idObject,
//									                                               ObjectItem.mObjectType,
//									handtemp.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight,
//									                                               EEventObjectType.EMove);
//								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 (ObjectItem.idObject,
//									handtemp.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight,
//									                                             EEventHandType.ERelease);
//								Hi5InteractionManager.Instance.GetMessage ().DispenseMessage (Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageHandEvent, (object)data, null);
//							}
//
//
//						}
//
//					}
//				}
//
//			}
//			else
//			{
            bool  IsRelease = false;
            float distance  = Vector3.Distance(hand.mPalm.transform.position, mObjectItem.transform.position);

            if (distance > Hi5_Interaction_Const.liftChangeMoveDistance)
            {
                IsRelease = true;
                //Debug.Log("distance release");
            }

            float angle = Vector3.Angle(Hi5_Interaction_Object_Manager.GetObjectManager().transform.up, -hand.mPalm.transform.up);

            //Debug.Log("IsLift angle" + angle);
            if (!IsRelease && angle > 40.0f && angle > 0.0f)
            {
                IsRelease = true;
                //Debug.Log("angle release");
            }
            if (!IsRelease && !mObjectItem.IsLiftTrigger())
            {
                IsRelease = true;
            }
            if (IsRelease)
            {
                Transform temp = hand.mPalm.transform;
                ObjectItem.transform.parent = Hi5_Interaction_Object_Manager.GetObjectManager().transform;
                if (mObjectItem.mObjectType == EObject_Type.ECommon)
                {
                    Hi5_Glove_Interaction_Hand handTemp = hand;
                    mObjectItem.ChangeState(E_Object_State.EMove);
                    //if(mObjectItem.mstatemanager != null && mObjectItem.mstatemanager.GetMoveState() != null)
                    mObjectItem.mstatemanager.GetMoveState().SetFreeMove(temp);

                    {
                        Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(ObjectItem.idObject,
                                                                                                                        ObjectItem.mObjectType,
                                                                                                                        handTemp.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight,
                                                                                                                        EEventObjectType.EMove);
                        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(ObjectItem.idObject,
                                                                                                                    handTemp.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight,
                                                                                                                    EEventHandType.ERelease);
                        Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageHandEvent, (object)data, null);
                    }
                }
            }
            //}
        }
예제 #27
0
 internal void CalculateThrowMove(Transform handPalm, Hi5_Glove_Interaction_Hand hand)
 {
     mstatemanager.CalculateThrowMove(mQueuePositionRecord, handPalm, hand);
 }
        void UnPinchObject(string messageKey, object param1, object param2, object param3, object param4)
        {
            if (messageKey.CompareTo(Hi5_MessageKey.messageUnPinchObject) == 0)
            {
                //Debug.Log ("UnPinchObject");
                int objectId = (int)param1;
                Hi5_Glove_Interaction_Hand hand = param2 as Hi5_Glove_Interaction_Hand;
                if (mObjectDic.ContainsKey(objectId))
                {
                    Hi5_Glove_Interaction_Item pinchObject = mObjectDic[objectId];
                    if (pinchObject != null && pinchObject.mObjectType == EObject_Type.ECommon)
                    {
                        Hi5_Object_State_Base state = pinchObject.mstatemanager.GetState(E_Object_State.EPinch);
                        bool isRelease        = false;
                        bool OtherHandRelease = false;
                        if (state != null && state is Hi5_Object_State_Pinch)
                        {
                            Hi5_Object_State_Pinch pinchState = state as Hi5_Object_State_Pinch;
                            if (pinchState != null && !pinchState.isTestRelease)
                            {
                                if (hand.m_IsLeftHand)
                                {
                                    isRelease = pinchState.CancelPinchHand(Hi5_Object_Pinch_Type.ELeft, out OtherHandRelease);
                                }
                                else
                                {
                                    isRelease = pinchState.CancelPinchHand(Hi5_Object_Pinch_Type.ERight, out OtherHandRelease);
                                }
                            }
                        }
                        if (OtherHandRelease)
                        {
                            Hi5_Interaction_Message.GetInstance().DispenseMessage(Hi5_MessageKey.messagePinchOtherHandRelease, hand, objectId);
                        }

                        if (isRelease)
                        {
                            if (!pinchObject.isTouchPlane)
                            {
                                //Debug.Log ("!pinchObject.isTouchPlane");

                                pinchObject.ChangeState(E_Object_State.EMove);
                                pinchObject.CalculateThrowMove(hand.mPalm.transform, hand);
                                pinchObject.CleanRecord();
//								if (Hi5_Interaction_Const.TestChangeState)
//									hand.mState.ChangeState(E_Hand_State.ERelease);
                                {
                                    Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(pinchObject.idObject,
                                                                                                                                    pinchObject.mObjectType,
                                                                                                                                    hand.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight,
                                                                                                                                    EEventObjectType.EMove);
                                    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(pinchObject.idObject,
                                                                                                                                hand.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight,
                                                                                                                                EEventHandType.EThrow);
                                    Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageHandEvent, (object)data, null);
                                }
                            }
                            else
                            {
                                Debug.Log("pinchObject.isTouchPlane");
                                //if (Hi5_Interaction_Const.TestChangeState)
                                hand.mState.ChangeState(E_Hand_State.ERelease);
                                pinchObject.ChangeState(E_Object_State.EStatic);
                                Hi5_Object_State_Static staticState = pinchObject.mstatemanager.GetState(E_Object_State.EStatic) as Hi5_Object_State_Static;
                                staticState.ResetPreTransform();
                                {
                                    Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(pinchObject.idObject,
                                                                                                                                    pinchObject.mObjectType,
                                                                                                                                    hand.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight,
                                                                                                                                    EEventObjectType.EStatic);
                                    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(pinchObject.idObject,
                                                                                                                                hand.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight,
                                                                                                                                EEventHandType.ERelease);
                                    Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageHandEvent, (object)data, null);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #29
0
 internal bool CancelPinchHand(Hi5_Object_Pinch_Type handType, out bool OtherIsRelease)
 {
     if (mPinchType == Hi5_Object_Pinch_Type.EDouble)
     {
         if (handType == Hi5_Object_Pinch_Type.ELeft)
         {
             mPinchType = Hi5_Object_Pinch_Type.ERight;
             if (m_right_hand != null)
             {
                 List <int> handList;
                 bool       IsOtherHandTrigger = false;
                 if (m_right_hand.mHandCollider.IsPinch(out handList))
                 {
                     if (handList != null)
                     {
                         foreach (int item in handList)
                         {
                             if (item == ObjectItem.idObject)
                             {
                                 IsOtherHandTrigger = true;
                                 break;
                             }
                         }
                     }
                 }
                 if (IsOtherHandTrigger)
                 {
                     ObjectItem.transform.parent = m_right_hand.mVisibleHand.palm.transform;
                     m_left_hand    = null;
                     OtherIsRelease = false;
                     return(false);
                 }
                 else
                 {
                     ObjectItem.transform.parent = Hi5_Interaction_Object_Manager.GetObjectManager().transform;
                     m_left_hand    = null;
                     OtherIsRelease = true;
                     m_right_hand   = null;
                     mPinchType     = Hi5_Object_Pinch_Type.ENone;
                     return(true);
                 }
             }
             else
             {
                 ObjectItem.transform.parent = Hi5_Interaction_Object_Manager.GetObjectManager().transform;
                 m_left_hand    = null;
                 OtherIsRelease = true;
                 m_right_hand   = null;
                 mPinchType     = Hi5_Object_Pinch_Type.ENone;
                 return(true);
             }
         }
         else if (handType == Hi5_Object_Pinch_Type.ERight)
         {
             mPinchType = Hi5_Object_Pinch_Type.ELeft;
             if (m_left_hand != null)
             {
                 List <int> handList;
                 bool       IsOtherHandTrigger = false;
                 if (m_left_hand.mHandCollider.IsPinch(out handList))
                 {
                     if (handList != null)
                     {
                         foreach (int item in handList)
                         {
                             if (item == ObjectItem.idObject)
                             {
                                 IsOtherHandTrigger = true;
                                 break;
                             }
                         }
                     }
                 }
                 if (IsOtherHandTrigger)
                 {
                     ObjectItem.transform.parent = m_left_hand.mVisibleHand.palm.transform;
                     m_right_hand   = null;
                     OtherIsRelease = false;
                     return(false);
                 }
                 else
                 {
                     ObjectItem.transform.parent = Hi5_Interaction_Object_Manager.GetObjectManager().transform;
                     m_right_hand   = null;
                     OtherIsRelease = true;
                     m_left_hand    = null;
                     mPinchType     = Hi5_Object_Pinch_Type.ENone;
                     return(true);
                 }
             }
             else
             {
                 ObjectItem.transform.parent = Hi5_Interaction_Object_Manager.GetObjectManager().transform;
                 m_right_hand   = null;
                 OtherIsRelease = true;
                 m_left_hand    = null;
                 mPinchType     = Hi5_Object_Pinch_Type.ENone;
                 return(true);
             }
         }
         else
         {
             ObjectItem.transform.parent = Hi5_Interaction_Object_Manager.GetObjectManager().transform;
             m_right_hand   = null;
             OtherIsRelease = true;
             m_left_hand    = null;
             mPinchType     = Hi5_Object_Pinch_Type.ENone;
             return(true);
         }
     }
     else if (mPinchType == handType)
     {
         mPinchType = Hi5_Object_Pinch_Type.ENone;
         if (handType == Hi5_Object_Pinch_Type.ELeft)
         {
             ObjectItem.transform.parent = Hi5_Interaction_Object_Manager.GetObjectManager().transform;
             OtherIsRelease = false;
             m_left_hand    = null;
         }
         else if (handType == Hi5_Object_Pinch_Type.ERight)
         {
             ObjectItem.transform.parent = Hi5_Interaction_Object_Manager.GetObjectManager().transform;
             OtherIsRelease = false;
             m_right_hand   = null;
         }
         else
         {
             ObjectItem.transform.parent = Hi5_Interaction_Object_Manager.GetObjectManager().transform;
             OtherIsRelease = false;
         }
         return(true);
     }
     else
     {
         ObjectItem.transform.parent = Hi5_Interaction_Object_Manager.GetObjectManager().transform;
         m_right_hand   = null;
         OtherIsRelease = true;
         m_left_hand    = null;
         mPinchType     = Hi5_Object_Pinch_Type.ENone;
         return(true);
     }
 }
예제 #30
0
        internal void CacullateThrowMove(Queue <Hi5_Position_Record> records, Transform handPalm, Hi5_Glove_Interaction_Hand hand)
        {
            mIsFlyMovePause = false;
            int     index            = 0;
            int     weightPointCount = 0;
            float   timeCount        = 0.0f;
            Vector3 distanceVector   = Vector3.zero;

            foreach (Hi5_Position_Record item in records)
            {
                if (Hi5_Interaction_Const.RecordPositionWeight.Length > index)
                {
                    int weight = Hi5_Interaction_Const.RecordPositionWeight[index];
                    weightPointCount += weight;
                    timeCount        += item.mIntervalTime * weight;
                    distanceVector   += item.mMoveVector * weight;
                }
                index++;
            }
            if (index <= 1)
            {
//				mMoveData = new ObjectMoveData();
//				mMoveData.mDirection = new Vector3 (0.0f, 0.08598139f, 0.0f);
//				mMoveData.y = mMoveData.mDirection.y;
//				mMoveData.ySpeed = mMoveData.mDirection.y;

                Vector3 temp = hand.MoveAnchor.position - hand.mPalm.transform.position;
                temp.Normalize();
                mMoveData            = new ObjectMoveData();
                mMoveData.mDirection = temp * 0.3998139f;
                mMoveData.y          = mMoveData.mDirection.y;
                mMoveData.ySpeed     = mMoveData.mDirection.y;

//				mMoveData = new ObjectMoveData();
//				mMoveData.mDirection = distanceVector / timeCount* Hi5_Interaction_Const.ThrowSpeed;
//				mMoveData.y = mMoveData.mDirection.y;
//				mMoveData.ySpeed = mMoveData.mDirection.y;

                Hi5_Interaction_Const.WriteItemMoveXml(records, mMoveData);
            }
            else
            {
                mMoveData            = new ObjectMoveData();
                mMoveData.mDirection = distanceVector / timeCount * Hi5_Interaction_Const.ThrowSpeed;
                mMoveData.y          = mMoveData.mDirection.y;
                mMoveData.ySpeed     = mMoveData.mDirection.y;
                Hi5_Interaction_Const.WriteItemMoveXml(records, mMoveData);
            }



            //if (Hi5_Interaction_Const.TestFlyMoveNoUsedGravity)
            {
                mItem.SetIsKinematic(true);
                mItem.SetUseGravity(false);
            }
            //else
            //{
            //    mItem.SetIsKinematic(false);
            //    mItem.SetUseGravity(true);
            //}


            mMoveType         = Hi5ObjectMoveType.EThrowMove;
            protecedTransform = handPalm;
            IsProtectFly      = true;
        }