少年修仙传客户端代码仓库
client_Hale
2018-09-12 0d9fc090f841516f7685aebd1bee8cf25df2160b
3434 前端战斗AI逻辑修改: 去掉2次记录的输入技能
7个文件已修改
323 ■■■■ 已修改文件
Fight/Actor/AI/HeroAIHandler.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/Actor/AI/HeroAI_Auto.cs 233 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/Actor/AI/HeroAI_Base.cs 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/Actor/AI/HeroAI_KillUntilDie.cs 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/Actor/HeroBehaviour.cs 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/Actor/UserInputHandler.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/PreFightMission.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/Actor/AI/HeroAIHandler.cs
@@ -88,6 +88,7 @@
            // 已经执行完毕, 退出状态
            m_Current.Exit();
            m_Current = null;
            currentType = E_HeroAIType.None;
        }
        // 遍历所有状态, 决定此次进入哪个状态
Fight/Actor/AI/HeroAI_Auto.cs
@@ -51,7 +51,7 @@
        m_LastUseSkillTime = 0;
        m_PauseStartTime = 0;
        m_LockTargetSID = 0;
        m_UserClickSkillID = 0;
        m_UserClickSkillID = -1;
        m_NeedMoveToPos = false;
        m_HandUpSkill = null;
        m_State = 0;
@@ -216,11 +216,9 @@
                    }
                }
                // 决策此次要使用的技能
                _skill = DecideUserSkill(m_HandUpSkill);
                break;
            case 1:// 暂停状态
                if (m_NeedMoveToPos)
                {
                    if (StatusMgr.Instance.CanMove(PlayerDatas.Instance.PlayerId))
@@ -234,28 +232,9 @@
                    m_NeedMoveToPos = false;
                }
                if (m_UserClickSkillID == 0)
                if (Time.realtimeSinceStartup - m_PauseStartTime > m_PauseResumeTime)
                {
                    int _index = _hero.nextComAtkIndex;
                    if (_index == -1)
                    {
                        _index = 0;
                    }
                    m_UserClickSkillID = _hero.GetCommonSkillID(_index);
                }
                if (m_UserClickSkillID != -1 && CanCastActiveUse(m_UserClickSkillID))
                {
                    // 决策此次要使用的技能
                    m_DecideSkill = _hero.SkillMgr.Get(m_UserClickSkillID);
                    m_UserClickSkillID = -1;
                }
                else
                {
                    if (Time.realtimeSinceStartup - m_PauseStartTime > m_PauseResumeTime)
                    {
                        m_State = 0;
                    }
                    m_State = 0;
                }
                break;
@@ -267,9 +246,20 @@
            return;
        }
        if (m_DecideSkill != null)
        if (m_UserClickSkillID == 0)
        {
            _skill = m_DecideSkill;
            int _index = _hero.nextComAtkIndex;
            if (_index == -1)
            {
                _index = 0;
            }
            m_UserClickSkillID = _hero.GetCommonSkillID(_index);
        }
        if (m_State == 0 || m_UserClickSkillID != -1)
        {
            // 决策此次要使用的技能
            _skill = DecideUserSkill(m_HandUpSkill, m_UserClickSkillID);
        }
        if (_skill == null)
@@ -277,110 +267,114 @@
            return;
        }
        bool _forceMove = _skill.skillInfo.soFile != null && _skill.skillInfo.soFile.forceMove;
        // 判断周围是否有可攻击目标
        GActorFight _atkTarget = null;
        if (!_forceMove && !IsSkillNeedMove(_skill.skillInfo.config.Tag, (E_SkillType)_skill.skillInfo.config.SkillType))
        // 处理玩家主动切换攻击目标行为
        if (m_LockTargetSID != 0)
        {
            _hero.Behaviour.DoAttack(_skill);
            m_DecideSkill = null;
            _atkTarget = GAMgr.Instance.GetBySID(m_LockTargetSID) as GActorFight;
            if (_atkTarget == null
            || !_atkTarget.CanAtked())
            {
                m_LockTargetSID = 0;
                _atkTarget = null;
            }
        }
        else if (_hero.aiHandler.PriorityNpcID > 0)
        {
            _atkTarget = DecideAttackTarget(_hero.Pos, m_HandupRange, _hero.aiHandler.PriorityNpcID);
        }
        else if (m_LockTargetNpcID > 0)
        {
            _atkTarget = DecideAttackTarget(_hero.Pos, m_HandupRange, m_LockTargetNpcID);
        }
        else
        {
            // 判断周围是否有可攻击目标
            GActorFight _atkTarget = null;
            _atkTarget = SelectTarget();
        }
            // 处理玩家主动切换攻击目标行为
            if (m_LockTargetSID != 0)
            {
                _atkTarget = GAMgr.Instance.GetBySID(m_LockTargetSID) as GActorFight;
        bool _forceMove = _skill.skillInfo.soFile != null && _skill.skillInfo.soFile.forceMove;
        if (_atkTarget == null
         || _atkTarget.ActorInfo.serverDie
         || (!_forceMove && !IsSkillNeedMove(_skill.skillInfo.config.Tag, (E_SkillType)_skill.skillInfo.config.SkillType)))
        {
            _hero.Behaviour.DoAttack(_skill);
            m_DecideSkill = null;
            return;
        }
                if (_atkTarget == null
                || !_atkTarget.CanAtked())
                {
                    m_LockTargetSID = 0;
                    _atkTarget = null;
                }
            }
            else if (_hero.aiHandler.PriorityNpcID > 0)
            {
                _atkTarget = DecideAttackTarget(_hero.Pos, m_HandupRange, _hero.aiHandler.PriorityNpcID);
            }
            else if (m_LockTargetNpcID > 0)
            {
                _atkTarget = DecideAttackTarget(_hero.Pos, m_HandupRange, m_LockTargetNpcID);
            }
            else
            {
                _atkTarget = SelectTarget();
            }
            if (_atkTarget == null)
            {
                _hero.StopRush();
                return;
            }
            _hero.LockTarget = _hero.SelectTarget = _atkTarget;
            // 判断技能范围, 不在可释放范围需要移动至目标
            float _compareDist = _skill.skillInfo.config.AtkDist * .5f;
            float _compareDistSqrt = _compareDist * _compareDist;
            // 计算当前和目标的距离
            float _currentDistSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, _atkTarget.Pos);
            // 比较距离
            if (_currentDistSqrt > _compareDistSqrt)
            {
                if ((StatusMgr.IsValid()
                && !StatusMgr.Instance.CanMove(_hero.ServerInstID)))
                {
                    return;
                }
                // 移动至目标
                _hero.MoveToTarget(_atkTarget, _compareDist);
                // 判断是否需要冲锋
                if (_hero.IsNeedRush(_currentDistSqrt))
                {
                    _hero.StartRush();
                }
                return;
            }
            // 停止冲锋逻辑
        if (_atkTarget == null)
        {
            _hero.StopRush();
            return;
        }
        _hero.LockTarget = _hero.SelectTarget = _atkTarget;
        // 判断技能范围, 不在可释放范围需要移动至目标
        float _compareDist = _skill.skillInfo.config.AtkDist * .5f;
        float _compareDistSqrt = _compareDist * _compareDist;
        // 计算当前和目标的距离
        float _currentDistSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, _atkTarget.Pos);
        // 比较距离
        if (_currentDistSqrt > _compareDistSqrt)
        {
            if ((StatusMgr.IsValid()
            && !StatusMgr.Instance.CanMove(_hero.ServerInstID)))
            {
                return;
            }
            // 移动至目标
            _hero.MoveToTarget(_atkTarget, _compareDist);
            // 判断是否需要冲锋
            if (_hero.IsNeedRush(_currentDistSqrt))
            {
                _hero.StartRush();
            }
            return;
        }
        // 停止冲锋逻辑
        _hero.StopRush();
        if (IsSkillNeedMove(_skill.skillInfo.config.Tag, (E_SkillType)_skill.skillInfo.config.SkillType))
        {
            Vector3 _forward = MathUtility.ForwardXZ(_atkTarget.Pos, _hero.Pos);
            _hero.destForward = _hero.Forward = _forward;
        }
            // 判断是否普通, 调用不同的接口
            if (_hero.Behaviour.IsComAtk(_skill.id))
        // 判断是否普通, 调用不同的接口
        if (_hero.Behaviour.IsComAtk(_skill.id))
        {
            _hero.Behaviour.DoCommonAttack();
            if (m_DecideSkill != null && m_DecideSkill.id == _skill.id)
            {
                _hero.Behaviour.DoCommonAttack();
                if (m_DecideSkill != null && m_DecideSkill.id == _skill.id)
                {
                    m_DecideSkill = null;
                }
                if (_skill.id == m_UserClickSkillID)
                {
                    m_UserClickSkillID = -1;
                }
                m_DecideSkill = null;
            }
            else
            if (_skill.id == m_UserClickSkillID)
            {
                _hero.Behaviour.DoAttack(_skill);
                if (m_DecideSkill != null && m_DecideSkill.id == _skill.id)
                {
                    m_DecideSkill = null;
                }
                if (_skill.id == m_UserClickSkillID)
                {
                    m_UserClickSkillID = -1;
                }
                m_UserClickSkillID = -1;
            }
        }
        else
        {
            _hero.Behaviour.DoAttack(_skill);
            if (m_DecideSkill != null && m_DecideSkill.id == _skill.id)
            {
                m_DecideSkill = null;
            }
            if (_skill.id == m_UserClickSkillID)
            {
                m_UserClickSkillID = -1;
            }
        }
        m_LastUseSkillTime = Time.realtimeSinceStartup;
    }
@@ -424,6 +418,15 @@
        {
            _hero.StopRush();
        }
        Skill _skill = _hero.SkillMgr.CurCastSkill;
        if (_skill != null)
        {
            if (!_skill.SkillCompelete)
            {
                m_UserClickSkillID = -1;
            }
        }
    }
    private Vector3 m_TargetPos;
@@ -460,8 +463,6 @@
        //    SysNotifyMgr.Instance.ShowTip("HookPrompt_Manual");
        //}
        m_NeedMoveToPos = false;
        m_PauseStartTime = Time.realtimeSinceStartup;
        m_State = 1;
    }
    private void OnLockTargetChanged(uint sid)
Fight/Actor/AI/HeroAI_Base.cs
@@ -22,7 +22,7 @@
    protected int xpSkillID = 0;
    protected Skill DecideUserSkill(int[] skillList = null)
    protected Skill DecideUserSkill(int[] skillList = null, int priorSkillId = -1)
    {
        GA_Hero _hero = PlayerDatas.Instance.hero;
        if (_hero == null || !_hero.CanCastSkill())
@@ -32,6 +32,18 @@
        Skill _skill = null;
        if (priorSkillId >= 0)
        {
            if (CanCast(priorSkillId))
            {
                _skill = _hero.SkillMgr.Get(priorSkillId);
                if (_skill != null)
                {
                    return _skill;
                }
            }
        }
        // 判断是否需要使用加血技能
        float _curHpPer = PlayerDatas.Instance.baseData.HP * 1f / PlayerDatas.Instance.extersion.MaxHP;
        if (_curHpPer < _hero.JobSetup.HpPerUseSkill * Constants.F_DELTA)
Fight/Actor/AI/HeroAI_KillUntilDie.cs
@@ -85,7 +85,11 @@
    private void OnUserClickSkill(int skillID)
    {
        m_FirstSkill = skillID;
        GActor _target = GAMgr.Instance.GetBySID(m_TargetID);
        if (_target != null && !_target.ActorInfo.serverDie)
        {
            m_FirstSkill = skillID;
        }
    }
    public override void Update()
@@ -278,25 +282,30 @@
        GA_Hero _hero = PlayerDatas.Instance.hero;
        GActorFight _target = GAMgr.Instance.GetBySID(m_TargetID) as GActorFight;
        //if (_target == null || !_target.CanAtked())
        //{
        //    Debug.Log("目标已死亡或者不可被攻击");
        //}
        // if (_target == null || !_target.CanAtked())
        // {
        //     Debug.Log("目标已死亡或者不可被攻击");
        // }
        //if (PlayerDatas.Instance.hero == null)
        //{
        //    Debug.Log("主角被销毁");
        //}
        // if (PlayerDatas.Instance.hero == null)
        // {
        //     Debug.Log("主角被销毁");
        // }
        //if (m_ActiveInterrupt)
        //{
        //    Debug.Log("行为被打断");
        //}
        // if (m_ActiveInterrupt)
        // {
        //     Debug.Log("行为被打断");
        // }
        //if (_hero.aiHandler.currentType != E_HeroAIType.KillUntilDie)
        //{
        //    Debug.Log("已切换ai行为");
        //}
        // if (_hero.aiHandler.currentType != E_HeroAIType.KillUntilDie)
        // {
        //     Debug.Log("已切换ai行为");
        // }
        // if (m_LimitOnce)
        // {
        //     Debug.Log("释放过一次技能");
        // }
        return (_target == null
            || !_target.CanAtked()
@@ -304,8 +313,8 @@
            || _hero == null
            || _hero.aiHandler.currentType != E_HeroAIType.KillUntilDie)
            && (m_LimitOnce
             || MapArea.IsInMapArea(_hero.CurMapArea, MapArea.E_Type.Safe)
             || MapArea.IsInMapArea(_hero.CurMapArea, MapArea.E_Type.RebornSafe));
            || MapArea.IsInMapArea(_hero.CurMapArea, MapArea.E_Type.Safe)
            || MapArea.IsInMapArea(_hero.CurMapArea, MapArea.E_Type.RebornSafe));
    }
    private void OnActiveInterrupt()
@@ -313,8 +322,10 @@
        m_ActiveInterrupt = true;
        GA_Hero _hero = PlayerDatas.Instance.hero;
        _hero.aiHandler.currentType = E_HeroAIType.None;
        if (_hero != null)
        {
            _hero.aiHandler.currentType = E_HeroAIType.None;
        }
    }
    private void OnClickFloor(Vector3 dest)
@@ -322,6 +333,9 @@
        m_ActiveInterrupt = true;
        GA_Hero _hero = PlayerDatas.Instance.hero;
        _hero.aiHandler.currentType = E_HeroAIType.None;
        if (_hero != null)
        {
            _hero.aiHandler.currentType = E_HeroAIType.None;
        }
    }
}
Fight/Actor/HeroBehaviour.cs
@@ -143,7 +143,6 @@
            }
        }
        if (m_Hero.aiHandler.currentType == E_HeroAIType.None)
        {
            byte _type = (byte)E_HeroAIType.KillUntilDie;
@@ -155,10 +154,12 @@
            _data.defaultSkillID = m_WillUsedSkillID;
            m_Hero.aiHandler.currentType = E_HeroAIType.KillUntilDie;
        }
        if (OnUserClickSkill != null)
        else
        {
            OnUserClickSkill(m_WillUsedSkillID);
            if (OnUserClickSkill != null)
            {
                OnUserClickSkill(m_WillUsedSkillID);
            }
        }
    }
Fight/Actor/UserInputHandler.cs
@@ -57,7 +57,7 @@
        float KeyVertical = Input.GetAxis("Vertical");
        float KeyHorizontal = Input.GetAxis("Horizontal");
        if (Input.GetKey(KeyCode.J))
        if (Input.GetKeyUp(KeyCode.J))
        {
            _hero.ComAtk();
        }
Fight/PreFightMission.cs
@@ -902,7 +902,7 @@
             _model2.clickClosed = false;
             m_AfterAttackType = E_AfterAttackType.RefreshRock;
             HeroBehaviour.OnUserClickSkill += OnCastSkill;
             HeroBehaviour.onCastSkill += OnCastSkill;
             _model2.onClose = null;
@@ -1146,7 +1146,7 @@
    private void OnCastSkill(int skillID)
    {
        HeroBehaviour.OnUserClickSkill -= OnCastSkill;
        HeroBehaviour.onCastSkill -= OnCastSkill;
        if (m_AfterAttackType == E_AfterAttackType.RefreshRock)
        {
@@ -1612,7 +1612,7 @@
        _temp = WindowCenter.Instance.Get<MainInterfaceWin>().transform.Find("CopyOfThePanel/HighSettingTip/Container_Treasure");
        _temp.gameObject.SetActive(true);
        _temp = WindowCenter.Instance.Get<MainInterfaceWin>().transform.Find("MainInterfaceWin/InGameDownLoadProgress");
        _temp = WindowCenter.Instance.Get<MainInterfaceWin>().transform.Find("InGameDownLoadProgress");
        _temp.localScale = Vector3.one;
        _temp = WindowCenter.Instance.Get<MainInterfaceWin>().transform.Find("SkillButtonTip/Pivot/CastSkillTip/SwitchPan_a");