public void UpdateSmoothedMovementDirection()
    {
        m_IsJoyMoving = false;
        if (null == m_MainPlayer)
        {
            m_MainPlayer = Singleton <ObjManager> .GetInstance().MainPlayer;

            if (null != m_MainPlayer)
            {
                m_MainPlayerTransform = m_MainPlayer.transform;
            }
            else
            {
                return;
            }
        }
        if (null == m_CameraTransform)
        {
            m_CameraTransform = Camera.main.transform;
            if (null == m_CameraTransform)
            {
                return;
            }
        }

        m_bIsMoving = Mathf.Abs(m_fHorizonRaw) > 0.1 || Mathf.Abs(m_fVerticalRaw) > 0.1;

        //如果玩家正在点击移动,则判断是否有输入,如果没有则不进行更新,否则打断
        if (!m_bIsMoving && m_MainPlayer.IsMoving)
        {
            return;
        }

        if (false == m_MainPlayer.IsCanOperate_Move())
        {
            return;
        }

        // Forward vector relative to the camera along the x-z plane
        Vector3 forward = m_CameraTransform.TransformDirection(Vector3.forward);

        forward.y = 0;
        forward   = forward.normalized;

        // Right vector relative to the camera
        // Always orthogonal to the forward vector
        Vector3 right = new Vector3(forward.z, 0, -forward.x);

        // Target direction relative to the camera
        var targetDirection = m_fHorizonRaw * right + m_fVerticalRaw * forward;

        // We store speed and direction seperately,
        // so that when the character stands still we still have a valid forward direction
        // moveDirection is always normalized, and we only update it if there is user input.
        if (targetDirection != Vector3.zero)
        {
            // If we are really slow, just snap to the target direction
            if (m_fMoveSpeed < m_fWalkSpeed * 0.9)
            {
                m_vecMoveDirection = targetDirection.normalized;
            }
            // Otherwise smoothly turn towards it
            else
            {
                m_vecMoveDirection = Vector3.RotateTowards(m_vecMoveDirection, targetDirection, m_fRrotateSpeed * Mathf.Deg2Rad * Time.deltaTime, 1000);
                m_vecMoveDirection = m_vecMoveDirection.normalized;
            }
        }

        // Smooth the speed based on the current target direction
//		float curSmooth = m_fSpeedSmoothing * Time.deltaTime;
        // Choose target speed
        if (m_bIsMoving)
        {
            m_IsJoyMoving = true;

            m_fMoveSpeed = m_MainPlayer.m_fMoveSpeed;
            Vector3 movement = m_vecMoveDirection * m_fMoveSpeed;
            movement *= Time.deltaTime;

            //移动
            m_MainPlayer.BreakAutoCombatState();
            m_MainPlayer.LeaveTeamFollow();
            Vector3 newPos = m_MainPlayerTransform.localPosition + movement * 10;

            //如果发动摇杆移动操作,清除掉地面点击特效
            GameManager.gameManager.ActiveScene.DeactiveMovingCircle();

            //进行移动操作
            m_MainPlayer.MoveTo(newPos, null, 0.0f);

            // added by mawenbin
            // 挂机自动战斗时设置玩家主动移动
            AI_PlayerCombat aiPlayerCombat = m_MainPlayer.GetComponent <AI_PlayerCombat>();
            if (null != aiPlayerCombat &&
                m_MainPlayer.IsOpenAutoCombat &&
                m_MainPlayer.AutoComabat)
            {
                aiPlayerCombat.IsPlayerControlMove = true;
            }

            //设置模型方向
            if (m_MainPlayer.SkillCore == null || m_MainPlayer.SkillCore.IsUsingSkill == false) //   播放旋风斩动画时不转向
            {
                // 有自动寻路代理了,为什么还要自己设置转向? ,by lizhe
                if (m_MainPlayer.NavAgent == null)
                {
                    m_MainPlayerTransform.rotation = Quaternion.LookRotation(m_vecMoveDirection);
                }
            }
            m_MainPlayer.CurObjAnimState = Games.GlobeDefine.GameDefine_Globe.OBJ_ANIMSTATE.STATE_WALK;
        }
        else
        {
            m_fMoveSpeed = 0.0f;
            if (false == Cutscene.CutsceneActionPlayAnim.m_bIsPlayingMainPlayerAnim)
            {
                m_MainPlayer.CurObjAnimState = Games.GlobeDefine.GameDefine_Globe.OBJ_ANIMSTATE.STATE_NORMOR;
            }
        }
    }
Example #2
0
        public uint Execute(PacketDistributed ipacket)
        {
            GC_RET_USE_SKILL packet = (GC_RET_USE_SKILL)ipacket;

            if (null == packet)
            {
                return((uint)PACKET_EXE.PACKET_EXE_ERROR);
            }
            //enter your logic
            int nSkillId  = packet.HasFixedSkillId ? packet.FixedSkillId : packet.SkillId;
            int nSenderId = packet.SenderId;
            int nTargetID = packet.TargetId;

            Obj_Character Sender = Singleton <ObjManager> .GetInstance().FindObjCharacterInScene(nSenderId);

            if (Sender == null)
            {
                return((uint)PACKET_EXE.PACKET_EXE_CONTINUE);
            }
            if (Sender.SkillCore == null)
            {
                return((uint)PACKET_EXE.PACKET_EXE_CONTINUE);
            }
            int nFailType = (int)SKILLUSEFAILTYPE.INVALID;

            if (packet.HasSkillfailType)
            {
                nFailType = packet.SkillfailType;
            }
            string szSkillName = "";

            if (packet.HasSkillname)
            {
                szSkillName = packet.Skillname;
            }
            if (nFailType == (int)SKILLUSEFAILTYPE.DISTANCE)
            {
                if (Sender.ObjType == Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_MAIN_PLAYER)
                {
                    //服务器认定 距离不够 再往前走点
                    Obj_Character targetCharacter = Singleton <ObjManager> .GetInstance().FindObjCharacterInScene(nTargetID);

                    if (targetCharacter)
                    {
                        Tab_SkillEx _skillEx = TableManager.GetSkillExByID(nSkillId, 0);
                        if (_skillEx != null)
                        {
                            if (Sender.SkillCore.IsUsingSkill)
                            {
                                Sender.SkillCore.BreakCurSkill();
                            }
                            Singleton <ObjManager> .GetInstance().MainPlayer.CurUseSkillId = nSkillId;

                            Singleton <ObjManager> .GetInstance().MainPlayer.MoveTo(targetCharacter.Position, targetCharacter.gameObject, _skillEx.Radius - 2.0f);
                        }
                    }
                }
            }
            else
            {
                //结婚相关特殊表现
                if (nSkillId == GlobeVar.MARRY_SKILL_2)
                {
                    Sender.SkillCore.BreakCurSkill();
                    Sender.FaceTo(new UnityEngine.Vector3(13.79419f, 0.9015087f, 30.36249f));
                }
                //结婚相关特殊表现
                if (nSkillId == GlobeVar.MARRY_SKILL_1)
                {
                    Sender.SkillCore.BreakCurSkill();
                    Sender.FaceTo(new UnityEngine.Vector3(13.79419f, 0.9015087f, 4.068859f));
                }
                if (szSkillName != "")
                {
                    Sender.SkillCore.UseSkill(nSkillId, nSenderId, nTargetID, szSkillName);
                }
                else
                {
                    Sender.SkillCore.UseSkill(nSkillId, nSenderId, nTargetID);
                }

                Tab_SkillEx _skillEx = TableManager.GetSkillExByID(nSkillId, 0);
            }

            if (Sender is Obj_MainPlayer)
            {
                //if the main player in the state of changing mode

                int nImpactCount = GameManager.gameManager.PlayerDataPool.ClientImpactInfo.Count;

                Obj_MainPlayer _mainPlayer = Singleton <ObjManager> .Instance.MainPlayer;
                Tab_SkillEx    _skillEx    = TableManager.GetSkillExByID(nSkillId, 0);

                Tab_SkillBase _skillBase = null;

                int nSkillIndex  = -1;
                int nChangeState = -1;
                if (null != _mainPlayer)
                {
                    for (int i = 0; i < _mainPlayer.OwnSkillInfo.Length; i++)
                    {
                        if (_mainPlayer.OwnSkillInfo[i].SkillId == nSkillId)
                        {
                            nSkillIndex = i;
                            break;
                        }
                    }

                    nChangeState = _mainPlayer.GetCurrentChangeState();

                    // added by mawenbin
                    // 缓存玩家使用的技能,用于挂机连续技的判定
                    AI_PlayerCombat aiPlayerCombat = _mainPlayer.GetComponent <AI_PlayerCombat>();
                    if (null != aiPlayerCombat && Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_MAIN_PLAYER == Sender.ObjType)
                    {
                        aiPlayerCombat.CurUseSkillId = nSkillId;
                    }
                }

                if (null != _skillEx)
                {
                    _skillBase = TableManager.GetSkillBaseByID(_skillEx.BaseId, 0);
                }

                if (null != _skillBase)
                {
                    if (null != SkillBarLogic.Instance())
                    {
                        //if the skill is xp skill and can put into skillbar
                        if ((_skillBase.SkillClass & (int)SKILLCLASS.AUTOREPEAT) == 0 &&
                            (_skillBase.SkillClass & (int)SKILLCLASS.XP) == 0 &&
                            (_skillBase.GetChangeModebyIndex(_mainPlayer.CurChangeState) > 0) &&
                            (_skillBase.SkillClass & (int)SKILLCLASS.PASSIVITY) == 0)
                        {
                            for (int i = 0; i < SkillBarLogic.Instance().MySkillBarInfo.Length; i++)
                            {
                                if (nSkillId == SkillBarLogic.Instance().MySkillBarInfo[i].CurSkillId)
                                {
                                    SkillBarLogic.Instance().MySkillBarInfo[i].nPreSkillId           = nSkillId;
                                    SkillBarLogic.Instance().MySkillBarInfo[i].fCurrentStartTime     = Time.realtimeSinceStartup;
                                    SkillBarLogic.Instance().MySkillBarInfo[i].fCurDisabledStartTime = Time.realtimeSinceStartup;
                                    SkillBarLogic.Instance().MySkillBarInfo[i].nCurrentCDTime        = _skillEx.NextSkillEffectTime / 1000.0f;
                                    SkillBarLogic.Instance().MySkillBarInfo[i].fRemainCDTime         = _skillEx.NextSkillEffectTime / 1000.0f;
                                    SkillBarLogic.Instance().MySkillBarInfo[i].fDisabledRemTime      = _skillEx.NextSkillDisabledTime / 1000.0f;
                                    SkillBarLogic.Instance().MySkillBarInfo[i].fCurDisabedTime       = _skillEx.NextSkillDisabledTime / 1000.0f;
                                    SkillBarLogic.Instance().MySkillBarInfo[i].SkillCount++;
                                    if (false == GameManager.gameManager.PlayerDataPool.CommonData.GetCommondFlag((int)USER_COMMONFLAG.CF_COMBO_FIRSTUSED))
                                    {
                                        if (nSkillId == GlobeVar.SHUANGJIANSHI_SKILL1_COMBO1 || nSkillId == GlobeVar.SHUANGJIANSHI_SKILL1_COMBO2)
                                        {
                                            SkillBarLogic.Instance().MySkillBarInfo[i].nCurrentCDTime = 10;
                                            SkillBarLogic.Instance().MySkillBarInfo[i].fRemainCDTime  = 10;
                                        }
                                    }
                                    SkillBarLogic.Instance().SetSkillBarInfoForNext(i, _skillEx.NextContinueSkillId);

                                    //第一个连续技能来了,要有提示
                                    if (nSkillIndex != -1 && nSkillIndex == SkillBarLogic.Instance().MySkillBarInfo[i].SkillIndex)
                                    {
                                        if (null != ComboSkillTipLogic.Instance())
                                        {
                                            System.Collections.Generic.List <string> iconList = SkillBarLogic.Instance().GetContinueSkillIcons(_skillBase);
                                            ComboSkillTipLogic.Instance().Show(i, iconList.Count, iconList);
                                        }
                                    }

                                    if (null != ComboSkillTipLogic.Instance())
                                    {
                                        ComboSkillTipLogic.Instance().SetStep(i, SkillBarLogic.Instance().MySkillBarInfo[i].SkillCount);
                                    }
                                    if (_skillBase.NextIndex == _skillBase.FirstIndex)
                                    {
                                        SkillBarLogic.Instance().MySkillBarInfo[i].isCompleted = true;
                                        SkillBarLogic.Instance().MySkillBarInfo[i].SkillCount  = 0;
                                    }


                                    break;
                                }
                            }
                        }
                    }

                    //if it is xpSkill and attackSkill
                    if (((_skillBase.SkillClass & (int)SKILLCLASS.AUTOREPEAT) != 0) &&
                        _skillBase.GetChangeModebyIndex(_mainPlayer.CurChangeState) >= 0 &&
                        SkillBarLogic.Instance()._AttackBarInfo != null)
                    {
                        SkillBarLogic.Instance()._AttackBarInfo.fCurrentStartTime = Time.realtimeSinceStartup;
                        SkillBarLogic.Instance()._AttackBarInfo.fCurDisabledStartTime = Time.realtimeSinceStartup;
                        SkillBarLogic.Instance()._AttackBarInfo.nCurrentCDTime = _skillEx.NextSkillEffectTime;
                        SkillBarLogic.Instance()._AttackBarInfo.fRemainCDTime = _skillEx.NextSkillEffectTime;
                        SkillBarLogic.Instance()._AttackBarInfo.fDisabledRemTime = _skillEx.NextSkillDisabledTime;
                        SkillBarLogic.Instance()._AttackBarInfo.fCurDisabledTime = _skillEx.NextSkillDisabledTime;
                        SkillBarLogic.Instance()._AttackBarInfo.nCurSkillId = _skillEx.NextContinueSkillId;
                    }
                }
            }


            return((uint)PACKET_EXE.PACKET_EXE_CONTINUE);
        }