using System;
|
using vnxbqy.UI;
|
using UnityEngine;
|
|
public class Status_Mocking : Status_Base
|
{
|
private float m_LastUseSkillTime;
|
private int m_UseClickSkill = -1;
|
|
public override void Init(uint sid, int skillId, uint srcSid, int type, int lastTime)
|
{
|
base.Init(sid, skillId, srcSid, type, lastTime);
|
m_UseClickSkill = -1;
|
HeroBehaviour.OnUserClickSkill += OnUserClickSkill;
|
}
|
|
private void OnUserClickSkill(int skillId)
|
{
|
m_UseClickSkill = skillId;
|
}
|
|
public override void UnInit(uint objID, byte buffType)
|
{
|
base.UnInit(objID, buffType);
|
|
HeroBehaviour.OnUserClickSkill -= OnUserClickSkill;
|
}
|
|
public sealed override void Update()
|
{
|
if (Sid != 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;
|
}
|
}
|
|
_skill = null;
|
|
if (m_UseClickSkill != -1)
|
{
|
int _skillId;
|
var _tsModel = ModelCenter.Instance.GetModel<TreasureSkillModel>();
|
if (_tsModel.TryGetExpertSkill(m_UseClickSkill, out _skillId))
|
{
|
int _level = 0;
|
if (_tsModel.TryGetExpertActiveLevel(_skillId, out _level))
|
{
|
_skillId += (_level - 1);
|
}
|
var _skillInfo = SkillHelper.Instance.Get(_skillId);
|
SkillHelper.EffectValue _effectValue;
|
if (_skillInfo.effectValue.TryGetValue(4093, out _effectValue))
|
{
|
_skill = _hero.SkillMgr.Get(_skillId);
|
}
|
}
|
m_UseClickSkill = -1;
|
}
|
|
if (_skill == null)
|
{
|
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(CasterSid) 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;
|
|
if (_skill.skillInfo.config.FuncType == (int)E_SkillFuncType.NormalAttack)
|
{
|
_hero.Behaviour.DoCommonAttack();
|
}
|
else
|
{
|
_hero.Behaviour.DoAttack(_skill);
|
}
|
|
m_UseClickSkill = -1;
|
m_LastUseSkillTime = Time.time;
|
}
|
}
|