Beispiel #1
0
        //#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);
                        }
                    }
                }
            }
        }
        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);
                }
            }
        }
Beispiel #3
0
        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 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();;
        }