override protected void OnTriggerEnter(Collider other) { base.OnTriggerEnter(other); if (mObjectType == EObject_Type.EButton || mObjectType == EObject_Type.ECommon) { if (other.gameObject.layer == Hi5_Interaction_Const.ThumbTailLayer() || other.gameObject.layer == Hi5_Interaction_Const.OtherFingerTailLayer()) { //Debug.Log ("item OnTriggerEnter Tail"); 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 (mObjectType == EObject_Type.EButton) { if (state == E_Object_State.EStatic) { this.ChangeState(E_Object_State.EPoke); NotifyPokeEvent(other); } } else { if (state == E_Object_State.EStatic || state == E_Object_State.EFlyLift) { } } } //ChangeColor(Color.black); } } }
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; } } } }
override protected void OnCollisionStay(Collision collision) { base.OnCollisionStay(collision); if (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 (mstatemanager == null) { return; } // if (collision.gameObject.GetComponent<Hi5_Hand_Collider_Visible_Finger>()) { if (Hi5_Interaction_Const.TestChangeState) { if (mstatemanager.State == E_Object_State.EStatic || (mstatemanager.State == E_Object_State.EMove && 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()) { if (mstatemanager != null) { mstatemanager.SetPlaneMove(collision); } Hi5_Hand_Visible_Hand handTemp = collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Finger> ().mHand; 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 (collision.gameObject.layer == Hi5_Interaction_Const.PalmRigidbodyLayer()) { 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, collision.gameObject.GetComponent <Hi5_Hand_Palm_Move>().mHand.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight, EEventObjectType.EMove); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } // Debug.Log("collision.gameObject.layer == Hi5_Interaction_Const.PalmRigibodyLayer"); } } } } else { if (mstatemanager.State == E_Object_State.EStatic || mstatemanager.State == E_Object_State.EMove) { 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()) { if (mstatemanager != null) { mstatemanager.SetPlaneMove(collision); } Hi5_Hand_Visible_Hand handTemp = collision.gameObject.GetComponent <Hi5_Hand_Collider_Visible_Finger> ().mHand; 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 (collision.gameObject.layer == Hi5_Interaction_Const.PalmRigidbodyLayer()) { 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, collision.gameObject.GetComponent <Hi5_Hand_Palm_Move>().mHand.m_IsLeftHand ? EHandType.EHandLeft : EHandType.EHandRight, EEventObjectType.EMove); Hi5InteractionManager.Instance.GetMessage().DispenseMessage(Hi5_Glove_Interaction_Message.Hi5_MessageMessageKey.messageObjectEvent, (object)data, null); } // Debug.Log("collision.gameObject.layer == Hi5_Interaction_Const.PalmRigibodyLayer"); } } } } } //if(collision.gameObject.GetComponent<Hi5_Hand_Collider_Visible_Finger>()) } } }
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();; }