using UnityEngine; public class Status_Mocking : Status_Base { private float m_LastUseSkillTime; public sealed override void Update() { if (h0605.ObjID != PlayerDatas.Instance.PlayerId) { return; } GA_Hero _hero = PlayerDatas.Instance.hero; if (_hero == null || !_hero.CanCommonAtk()) { return; } // 攻击间隔中 if (Time.time - m_LastUseSkillTime < (1f / _hero.ActorInfo.atkSpeed) * .8f) { return; } Skill _skill = _hero.SkillMgr.CurCastSkill; if (_hero.SkillMgr.DoingPrepareSkill) { return; } // 判断主角当前是否有技能尚未释放完毕 if (_skill != null) { if (!_skill.SkillCompelete) { return; } } int _index = _hero.nextComAtkIndex; if (_index == -1) { _index = 0; } int _comSkillID = _hero.GetCommonSkillID(_index); _skill = _hero.SkillMgr.Get(_comSkillID); if (_skill == null) { return; } // 这里需要实时取对象, 因为视野可能导致对象回收 GActorFight _target = GAMgr.Instance.GetBySID(h0605.OwnerID) as GActorFight; // 对象是否还存在且为可攻击状态 if (_target == null || !_target.CanAtked()) { return; } // 判断技能范围, 不在可释放范围需要移动至目标 float _compareDist = _skill.skillInfo.config.AtkDist * .5f; float _compareDistSqrt = _compareDist * _compareDist; // 计算当前和目标的距离 float _currentDistSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, _target.Pos); // 比较距离 if (_currentDistSqrt > _compareDistSqrt) { // 移动至目标 _hero.MoveToTarget(_target, _compareDist); // 判断是否需要冲锋 if (_hero.IsNeedRush(_currentDistSqrt)) { _hero.StartRush(); } return; } // 停止冲锋逻辑 _hero.StopRush(); Vector3 _forward = MathUtility.ForwardXZ(_target.Pos, _hero.Pos); _hero.destForward = _hero.Forward = _forward; _hero.Behaviour.DoCommonAttack(); m_LastUseSkillTime = Time.time; } }