bug animation dont clear pre- animation

This commit is contained in:
VDH
2025-10-16 17:41:05 +07:00
parent 755638c5f8
commit e9048c035b
5 changed files with 70 additions and 15 deletions
@@ -29,7 +29,7 @@ public class CECAttacksMan : MonoSingleton<CECAttacksMan>
public CECAttackerEvents FindAttackByAttacker(int idHost)
{
CECAttackerEvents result = new CECAttackerEvents();
BMLogger.LogError("HoangDev: FindAttackByAttacker idHost: " + m_AttackLinkedList.Count);
foreach (var attack in m_AttackLinkedList)
{
if (attack.m_idHost == idHost)
@@ -57,6 +57,7 @@ public class CECAttacksMan : MonoSingleton<CECAttacksMan>
nTimeFly // timeToDoDamage
);
m_AttackLinkedList.AddLast(newEvent);
BMLogger.LogError("HoangDev: FindAttackByAttacker idHost: " + m_AttackLinkedList.Count);
newEvent.UpdateTargetFlag();
return m_AttackLinkedList.Last.Value;
@@ -133,6 +134,7 @@ public class CECAttackEvent
m_nSkillLevel = nSkillLevel;
m_timeToBeFired = (uint)nTimeToBeFired;
m_timeToDoDamage = (uint)nTimeToDoDamage;
m_bFinished = false;
AddTarget(idTarget, dwModifier, nDamage);
}
+15 -2
View File
@@ -423,8 +423,8 @@ public abstract class CECPlayer : CECObject
if (CECAttacksMan.Instance.FindAttackByAttacker(GetPlayerInfo().cid))
{
// Unity animation làm hộ r
//ClearComActFlagAllRankNodes(true);
BMLogger.LogError("CECAttacksMan::FindAttackByAttacker != NULL");
ClearComActFlagAllRankNodes(true);
}
// melee attack
@@ -506,6 +506,19 @@ public abstract class CECPlayer : CECObject
*piAttackTime = 0;*/
}
}
private void ClearComActFlagAllRankNodes(bool v)
{
EventBus.PublishChannel(m_PlayerInfo.cid, new CleearComActFlagAllRankNodesEvent(v));
}
public struct CleearComActFlagAllRankNodesEvent
{
public bool v;
public CleearComActFlagAllRankNodesEvent(bool value)
{
v = value;
}
}
public bool PlayAttackAction(int nAttackSpeed, out int attackTime, CECAttackEvent attackEvent)
{
attackTime = 0;
+1 -1
View File
@@ -353,7 +353,7 @@ public class CECHostPlayer : CECPlayer
}
public void OnMsgHstAttackResult(ECMSG Msg)
{
BMLogger.LogError($"dwParam1 type = {Msg.dwParam1?.GetType()}");
BMLogger.LogError($"HoangDev OnMsgHstAttackResult ");
byte[] data = Msg.dwParam1 as byte[];
cmd_host_attack_result pCmd = EC_Utility.ByteArrayToStructure<cmd_host_attack_result>(data);
+15 -2
View File
@@ -4,13 +4,14 @@ using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static CECPlayer;
public class PlayerVisual : MonoBehaviour
{
[SerializeField] NamedAnimancerComponent namedAnimancer;
[SerializeField] private INFO _playerInfo;
private Dictionary<string, AnimancerState> _activeStates = new();
[SerializeField] private AnimancerState _currentState;
[SerializeField] private Queue<string> _animationQueue = new Queue<string>();
[SerializeField] private bool isHit;
@@ -42,6 +43,16 @@ public class PlayerVisual : MonoBehaviour
_playerInfo = player.GetPlayInfo();
EventBus.SubscribeChannel<PlayActionEvent>(_playerInfo.cid, PlayActionEventHandler);
EventBus.SubscribeChannelClass<QueueActionEvent>(_playerInfo.cid, QueueActionEventHandler);
EventBus.SubscribeChannel<CleearComActFlagAllRankNodesEvent>(_playerInfo.cid, CleearComActFlagAllRankNodesEventHandler);
}
private void CleearComActFlagAllRankNodesEventHandler(CleearComActFlagAllRankNodesEvent @event)
{
_animationQueue.Clear();
if (isHit)
{
ApplyDamage();
}
}
private void QueueActionEventHandler(QueueActionEvent @event)
@@ -58,10 +69,10 @@ public class PlayerVisual : MonoBehaviour
public bool EnqueueAnimation(QueueActionEvent @event)
{
if (namedAnimancer == null) return false;
queueActionEvent = @event;
_animationQueue.Enqueue(@event.AnimationName);
if (!isHit)
{
queueActionEvent = @event;
isHit = @event.IsHitAnim;
}
return true;
@@ -84,8 +95,10 @@ public class PlayerVisual : MonoBehaviour
}
void ApplyDamage()
{
if(queueActionEvent == null) return;
isHit = false;
queueActionEvent.SetFlag(true, queueActionEvent.AttackEvent);
queueActionEvent = null;
}
private void OnDestroy()
{
File diff suppressed because one or more lines are too long