using UnityEngine;
|
|
public class STM_NormalAttack : STM_BaseAttack
|
{
|
public static UnityEngine.Events.UnityAction OnCastNormalAttack;
|
protected bool hadCompelete = false;
|
|
protected virtual void CacheSkillId(GActorPlayerBase _playerActor) { }
|
|
protected override void OnEnter(GActor owner, Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
{
|
GActorPlayerBase _player = owner as GActorPlayerBase;
|
|
if (_player == null)
|
{
|
return;
|
}
|
|
CacheSkillId(_player);
|
|
m_CastedEffect.Clear();
|
m_Duration = 0;
|
m_ProcessFrame = 0;
|
m_ProcessIndex = 0;
|
m_MoveDuration = 0;
|
m_DelayHurtBlood.Clear();
|
m_ClickedEndPosition = Vector3.zero;
|
hasHandleDelayLogic = false;
|
m_EndPosition = _player.Pos;
|
m_CacheSkill = _player.SkillMgr.Get(cacheSkillID);
|
|
if (_player.ServerInstID == PlayerDatas.Instance.PlayerId)
|
{
|
if (_player.State == E_ActorState.AutoRun)
|
{
|
_player.StopPathFind();
|
// 同步停止协议
|
C0502_tagCPlayerStopMove _0502 = new C0502_tagCPlayerStopMove();
|
_0502.Dir = 0;
|
_0502.PosX = (ushort)(_player.Pos.x * 2);
|
_0502.PosY = (ushort)(_player.Pos.z * 2);
|
_0502.WorldTick = 0;
|
GameNetSystem.Instance.SendInfo(_0502);
|
}
|
|
if (UserInputHandler.isTouched)
|
{
|
Vector3 _dir = _player.destForward;
|
if (_player.SelectTarget != null)
|
{
|
Vector3 _targetPos = _player.SelectTarget.Pos;
|
Vector3 _selfPos = _player.Pos;
|
_targetPos.y = 0;
|
_selfPos.y = 0;
|
_dir = (_targetPos - _selfPos).normalized;
|
}
|
_player.Forward = _dir;
|
}
|
|
if (OnCastNormalAttack != null)
|
{
|
OnCastNormalAttack();
|
}
|
}
|
|
hadCompelete = false;
|
|
_player.Idle();
|
|
_player.SwitchHeadNameBindNode(true);
|
m_EffectAnimatorSpeed = m_AnimatorSpeed = animator.speed = owner.ActorInfo.atkSpeed;
|
|
#if UNITY_EDITOR
|
string _content = string.Format("STM_BaseAttack => {0} 的技能: {1} 进入技能状态逻辑", owner.ServerInstID, cacheSkillID);
|
RuntimeLogUtility.AddLog_Green(_content);
|
m_EnterPos = m_EndPosition;
|
#endif
|
|
if (m_CacheSkill != null)
|
{
|
if (m_CacheSkill.skillInfo.soFile != null)
|
{
|
if (m_CacheSkill.skillInfo.soFile.effectOnTargetHead > 0)
|
{
|
if (_player.SelectTarget != null)
|
{
|
if (BattleEffectPlayRule.Instance.CanPlay(_player.ServerInstID))
|
{
|
m_StartHeadEffect = SFXPlayUtility.Instance.PlayEffectAsync(m_CacheSkill.skillInfo.soFile.effectOnTargetHead, _player.SelectTarget);
|
}
|
}
|
}
|
}
|
}
|
|
if (owner is GA_Player || owner is GA_Hero)
|
{
|
if (owner.State != E_ActorState.Roll)
|
{
|
owner.State = E_ActorState.CommonAtk;
|
}
|
}
|
}
|
|
protected override void OnExit(GActor owner, Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
|
{
|
DoCompelete();
|
|
base.OnExit(owner, animator, stateInfo, layerIndex);
|
}
|
|
protected override void OnSkillComplete()
|
{
|
DoCompelete();
|
}
|
|
protected void DoCompelete()
|
{
|
if (hadCompelete)
|
{
|
return;
|
}
|
|
hadCompelete = true;
|
|
if (owner.State == E_ActorState.CommonAtk)
|
{
|
owner.State = E_ActorState.Idle;
|
}
|
|
HandleSkillCompelete(owner as GActorPlayerBase);
|
|
ProcessDelayLogic();
|
|
if (owner.ServerInstID == PlayerDatas.Instance.PlayerId)
|
{
|
PlayerDatas.Instance.hero.Behaviour.ResetComAtkConnectTime();
|
}
|
}
|
|
protected virtual void HandleSkillCompelete(GActorPlayerBase owner) { }
|
}
|