private void Reset(string messageKey, object param1, object param2, object param3, object param4) { if (mObjectType == EObject_Type.ECommon) { if (messageKey.CompareTo(Hi5_MessageKey.messageObjectReset) == 0) { transform.parent = Hi5_Interaction_Object_Manager.GetObjectManager().transform; transform.position = originalPosition; transform.rotation = originalRotation; transform.gameObject.GetComponent <Rigidbody>().Sleep(); #if UNITY_2017_2_OR_NEWER #else transform.gameObject.GetComponent <Rigidbody>().WakeUp(); #endif mstatemanager.ChangeState(E_Object_State.EMove); mstatemanager.GetMoveState().mMoveType = Hi5ObjectMoveType.EFree; //if (Hi5_Interaction_Const.TestChangeState) { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(idObject, mObjectType, EHandType.EHandLeft, EEventObjectType.EStatic); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } SetIsKinematic(false); //if (!Hi5_Interaction_Const.TestModifyConstraints) // SetIsLockYPosition(true); SetUseGravity(true); } } }
public override void Update(float deltaTime) { if (ObjectItem.mObjectType == EObject_Type.ECommon) { ObjectItem.SetIsKinematic(true); ObjectItem.SetIsLockYPosition(true); ObjectItem.SetUseGravity(true); } else { ObjectItem.SetIsKinematic(true); ObjectItem.SetIsLockYPosition(true); ObjectItem.SetUseGravity(true); } cd -= deltaTime; if (IsRealese() && cd < 0.0f) { ObjectItem.mstatemanager.ChangeState(E_Object_State.EStatic); { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(ObjectItem.idObject, ObjectItem.mObjectType, handType == Hi5_Object_Clap_Type.ELeft ? 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(ObjectItem.idObject, handType == Hi5_Object_Clap_Type.ELeft ? EHandType.EHandLeft : EHandType.EHandRight, EEventHandType.ERelease); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageHandEvent, (object)data, null); } } }
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); }
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 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); }
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); }
private void FreeFly(float deltaTime) { //if (Hi5_Interaction_Const.TestPlaneMoveUsePhysic) { //if (!Hi5_Interaction_Const.TestModifyConstraints) //{ // mItem.SetUseGravity(true); // mItem.SetIsKinematic(false); // mItem.CleanLock(); //} //if (Hi5_Interaction_Const.TestPlaneStatic) { if (mItem.isTouchPlane) { mState.ChangeState(E_Object_State.EStatic); //if (Hi5_Interaction_Const.TestChangeState) { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(mItem.idObject, mItem.mObjectType, EHandType.EHandLeft, EEventObjectType.EStatic); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } } if (mItem.mQueuePositionRecord != null) { Hi5_Position_Record[] records = mItem.mQueuePositionRecord.ToArray(); if (records != null && records.Length > 0) { if (records.Length - 2 > 0) { Vector3 offset = records [records.Length - 2].position - records [records.Length - 1].position; if (Mathf.Abs(offset.x) < 0.003f && Mathf.Abs(offset.y) < 0.003f && Mathf.Abs(offset.z) < 0.003f) { //Debug.Log("FreeFly test"); mState.ChangeState(E_Object_State.EStatic); //if (Hi5_Interaction_Const.TestChangeState) { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(mItem.idObject, mItem.mObjectType, EHandType.EHandLeft, EEventObjectType.EStatic); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } } } } } } } }
internal void NotifyPokeEvent(Collider other) { { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(idObject, mObjectType, other.gameObject.GetComponent <Hi5_Glove_Collider_Finger> ().mFinger.mHand.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight, EEventObjectType.EPoke); 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(idObject, other.gameObject.GetComponent <Hi5_Glove_Collider_Finger> ().mFinger.mHand.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight, EEventHandType.EPoke); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageHandEvent, (object)data, null); } }
//#if Test_Assembly internal void OnItemTriggerEnter(Collider collision) { //Debug.Log ("Hi5_Glove_Interaction_Item OnItemTriggerEnter ENTER"); if (collision.gameObject.layer == Hi5_Interaction_Const.PlaneLayer()) { if (mObjectType == EObject_Type.ECommon) { //Debug.Log ("Hi5_Glove_Interaction_Item OnItemTriggerEnter"); mstatemanager.StopThrowMove(true); //if (Hi5_Interaction_Const.TestPlanePhycis) { //} //else // transform.rotation = Quaternion.Euler(0.0f, transform.eulerAngles.y, 0.0f); { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(idObject, mObjectType, EHandType.EHandLeft, EEventObjectType.EStatic); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } } } if (collision.gameObject.layer == Hi5_Interaction_Const.ObjectGrasp()) { if ((collision.gameObject.GetComponent <Hi5_Glove_Interaction_Item> () != null && collision.gameObject.GetComponent <Hi5_Glove_Interaction_Item> ().state == E_Object_State.EStatic) || (collision.transform.parent.gameObject.GetComponent <Hi5_Glove_Interaction_Item> () != null && collision.transform.parent.gameObject.GetComponent <Hi5_Glove_Interaction_Item> ().state == E_Object_State.EStatic)) { if (mObjectType == EObject_Type.ECommon) { //Debug.Log ("Hi5_Glove_Interaction_Item OnItemTriggerEnter"); mstatemanager.StopThrowMove(true); //transform.rotation = Quaternion.Euler(0.0f, transform.eulerAngles.y, 0.0f); //if (Hi5_Interaction_Const.TestChangeState) { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(idObject, mObjectType, EHandType.EHandLeft, EEventObjectType.EStatic); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } } } } }
override protected void OnTriggerExit(Collider other) { base.OnTriggerExit(other); if (mObjectType == EObject_Type.EButton) { if (other.gameObject.layer == Hi5_Interaction_Const.ThumbTailLayer() || other.gameObject.layer == Hi5_Interaction_Const.OtherFingerTailLayer()) { if (other.gameObject.GetComponent <Hi5_Glove_Collider_Finger> () != null && other.gameObject.GetComponent <Hi5_Glove_Collider_Finger> ().mFinger != null && other.gameObject.GetComponent <Hi5_Glove_Collider_Finger> ().mFinger.mHand != null) { if (state == E_Object_State.EPoke) { this.ChangeState(E_Object_State.EStatic); if (Hi5_Interaction_Const.TestChangeState) { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(idObject, mObjectType, other.gameObject.GetComponent <Hi5_Glove_Collider_Finger> ().mFinger.mHand.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight, EEventObjectType.EStatic); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } } } } } else if (mObjectType == EObject_Type.ECommon) { if (other.gameObject.layer == Hi5_Interaction_Const.ThumbTailLayer() || other.gameObject.layer == Hi5_Interaction_Const.OtherFingerTailLayer()) { if (other.gameObject.GetComponent <Hi5_Glove_Collider_Finger> () != null && other.gameObject.GetComponent <Hi5_Glove_Collider_Finger> ().mFinger != null && other.gameObject.GetComponent <Hi5_Glove_Collider_Finger> ().mFinger.mHand != null) { IsPokeInLoop = false; } } } }
private void Reset(string messageKey, object param1, object param2, object param3, object param4) { if (mObjectType == EObject_Type.ECommon) { if (messageKey.CompareTo(Hi5_MessageKey.messageObjectReset) == 0) { transform.parent = Hi5_Interaction_Object_Manager.GetObjectManager().transform; transform.position = originalPosition; transform.rotation = originalRotation; mstatemanager.ChangeState(E_Object_State.EStatic); if (Hi5_Interaction_Const.TestChangeState) { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(idObject, mObjectType, EHandType.EHandLeft, EEventObjectType.EStatic); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } SetIsKinematic(false); SetIsLockYPosition(true); SetUseGravity(true); } } }
internal void OnItemTriggerEnter(Collider collision) { if (collision.gameObject.layer == Hi5_Interaction_Const.PlaneLayer()) { if (mObjectType == EObject_Type.ECommon) { //Debug.Log ("OnItemTriggerEnter collision"+transform.eulerAngles.y); mstatemanager.StopThrowMove(); transform.rotation = Quaternion.Euler(0.0f, transform.eulerAngles.y, 0.0f); if (Hi5_Interaction_Const.TestChangeState) { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(idObject, mObjectType, EHandType.EHandLeft, EEventObjectType.EStatic); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } //transform.position = new Vector3(transform.position.x, Y-0.001f, transform.position.z); //Debug.Log ("transform.rotation x"+ transform.rotation.x+" y"+ transform.rotation.y+"transform.rotation z"+ transform.rotation.z); } } if (collision.gameObject.layer == Hi5_Interaction_Const.ObjectGrasp() && collision.gameObject.GetComponent <Hi5_Glove_Interaction_Item>() != null && collision.gameObject.GetComponent <Hi5_Glove_Interaction_Item>().state == E_Object_State.EStatic) { if (mObjectType == EObject_Type.ECommon) { //Debug.Log ("OnItemTriggerEnter collision"+transform.eulerAngles.y); mstatemanager.StopThrowMove(); transform.rotation = Quaternion.Euler(0.0f, transform.eulerAngles.y, 0.0f); if (Hi5_Interaction_Const.TestChangeState) { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(idObject, mObjectType, EHandType.EHandLeft, EEventObjectType.EStatic); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } //transform.position = new Vector3(transform.position.x, Y-0.001f, transform.position.z); //Debug.Log ("transform.rotation x"+ transform.rotation.x+" y"+ transform.rotation.y+"transform.rotation z"+ transform.rotation.z); } } }
private void NotifyPokeEvent(Collision collision) { if (collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Finger> () != null) { { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(idObject, mObjectType, collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Finger> ().mFinger.mHand.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight, EEventObjectType.EPoke); 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(idObject, collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Finger> ().mFinger.mHand.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight, EEventHandType.EPoke); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageHandEvent, (object)data, null); } } else if (collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Thumb_Finger> () != null) { { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(idObject, mObjectType, collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Thumb_Finger> ().mFinger.mHand.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight, EEventObjectType.EPoke); 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(idObject, collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Thumb_Finger> ().mFinger.mHand.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight, EEventHandType.EPoke); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageHandEvent, (object)data, null); } } }
private void FreeFly(float deltaTime) { //if (Hi5_Interaction_Const.TestPlaneMoveUsePhysic) { mItem.SetUseGravity(true); mItem.SetIsKinematic(false); mItem.SetIsLockYPosition(false); if (Hi5_Interaction_Const.TestPlaneStatic) { if (mItem.isTouchPlane) { mState.ChangeState(E_Object_State.EStatic); if (Hi5_Interaction_Const.TestChangeState) { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(mItem.idObject, mItem.mObjectType, EHandType.EHandLeft, EEventObjectType.EStatic); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } } if (mItem.mQueuePositionRecord != null) { Hi5_Position_Record[] records = mItem.mQueuePositionRecord.ToArray(); if (records != null && records.Length > 0) { if (records.Length - 2 > 0) { Vector3 offset = records [records.Length - 2].position - records [records.Length - 1].position; if (Mathf.Abs(offset.x) < 0.003f && Mathf.Abs(offset.y) < 0.003f && Mathf.Abs(offset.z) < 0.003f) { mState.ChangeState(E_Object_State.EStatic); if (Hi5_Interaction_Const.TestChangeState) { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(mItem.idObject, mItem.mObjectType, EHandType.EHandLeft, EEventObjectType.EStatic); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } } } } } } else { if (mItem.mQueuePositionRecord != null) { Hi5_Position_Record[] records = mItem.mQueuePositionRecord.ToArray(); if (records != null && records.Length > 0) { if (records.Length - 2 > 0) { Vector3 offset = records[records.Length - 2].position - records[records.Length - 1].position; if (Mathf.Abs(offset.x) < 0.003f && Mathf.Abs(offset.z) < 0.003f) { mState.ChangeState(E_Object_State.EStatic); if (Hi5_Interaction_Const.TestChangeState) { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(mItem.idObject, mItem.mObjectType, EHandType.EHandLeft, EEventObjectType.EStatic); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } } } } } } //if (mMoveType == Hi5ObjectMoveType.EThrowMove) { //if (mIsFlyMovePause) //{ // mWaitFlyPauseTime -= deltaTime; // if (mWaitFlyPauseTime < 0.0f) // { // mIsFlyMovePause = false; // mItem.SetUseGravity(true); // mItem.SetIsKinematic(false); // mWaitFlyPauseTime = Hi5_Interaction_Const.FingerColliderPinchPauseTime; // } // else // { // return; // } //} } } }
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); }
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); } } } //} }
override protected void OnCollisionEnter(Collision collision) { base.OnCollisionEnter(collision); if (itemObject.mObjectType == EObject_Type.ECommon) { if ((collision.gameObject.layer == Hi5_Interaction_Const.PlaneLayer()) || ((collision.gameObject.layer == Hi5_Interaction_Const.ObjectGrasp() && (collision.gameObject.GetComponent <Hi5_Glove_Interaction_Item>() != null && collision.gameObject.GetComponent <Hi5_Glove_Interaction_Item>().state == E_Object_State.EStatic) || (collision.transform.parent.gameObject.GetComponent <Hi5_Glove_Interaction_Item>() != null && collision.transform.parent.gameObject.GetComponent <Hi5_Glove_Interaction_Item>().state == E_Object_State.EStatic))) ) { if (itemObject.state == E_Object_State.EPinch) { return; } //Debug.Log ("Hi5_Interaction_Item_Collider OnCollisionEnter"); itemObject.mstatemanager.StopThrowMove(true); Vector3 separationVector = Vector3.zero; ContactPoint[] contactPoints = collision.contacts; if (contactPoints != null && contactPoints.Length > 0) { itemObject.contactPointTemp = new Hi5_Glove_Interaction_Item.ContactPointClass(); itemObject.contactPointTemp.contactPoint = contactPoints [0]; float separation = itemObject.contactPointTemp.contactPoint.separation; Vector3 contactPointNormal = itemObject.contactPointTemp.contactPoint.normal; contactPointNormal.Normalize(); separationVector = (contactPointNormal) * separation; itemObject.transform.position = new Vector3(itemObject.transform.position.x, itemObject.transform.position.y + Mathf.Abs(separationVector.y), itemObject.transform.position.z); } itemObject.PlaneY = itemObject.transform.position.y; //transform.rotation = initRotation; //if (!Hi5_Interaction_Const.TestPlanePhycis) // itemObject.transform.rotation = Quaternion.Euler(0.0f, transform.eulerAngles.y, 0.0f); //if (Hi5_Interaction_Const.TestChangeState) { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(itemObject.idObject, itemObject.mObjectType, EHandType.EHandLeft, EEventObjectType.EStatic); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } } if (collision.gameObject.layer == Hi5_Interaction_Const.OtherFingerTailLayer() /*|| collision.gameObject.layer == Hi5_Interaction_Const.ThumbTailLayer()*/) { if (collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Finger>()) { if (itemObject.mObjectType == EObject_Type.ECommon) { if (itemObject.state == E_Object_State.EStatic || itemObject.state == E_Object_State.EFlyLift) { if (!itemObject.IsPokeInLoop) { ContactPoint[] contactPoints = collision.contacts; if (contactPoints != null && contactPoints.Length > 0) { Vector3 normal = contactPoints [0].normal; float angle = Vector3.Angle(Hi5_Interaction_Object_Manager.GetObjectManager().transform.up, normal); if (Mathf.Abs(angle) > 25.0f) { itemObject.NotifyPokeEvent(collision); itemObject.IsPokeInLoop = true; } } } } { if (itemObject.mstatemanager.State == E_Object_State.EStatic || (itemObject.mstatemanager.State == E_Object_State.EMove && itemObject.mstatemanager.GetMoveState().mMoveType == Hi5ObjectMoveType.EPlaneMove)) { Hi5_Hand_Visible_Hand handTemp = collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Finger>().mHand; itemObject.ChangeState(E_Object_State.EMove); if (itemObject.mstatemanager != null) { itemObject.mstatemanager.SetPlaneMove(collision); } { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(itemObject.idObject, itemObject.mObjectType, handTemp.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight, EEventObjectType.EMove); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } } } } } } } }
override protected void OnTriggerExit(Collider other) { base.OnTriggerExit(other); if (Hi5_Interaction_Const.TestPinchOpenCollider) { if (other.gameObject.GetComponent <Hi5_Hand_Nail_Collider>() != null) { itemObject.ColliderNailNum--; if (itemObject.ColliderNailNum <= 0) { if (other.gameObject.GetComponent <Hi5_Hand_Nail_Collider>().mHand != null) { other.gameObject.GetComponent <Hi5_Hand_Nail_Collider>().mHand.RemoveNailColliderCount(); } //if (itemObject.state == E_Object_State.EMove // || itemObject.state == E_Object_State.EPoke // || itemObject.state == E_Object_State.EStatic) //{ // itemObject.SetIsKinematic(false); //} } } } if (itemObject.mObjectType == EObject_Type.EButton) { if (/*other.gameObject.layer == Hi5_Interaction_Const.ThumbTailLayer () ||*/other.gameObject.layer == Hi5_Interaction_Const.OtherFingerTailLayer()) { if (other.gameObject.GetComponent <Hi5_Glove_Collider_Finger> () != null && other.gameObject.GetComponent <Hi5_Glove_Collider_Finger> ().mFinger != null && other.gameObject.GetComponent <Hi5_Glove_Collider_Finger> ().mFinger.mHand != null) { if (itemObject.state == E_Object_State.EPoke) { //Debug.Log("EPoke"); itemObject.ChangeState(E_Object_State.EStatic); //if (Hi5_Interaction_Const.TestChangeState) { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(itemObject.idObject, itemObject.mObjectType, other.gameObject.GetComponent <Hi5_Glove_Collider_Finger> ().mFinger.mHand.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight, EEventObjectType.EStatic); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } } } } } else if (itemObject.mObjectType == EObject_Type.ECommon) { if (/*other.gameObject.layer == Hi5_Interaction_Const.ThumbTailLayer () ||*/other.gameObject.layer == Hi5_Interaction_Const.OtherFingerTailLayer()) { if (other.gameObject.GetComponent <Hi5_Glove_Collider_Finger> () != null && other.gameObject.GetComponent <Hi5_Glove_Collider_Finger> ().mFinger != null && other.gameObject.GetComponent <Hi5_Glove_Collider_Finger> ().mFinger.mHand != null) { itemObject.IsPokeInLoop = false; } } } }
override protected void OnCollisionStay(Collision collision) { base.OnCollisionStay(collision); if (itemObject.mObjectType == EObject_Type.ECommon) { if (/*collision.gameObject.layer == Hi5_Interaction_Const.ThumbTailLayer() || */collision.gameObject.layer == Hi5_Interaction_Const.OtherFingerTailLayer() /*|| collision.gameObject.layer == Hi5_Interaction_Const.PalmRigidbodyLayer()*/) { if (itemObject.mstatemanager == null) { return; } // if (collision.gameObject.GetComponent<Hi5_Hand_Collider_Visible_Finger>()) { //if (Hi5_Interaction_Const.TestChangeState) { if (itemObject.mstatemanager.State == E_Object_State.EStatic || (itemObject.mstatemanager.State == E_Object_State.EMove && itemObject.mstatemanager.GetMoveState().mMoveType == Hi5ObjectMoveType.EPlaneMove)) { if (/*collision.gameObject.layer == Hi5_Interaction_Const.ThumbTailLayer() ||*/ collision.gameObject.layer == Hi5_Interaction_Const.OtherFingerTailLayer()) { if (collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Thumb_Finger>() == null) { return; } Hi5_Hand_Visible_Finger finger = collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Thumb_Finger>().mFinger; if (finger && (finger is Hi5_Hand_Visible_Thumb_Finger)) { if (!(finger as Hi5_Hand_Visible_Thumb_Finger).IsMoveTowardHand()) { Hi5_Hand_Visible_Hand handTemp = collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Finger> ().mHand; itemObject.ChangeState(E_Object_State.EMove); if (itemObject.mstatemanager != null) { itemObject.mstatemanager.SetPlaneMove(collision); } { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(itemObject.idObject, itemObject.mObjectType, handTemp.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight, EEventObjectType.EMove); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } } } } else { } } } } } } }
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 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); }
override public void Update(float deltaTime) { //if (Hi5_Interaction_Const.TestChangeState1) { if (ObjectItem.transform.parent != Hi5_Interaction_Object_Manager.GetObjectManager().transform) { ///Debug.Log ("static palm parent"); ObjectItem.transform.parent = Hi5_Interaction_Object_Manager.GetObjectManager().transform; } } { if (ObjectItem.mObjectType == EObject_Type.ECommon) { int touchIdtemp; if (((!ObjectItem.IsTouchPlane()) && (!ObjectItem.IsTouchStaticObject(out touchIdtemp)))) { //静止转自由下落 if (!StartY) { StartY = true; Y = ObjectItem.transform.position.y; } else { if (StartY) { if (Mathf.Abs(Y - ObjectItem.transform.position.y) > 0.2f) { ObjectItem.ChangeState(E_Object_State.EMove); ObjectItem.mstatemanager.GetMoveState().SetFreeMove(null); { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(ObjectItem.idObject, ObjectItem.mObjectType, EHandType.ENone, EEventObjectType.EMove); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } return; } } } } //if (Hi5_Interaction_Const.TestPlanePhycis) { //Debug.Log ("static move "); //静止转平面移动 float distance = Vector3.Distance(staticPosition, ObjectItem.transform.position); if (distance > 0.008f && ObjectItem.IsTouchPlane()) { //ObjectItem.ChangeColor (Color.green); ObjectItem.ChangeState(E_Object_State.EMove); if (ObjectItem.mstatemanager != null) { ObjectItem.mstatemanager.SetPlaneMove(null); } { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(ObjectItem.idObject, ObjectItem.mObjectType, EHandType.EHandLeft, EEventObjectType.EMove); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } } } } } if (ObjectItem.mObjectType == EObject_Type.EButton) { //if (!Hi5_Interaction_Const.TestModifyConstraints) //{ // ObjectItem.SetIsKinematic(true); //} //if (!Hi5_Interaction_Const.TestModifyConstraints) // ObjectItem.SetIsLockYPosition(true); } int touchId; // Debug.Log("IsTouchStaticObject out"); //if (ObjectItem.IsTouchStaticObject(out touchId) && !ObjectItem.IsItemTouchPlane()) //{ // // Debug.Log("IsTouchStaticObject"); // if (touchId != -1000) // { // // Debug.Log("IsTouchStaticObject 1"); // Hi5_Glove_Interaction_Item itemTemp = Hi5_Interaction_Object_Manager.GetObjectManager().GetItemById(touchId); // if (itemTemp.state == E_Object_State.EFlyLift || itemTemp.state == E_Object_State.EPinch || itemTemp.state == E_Object_State.EStatic) // { // // Debug.Log("IsTouchStaticObject 2"); // //itemTemp.gameObject.GetComponent<Collider>().material = itemTemp.planePhysicMaterial; // if (itemTemp.itemColliders.Count>0) // { // /// Debug.Log("IsTouchStaticObject 3"); // foreach (Hi5_Interaction_Item_Collider itemCollider in itemTemp.itemColliders) // { // if (itemCollider.GetComponent<BoxCollider>() != null) // { // float angle1 = Vector3.Angle(Hi5_Interaction_Object_Manager.GetObjectManager().transform.up, -itemCollider.transform.up); // float angle2 = Vector3.Angle(Hi5_Interaction_Object_Manager.GetObjectManager().transform.up, itemCollider.transform.right); // float angle3 = Vector3.Angle(Hi5_Interaction_Object_Manager.GetObjectManager().transform.up, itemCollider.transform.forward); // //Debug.Log("angle" + angle1); // bool isFollow = false; // if (angle1 < Hi5_Interaction_Const.FlyLiftPalmAngle || (180.0f - angle1) < Hi5_Interaction_Const.FlyLiftPalmAngle) // { // isFollow = true; // } // else if (angle2 < Hi5_Interaction_Const.FlyLiftPalmAngle || (180.0f - angle2) < Hi5_Interaction_Const.FlyLiftPalmAngle) // { // isFollow = true; // } // else if (angle3 < Hi5_Interaction_Const.FlyLiftPalmAngle || (180.0f - angle3) < Hi5_Interaction_Const.FlyLiftPalmAngle) // { // isFollow = true; // } // if (isFollow /*&& ObjectItem.transform.parent != Hi5_Interaction_Object_Manager.GetObjectManager().transform.parent*/) // { // //ObjectItem.GetComponent<Rigidbody>().useGravity = false; // // ObjectItem.transform.parent = itemCollider.transform; // //ObjectItem.GetComponent<Rigidbody>().Sleep(); // } // } // } // } // } // ObjectItem.GetComponent<Rigidbody>().Sleep(); // } //} }
override public void Update(float deltaTime) { if (Hi5_Interaction_Const.TestChangeState1) { if (ObjectItem.transform.parent != Hi5_Interaction_Object_Manager.GetObjectManager().transform) { ///Debug.Log ("static palm parent"); ObjectItem.transform.parent = Hi5_Interaction_Object_Manager.GetObjectManager().transform; } } { if (ObjectItem.mObjectType == EObject_Type.ECommon) { if (((!ObjectItem.IsTouchPlane()) && (!ObjectItem.IsTouchStaticObject()))) { //Debug.Log ("Move From"); ObjectItem.SetIsKinematic(false); ObjectItem.SetUseGravity(true); ObjectItem.SetIsLockYPosition(false); if (Hi5_Interaction_Const.TestPlaneStatic) { if (!StartY) { StartY = true; Y = ObjectItem.transform.position.y; } else { if (StartY) { if (Mathf.Abs(Y - ObjectItem.transform.position.y) > 0.2f) { ObjectItem.mstatemanager.GetMoveState().SetFreeMove(null); ObjectItem.ChangeState(E_Object_State.EMove); { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(ObjectItem.idObject, ObjectItem.mObjectType, EHandType.ENone, EEventObjectType.EMove); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } } } } } else { ObjectItem.mstatemanager.GetMoveState().SetFreeMove(null); ObjectItem.ChangeState(E_Object_State.EMove); { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(ObjectItem.idObject, ObjectItem.mObjectType, EHandType.ENone, EEventObjectType.EMove); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } } } else { ObjectItem.SetIsKinematic(false); ObjectItem.SetIsLockYPosition(false); ObjectItem.SetUseGravity(true); } } else { ObjectItem.SetIsKinematic(true); ObjectItem.SetIsLockYPosition(true); ObjectItem.SetUseGravity(false); //ObjectItem.transform.position = new Vector3 (ObjectItem.transform.position.x,ObjectItem.Y,ObjectItem.transform.position.z); } } if (ObjectItem.mObjectType == EObject_Type.EButton) { ObjectItem.SetIsKinematic(true); ObjectItem.SetIsLockYPosition(true); } }
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); } } } } } } }
override protected void OnCollisionEnter(Collision collision) { UnityEngine.Profiling.Profiler.BeginSample("Hi5_Glove_Interaction_Item"); base.OnCollisionEnter(collision); if (mObjectType == EObject_Type.ECommon) { if ((collision.gameObject.layer == Hi5_Interaction_Const.PlaneLayer()) || ((collision.gameObject.layer == Hi5_Interaction_Const.ObjectGrasp() && collision.gameObject.GetComponent <Hi5_Glove_Interaction_Item>() != null && collision.gameObject.GetComponent <Hi5_Glove_Interaction_Item>().state == E_Object_State.EStatic))) { if (state == E_Object_State.EPinch) { return; } mstatemanager.StopThrowMove(); Vector3 separationVector = Vector3.zero; ContactPoint[] contactPoints = collision.contacts; if (contactPoints != null && contactPoints.Length > 0) { contactPointTemp = new ContactPointClass(); contactPointTemp.contactPoint = contactPoints [0]; float separation = contactPointTemp.contactPoint.separation; Vector3 contactPointNormal = contactPointTemp.contactPoint.normal; contactPointNormal.Normalize(); separationVector = (contactPointNormal) * separation; transform.position = new Vector3(transform.position.x, transform.position.y + Mathf.Abs(separationVector.y), transform.position.z); } PlaneY = transform.position.y; //transform.rotation = initRotation; transform.rotation = Quaternion.Euler(0.0f, transform.eulerAngles.y, 0.0f); if (Hi5_Interaction_Const.TestChangeState) { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(idObject, mObjectType, EHandType.EHandLeft, EEventObjectType.EStatic); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } } if (collision.gameObject.layer == Hi5_Interaction_Const.OtherFingerTailLayer() || collision.gameObject.layer == Hi5_Interaction_Const.ThumbTailLayer()) { //Debug.Log ("Hi5_Interaction_Const.OtherFingerTailLayer"); if (collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Finger>()) { //float dot = Vector3.Dot(collision.contacts[0].normal, collision.gameObject.transform.parent.right); //if (dot < 0.0f) if (mObjectType == EObject_Type.ECommon) { if (state == E_Object_State.EStatic || state == E_Object_State.EFlyLift) { if (!IsPokeInLoop) { ContactPoint[] contactPoints = collision.contacts; if (contactPoints != null && contactPoints.Length > 0) { Vector3 normal = contactPoints [0].normal; float angle = Vector3.Angle(Hi5_Interaction_Object_Manager.GetObjectManager().transform.up, normal); if (Mathf.Abs(angle) > 25.0f) { NotifyPokeEvent(collision); IsPokeInLoop = true; } } } } if (Hi5_Interaction_Const.TestChangeState) { if (mstatemanager.State == E_Object_State.EStatic || (mstatemanager.State == E_Object_State.EMove && mstatemanager.GetMoveState().mMoveType == Hi5ObjectMoveType.EPlaneMove)) { Hi5_Hand_Visible_Hand handTemp = collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Finger>().mHand; if (mstatemanager != null) { mstatemanager.SetPlaneMove(collision); } ChangeState(E_Object_State.EMove); { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(idObject, mObjectType, handTemp.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight, EEventObjectType.EMove); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } } } else { if (mstatemanager.State == E_Object_State.EStatic || mstatemanager.State == E_Object_State.EMove) { Hi5_Hand_Visible_Hand handTemp = collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Finger>().mHand; if (mstatemanager != null) { mstatemanager.SetPlaneMove(collision); } ChangeState(E_Object_State.EMove); { Hi5_Glove_Interaction_Object_Event_Data data = Hi5_Glove_Interaction_Object_Event_Data.Instance(idObject, mObjectType, handTemp.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight, EEventObjectType.EMove); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } } } } } } } UnityEngine.Profiling.Profiler.EndSample();; }