示例#1
0
        private void UpdateInput()
        {
            if (maskGraphicTrigger && DeviceInput.UF_Press(0))
            {
                if (uiCamera == null)
                {
                    return;
                }
                //停止复位
                m_IsResumePoint = false;

                if (!m_IsPress)
                {
                    m_SourceDragPos = DeviceInput.UF_DownPosition(0);
                    joyRoot.gameObject.transform.position = uiCamera.ScreenToWorldPoint(m_SourceDragPos);
                    m_IsPress = true;
                    UF_CallDelegateEvent(m_EventJoyPressDown);
                    UF_CallUnityEvent(m_UEventPressDown);
                }
                if (m_IsPress)
                {
                    m_TargetDragPos = DeviceInput.UF_PressPosition(0);
                    float dist   = Vector3.Distance(m_SourceDragPos, m_TargetDragPos);
                    float limitV = limtPointDistance * Screen.width / UIManager.FixedWidth;

                    if (dist > limitV)
                    {
                        m_TargetDragPos = m_SourceDragPos + (m_TargetDragPos - m_SourceDragPos).normalized * limitV;
                    }
                    if (joyPoint != null)
                    {
                        joyPoint.gameObject.transform.position = uiCamera.ScreenToWorldPoint(m_TargetDragPos);
                    }
//					float angle = 0;
                    Vector3 _moveVector = MathX.UF_Foward(m_SourceDragPos, m_TargetDragPos);
                    if (dist > deadZoom)
                    {
                        m_MoveForward = new Vector3(_moveVector.x, gravity, _moveVector.y).normalized;
                        UF_CallDelegateEvent(m_EventJoyPressMove);
                        UF_UpdateRotate(m_MoveForward);
                    }
                }
            }
            else
            {
                if (m_IsPress)
                {
                    m_IsPress = false;
                    UF_ResumePoint(); UF_UpdateRevertRoot();
                    UF_CallDelegateEvent(m_EventJoyPressUp);
                    UF_CallUnityEvent(m_UEventPressUp);
                }
            }
        }
示例#2
0
        //碰撞
        internal void UF_OnCollisionHit(ControllerColliderHit hit)
        {
            if (!activeTriggerCollision)
            {
                return;
            }

            GameObject hitTarget = hit.gameObject;

            if (hitTarget.tag == DefineTag.Ground)
            {
                return;
            }

            if (!UF_CheckCollisionIntervalTime())
            {
                return;
            }

            //忽略指定层碰撞
            if (hitTarget.tag == DefineTag.Block || hitTarget.tag == DefineTag.Unwalk)
            {
                //碰撞不可走区域
                MessageSystem.UF_GetInstance().UF_Send(DefineEvent.E_AVATAR_BLOCK, m_Avatar, hitTarget, hit.point);
                return;
            }

            //只处理角色间碰撞
            if (m_Avatar.tag != hitTarget.tag)
            {
                //if (!CheckCollisionIntervalTime()) return;
                if (GHelper.UF_CheckStringMask(collisionMask, hitTarget.tag))
                {
                    //推开角色
                    if (hit.collider is CharacterController)
                    {
                        var     targetController = hit.collider as CharacterController;
                        Vector3 pushForward      = MathX.UF_Foward(m_Avatar.position, hit.transform.position);
                        pushForward.y = 0;
                        //Vector3 pushForward = hit.moveDirection;
                        targetController.Move(pushFactor * pushForward.normalized * GTime.RunDeltaTime);
                    }

                    MessageSystem.UF_GetInstance().UF_Send(DefineEvent.E_AVATAR_COLLISION, m_Avatar, hitTarget);
                }
            }
        }