Example #1
0
    void Update()
    {
        if (_targetTrans)
        {
            _tempZ = PeInput.GetAxisH();
            _tempX = PeInput.GetAxisV();

            if (Mathf.Abs(_tempX) > float.Epsilon)
            {
                _offsetRotate.x = (_tempX * Time.deltaTime) * TameMonsterConfig.instance.CtrlRotateSpeed;
            }
            else
            {
                _offsetRotate.x = 0f;
            }

            if (Mathf.Abs(_tempZ) > float.Epsilon)
            {
                _offsetRotate.z = -(_tempZ * Time.deltaTime) * TameMonsterConfig.instance.CtrlRotateSpeed;
            }
            else
            {
                _offsetRotate.z = 0f;
            }

            _offsetRotate.y = 0f;
        }
    }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        void UpdateMoveState()
        {
            if (ctrlType != ECtrlType.Mount || Entity.skEntity.IsSkillRunning())
            {
                return;
            }

            if (m_Move == null)
            {
                return;
            }

            //if(PeInput.Get(PeInput.LogicFunction.InteractWithItem) && null != SelectItem_N.Instance && SelectItem_N.Instance.HaveOpItem())

            //计算移动方向
            Vector3 moveDirLocal = PeInput.GetAxisH() * Vector3.right + PeInput.GetAxisV() * Vector3.forward;

            m_MoveDir = Vector3.ProjectOnPlane(PETools.PEUtil.MainCamTransform.rotation * moveDirLocal, Vector3.up);

            //计算行走速度
            if (PeInput.Get(PeInput.LogicFunction.SwitchWalkRun))
            {
                m_MoveWalk = !m_MoveWalk;
            }
            SpeedState state = m_MoveWalk ? SpeedState.Walk : SpeedState.Run;

            if (PeInput.Get(PeInput.LogicFunction.Sprint) && Entity.GetAttribute(AttribType.SprintSpeed) > 0)
            {
                state = SpeedState.Sprint;
            }

            //移动
            m_Move.Move(m_MoveDir.normalized, state);


            //跳跃
            if ((m_SkillData.canSpace() || m_SkillData.canProunce()) && PeInput.Get(PeInput.LogicFunction.Jump))
            {
                Jump();
            }

            //左键攻击
            if (m_SkillData.canAttack() && PeInput.Get(PeInput.LogicFunction.Attack))
            {
                AttackL();
            }
            //右键攻击:还需要定义右键攻击逻辑键
            //if (PeInput.Get(PeInput.LogicFunction.Item_Use))
            //    AttackR();
        }
Example #3
0
        void UpdateMoveState()
        {
            if (PeCamera.isFreeLook || (!PeGameMgr.IsMulti && PeGameMgr.gamePause))
            {
                mMove.Move(Vector3.zero);
                return;
            }

            m_MoveDir = Vector3.zero;

            Vector3 moveDirLocal = Vector3.zero;

            moveDirLocal = PeInput.GetAxisH() * Vector3.right + PeInput.GetAxisV() * Vector3.forward;

            if (m_AutoRun && moveDirLocal == Vector3.zero && (!UIStateMgr.Instance.isTalking || GameUI.Instance.mNPCTalk.type != UINPCTalk.NormalOrSp.Normal))
            {
                moveDirLocal += Vector3.forward;
            }

            if (PeInput.Get(PeInput.LogicFunction.SwitchWalkRun) &&
                !Entity.passengerCmpt.IsOnCarrier())
            {
                m_MoveWalk = !m_MoveWalk;
            }

            float inputDirLength = moveDirLocal.magnitude;
            bool  stickWalk      = inputDirLength > 0.1f && inputDirLength < 0.9f;

            if (PeInput.Get(PeInput.LogicFunction.AutoRunOnOff))
            {
                m_AutoRun = !m_AutoRun;
            }

            if (PeInput.GetAxisV() < -0.5f || Entity.passengerCmpt.IsOnCarrier())
            {
                m_AutoRun = false;
            }

            Vector3 dodgeDir = Vector3.zero;

            if (PeInput.Get(PeInput.LogicFunction.DodgeForward))
            {
                dodgeDir += Vector3.forward;
            }
            if (PeInput.Get(PeInput.LogicFunction.DodgeRight))
            {
                dodgeDir += Vector3.right;
            }
            if (PeInput.Get(PeInput.LogicFunction.DodgeBackward))
            {
                dodgeDir += Vector3.back;
            }
            if (PeInput.Get(PeInput.LogicFunction.DodgeLeft))
            {
                dodgeDir += Vector3.left;
            }

            if (!PeInput.Get(PeInput.LogicFunction.LiberatiePerspective))
            {
                _cameraRotation = PETools.PEUtil.MainCamTransform.rotation;
            }

            //			if(PeInput.Get(PeInput.LogicFunction.SwimUp)) dodgeDir += Vector3.up;
            if (dodgeDir != Vector3.zero && (PeGameMgr.IsMulti || !PeGameMgr.gamePause))
            {
                dodgeDir = Vector3.ProjectOnPlane(_cameraRotation * dodgeDir, Vector3.up).normalized;
                mMove.Dodge(dodgeDir);
            }

            if (mMove.state == MovementState.Water)
            {
                m_MoveDir = _cameraRotation * moveDirLocal;
            }
            else
            {
                m_MoveDir = Vector3.ProjectOnPlane(_cameraRotation * moveDirLocal, Vector3.up);
            }

            if (null != m_PhyCtrl && m_PhyCtrl.spineInWater)
            {
                if (!m_PhyCtrl.headInWater)
                {
                    if (m_MoveDir.y < 0 && m_MoveDir.y > m_DiveMinY)
                    {
                        m_MoveDir.y = 0;
                    }
                    if (PeInput.Get(PeInput.LogicFunction.Jump) &&
                        !mView.IsRagdoll &&
                        !mMotionMgr.IsActionRunning(PEActionType.Dig) &&
                        !mMotionMgr.IsActionRunning(PEActionType.Gather))
                    {
                        m_PhyCtrl.ApplyImpact(Mathf.Sqrt(20f * waterJumpHeight) * Vector3.up);
                    }
                }
                if (PeInput.Get(PeInput.LogicFunction.SwimUp) &&
                    !mView.IsRagdoll &&
                    !mMotionMgr.IsActionRunning(PEActionType.Dig) &&
                    !mMotionMgr.IsActionRunning(PEActionType.Gather))
                {
                    m_PhyCtrl.ApplyMoveRequest(waterUpSpeed * Vector3.up);
                }
            }

            if (!m_MouseMoveMode)
            {
                if (mMove.autoRotate)
                {
                    if (m_MoveRequest.Count == MoveRequestCount)
                    {
                        m_MoveRequest.RemoveAt(0);
                    }
                    for (int i = 0; i < m_MoveRequest.Count; i++)
                    {
                        if (Vector3.Angle(m_MoveRequest[i], moveDirLocal) > 150f)
                        {
                            PEActionParamVBB param = PEActionParamVBB.param;
                            param.vec = m_MoveDir.normalized;
                            param.b1  = true;
                            param.b2  = false;
                            if (mMotionMgr.DoAction(PEActionType.Rotate, param))
                            {
                                m_MoveRequest.Clear();
                            }
                            break;
                        }
                    }
                    m_MoveRequest.Add(moveDirLocal);
                }
                if (mMotionMgr.IsActionRunning(PEActionType.Hand))
                {
                    if (null == m_Hand)
                    {
                        m_Hand = mMotionMgr.GetAction <Action_Hand>();
                    }
                    if (m_Hand.moveable)
                    {
                        mMove.Move(m_MoveDir.normalized, SpeedState.Walk);
                    }
                }
                else
                {
                    SpeedState state = SpeedState.Run;
                    if (PeInput.Get(PeInput.LogicFunction.Sprint))
                    {
                        state = SpeedState.Sprint;
                    }
                    else if (m_MoveWalk || stickWalk)
                    {
                        state = SpeedState.Walk;
                    }
                    mMove.Move(m_MoveDir.normalized, state);
                }
                mMove.UpdateMoveDir(m_MoveDir, moveDirLocal);
            }

            mEquip.UpdateMoveDir(m_MoveDir, moveDirLocal);

            if (PeInput.Get(PeInput.LogicFunction.Jump))
            {
                mMove.Jump();
            }
        }