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();; }
override protected void Awake() { base.Awake(); mHand = transform.parent.parent.parent.GetComponent <Hi5_Hand_Visible_Hand>(); }