fix play animation
This commit is contained in:
@@ -1649,6 +1649,7 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 3698356007416754653}
|
||||
- component: {fileID: 6067755730919934559}
|
||||
m_Layer: 0
|
||||
m_Name: "\u6B66\u4FA0\u7537"
|
||||
m_TagString: Untagged
|
||||
@@ -1672,6 +1673,22 @@ Transform:
|
||||
- {fileID: 1172840009114654878}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!111 &6067755730919934559
|
||||
Animation:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2132400081078426141}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 4
|
||||
m_Animation: {fileID: 7400000, guid: 944a8a50d5b7a2b48adda6181a6b34a7, type: 2}
|
||||
m_Animations: []
|
||||
m_WrapMode: 0
|
||||
m_PlayAutomatically: 1
|
||||
m_AnimatePhysics: 0
|
||||
m_UpdateMode: 0
|
||||
m_CullingType: 0
|
||||
--- !u!1 &2170371384673563007
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2586,20 +2603,23 @@ MonoBehaviour:
|
||||
- {fileID: 7400000, guid: 4c93f18fe5082524d8ccda024f7988ad, type: 2}
|
||||
- {fileID: 7400000, guid: bc909de03ae7dcc4d824253bf652de1d, type: 2}
|
||||
- {fileID: 7400000, guid: 0f91f25e28e0f9e40b3775ae54c8f7da, type: 2}
|
||||
- {fileID: 7400000, guid: 944a8a50d5b7a2b48adda6181a6b34a7, type: 2}
|
||||
- {fileID: 7400000, guid: 211cf985d64485e4ca42f7d8d6509e87, type: 2}
|
||||
- {fileID: 7400000, guid: caa9485da71a78b4da087ae69bf7120d, type: 2}
|
||||
- {fileID: 7400000, guid: 233ca05b3510f614e8b2ea31731dc298, type: 2}
|
||||
- {fileID: 7400000, guid: 13d67a517390ab44ab7cd04a01241fa1, type: 2}
|
||||
- {fileID: 7400000, guid: ca2d9fd2f36b8be4b913cf0454258ecc, type: 2}
|
||||
- {fileID: 7400000, guid: e45130cf176245344a417eb0ddb79826, type: 2}
|
||||
- {fileID: 7400000, guid: 3e4c04d71f4e90041b63b23d8537a208, type: 2}
|
||||
- {fileID: 7400000, guid: b8a2d2fdc3fbd5a4ca393badcb53bbea, type: 2}
|
||||
- {fileID: 7400000, guid: b0ca22f0c2157aa46a778db01a1e5021, type: 2}
|
||||
- {fileID: 7400000, guid: 097ef914299efe045a7aca60c48e2eb1, type: 2}
|
||||
- {fileID: 7400000, guid: c2fb725802130e449a0636acf8b1815d, type: 2}
|
||||
- {fileID: 7400000, guid: 94e88f93d73c0384e912f9bdf56ca0f0, type: 2}
|
||||
- {fileID: 7400000, guid: 786983b70dc6a38408454df8417def4a, type: 2}
|
||||
- {fileID: 7400000, guid: e8c5bb1084b86d2479538668547bc7bd, type: 2}
|
||||
- {fileID: 7400000, guid: 3ab1241d6adeb0a4988632a06f8b8082, type: 2}
|
||||
- {fileID: 7400000, guid: 30e08956cf9426044bf26fc108298874, type: 2}
|
||||
- {fileID: 7400000, guid: 94e88f93d73c0384e912f9bdf56ca0f0, type: 2}
|
||||
_searchingAnimation: "\u53D7\u4F24_\u901A\u7528"
|
||||
--- !u!1 &2587141697474146175
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace PerfectWorld.Scripts.Managers
|
||||
//if (pPlayer && !pPlayer.IsAboutToDie())
|
||||
// pPlayer.Killed(pCmd.idKiller);
|
||||
|
||||
EventBus.PublishChannel(pPlayer.GetCharacterID(), new CECPlayer.CleearComActFlagAllRankNodesEvent(true));
|
||||
EventBus.PublishChannel(pPlayer.GetCharacterID(), new CECPlayer.ClearComActFlagAllRankNodesEvent(true));
|
||||
pPlayer.PlayAction((int)CECPlayer.PLAYER_ACTION_TYPE.ACT_GROUNDDIE);
|
||||
}
|
||||
|
||||
|
||||
@@ -513,7 +513,6 @@ public abstract partial class CECPlayer : CECObject
|
||||
|
||||
if (CECAttacksMan.Instance.FindAttackByAttacker(GetPlayerInfo().cid))
|
||||
{
|
||||
BMLogger.LogError("CECAttacksMan::FindAttackByAttacker != NULL");
|
||||
ClearComActFlagAllRankNodes(true);
|
||||
}
|
||||
|
||||
@@ -600,14 +599,14 @@ public abstract partial class CECPlayer : CECObject
|
||||
|
||||
private void ClearComActFlagAllRankNodes(bool v)
|
||||
{
|
||||
EventBus.PublishChannel(m_PlayerInfo.cid, new CleearComActFlagAllRankNodesEvent(v));
|
||||
EventBus.PublishChannel(m_PlayerInfo.cid, new ClearComActFlagAllRankNodesEvent(v));
|
||||
}
|
||||
|
||||
public struct CleearComActFlagAllRankNodesEvent
|
||||
public struct ClearComActFlagAllRankNodesEvent
|
||||
{
|
||||
public bool v;
|
||||
|
||||
public CleearComActFlagAllRankNodesEvent(bool value)
|
||||
public ClearComActFlagAllRankNodesEvent(bool value)
|
||||
{
|
||||
v = value;
|
||||
}
|
||||
@@ -1039,7 +1038,6 @@ public abstract partial class CECPlayer : CECObject
|
||||
|
||||
public void Damaged(int nDamage, uint dwModifier = 0, int skill = 0)
|
||||
{
|
||||
BMLogger.LogError($"HoangDev: Damaged nDamage={nDamage} ");
|
||||
if (nDamage == -2)
|
||||
{
|
||||
// this message is caused by a help skill, so don't use a wounded action here
|
||||
@@ -1056,7 +1054,7 @@ public abstract partial class CECPlayer : CECObject
|
||||
// Just play a wounded action
|
||||
if (!OnDamaged(skill))
|
||||
{
|
||||
PlayAction((int)PLAYER_ACTION_TYPE.ACT_WOUNDED);
|
||||
// PlayAction((int)PLAYER_ACTION_TYPE.ACT_WOUNDED);
|
||||
}
|
||||
/*if (dwModifier & CECAttackEvent::MOD_IMMUNE)
|
||||
BubbleText(BUBBLE_IMMUNE, 0);
|
||||
@@ -1078,7 +1076,7 @@ public abstract partial class CECPlayer : CECObject
|
||||
p1 |= 0x0002;*/
|
||||
|
||||
if (!OnDamaged(skill))
|
||||
PlayAction((int)PLAYER_ACTION_TYPE.ACT_WOUNDED);
|
||||
// PlayAction((int)PLAYER_ACTION_TYPE.ACT_WOUNDED);
|
||||
|
||||
DamageTextManager.Instance.ShowDamageText(
|
||||
transform.position, nDamage, Color.yellow, 1.0f);
|
||||
|
||||
@@ -528,7 +528,7 @@ public partial class CECHostPlayer : CECPlayer
|
||||
public bool HostIsReady() { return true /*m_bEnterGame*/; }
|
||||
private void OnMsgHstDied(in ECMSG msg)
|
||||
{
|
||||
EventBus.PublishChannel(GetCharacterID(), new CECPlayer.CleearComActFlagAllRankNodesEvent(true));
|
||||
EventBus.PublishChannel(GetCharacterID(), new CECPlayer.ClearComActFlagAllRankNodesEvent(true));
|
||||
PlayAction((int)PLAYER_ACTION_TYPE.ACT_GROUNDDIE);
|
||||
if (PopupManager.Instance != null)
|
||||
{
|
||||
@@ -633,8 +633,6 @@ public partial class CECHostPlayer : CECPlayer
|
||||
CECNPC pAttacker = EC_ManMessageMono.Instance._CECNPCMan.GetNPC(pCmd.idAttacker);
|
||||
if (pAttacker)
|
||||
{
|
||||
BMLogger.LogError($"HoangDev pAttacker.OnMsgAttackHostResult ");
|
||||
|
||||
pAttacker.OnMsgAttackHostResult(GetCharacterID(), pCmd.iDamage, pCmd.attack_flag, pCmd.speed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using BrewMonster;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using static CECPlayer;
|
||||
|
||||
@@ -14,20 +15,22 @@ public class PlayerVisual : MonoBehaviour
|
||||
private Dictionary<string, AnimancerState> _activeStates = new();
|
||||
[SerializeField] private AnimancerState _currentState;
|
||||
[SerializeField] private Queue<string> _animationQueue = new Queue<string>();
|
||||
[SerializeField] private List<string> _animationList = new List<string>();
|
||||
[SerializeField] private bool isHit;
|
||||
[SerializeField] private int id;
|
||||
|
||||
private const float FadeTime = 0.3f;
|
||||
private const float FadeTime = 0.1f;
|
||||
private const FadeMode FadeMode = Animancer.FadeMode.FixedDuration;
|
||||
QueueActionEvent queueActionEvent;
|
||||
|
||||
private void PlayActionEventHandler(PlayActionEvent @event)
|
||||
{
|
||||
_currentState = namedAnimancer.TryPlay(@event.AnimationName, FadeTime, FadeMode);
|
||||
if (_currentState == null)
|
||||
{
|
||||
BMLogger.LogError("HoangDev: PlayActionEventHandler Failed " + @event.AnimationName);
|
||||
}
|
||||
// if (_animationQueue.Count > 0)
|
||||
// {
|
||||
// _animationQueue.Enqueue(@event.AnimationName);
|
||||
// return;
|
||||
// }
|
||||
InternalPlayAnimation(@event.AnimationName);
|
||||
}
|
||||
public void InitPlayerEventDoneHandler()
|
||||
{
|
||||
@@ -48,32 +51,33 @@ public class PlayerVisual : MonoBehaviour
|
||||
id = _playerInfo.cid;
|
||||
EventBus.SubscribeChannel<PlayActionEvent>(_playerInfo.cid, PlayActionEventHandler);
|
||||
EventBus.SubscribeChannelClass<QueueActionEvent>(_playerInfo.cid, QueueActionEventHandler);
|
||||
EventBus.SubscribeChannel<CleearComActFlagAllRankNodesEvent>(_playerInfo.cid, CleearComActFlagAllRankNodesEventHandler);
|
||||
EventBus.SubscribeChannel<ClearComActFlagAllRankNodesEvent>(_playerInfo.cid, ClearComActFlagAllRankNodesEventHandler);
|
||||
}
|
||||
|
||||
public void InitElsePlayerEventDoneHandler(INFO playerInfo)
|
||||
{
|
||||
namedAnimancer = GetComponentInChildren<NamedAnimancerComponent>();
|
||||
if (namedAnimancer == null)
|
||||
{
|
||||
BrewMonster.BMLogger.LogError("animancer == null");
|
||||
return;
|
||||
}
|
||||
//var player = GetComponentInParent<CECPlayer>();
|
||||
//if (player == null)
|
||||
//{
|
||||
// BrewMonster.BMLogger.LogError("player == null");
|
||||
// return;
|
||||
//}
|
||||
_playerInfo = playerInfo;//player.GetPlayInfo();
|
||||
EventBus.SubscribeChannel<PlayActionEvent>(_playerInfo.cid, PlayActionEventHandler);
|
||||
EventBus.SubscribeChannelClass<QueueActionEvent>(_playerInfo.cid, QueueActionEventHandler);
|
||||
EventBus.SubscribeChannel<CleearComActFlagAllRankNodesEvent>(_playerInfo.cid, CleearComActFlagAllRankNodesEventHandler);
|
||||
}
|
||||
// public void InitElsePlayerEventDoneHandler(INFO playerInfo)
|
||||
// {
|
||||
// namedAnimancer = GetComponentInChildren<NamedAnimancerComponent>();
|
||||
// if (namedAnimancer == null)
|
||||
// {
|
||||
// BrewMonster.BMLogger.LogError("animancer == null");
|
||||
// return;
|
||||
// }
|
||||
// //var player = GetComponentInParent<CECPlayer>();
|
||||
// //if (player == null)
|
||||
// //{
|
||||
// // BrewMonster.BMLogger.LogError("player == null");
|
||||
// // return;
|
||||
// //}
|
||||
// _playerInfo = 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)
|
||||
private void ClearComActFlagAllRankNodesEventHandler(ClearComActFlagAllRankNodesEvent @event)
|
||||
{
|
||||
_animationQueue.Clear();
|
||||
_animationList = _animationQueue.ToList();
|
||||
if (isHit)
|
||||
{
|
||||
ApplyDamage();
|
||||
@@ -95,6 +99,8 @@ public class PlayerVisual : MonoBehaviour
|
||||
{
|
||||
if (namedAnimancer == null) return false;
|
||||
_animationQueue.Enqueue(@event.AnimationName);
|
||||
_animationList = _animationQueue.ToList();
|
||||
|
||||
if (!isHit)
|
||||
{
|
||||
queueActionEvent = @event;
|
||||
@@ -108,15 +114,20 @@ public class PlayerVisual : MonoBehaviour
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_currentState == null) return;
|
||||
if (_currentState.NormalizedTime < 1f) return;
|
||||
if (isHit)
|
||||
|
||||
// if (_currentState == null)
|
||||
// {
|
||||
// _animationQueue.Dequeue();
|
||||
// return;
|
||||
// }
|
||||
if (_currentState!=null && _currentState.NormalizedTime < 1f) return;
|
||||
if (isHit)// have it relative to check _currentState == null?
|
||||
{
|
||||
ApplyDamage();
|
||||
}
|
||||
string animName = _animationQueue.Dequeue();
|
||||
_currentState = namedAnimancer.TryPlay(animName, FadeTime, FadeMode);
|
||||
|
||||
_animationList = _animationQueue.ToList();
|
||||
InternalPlayAnimation(animName);
|
||||
}
|
||||
void ApplyDamage()
|
||||
{
|
||||
@@ -127,10 +138,28 @@ public class PlayerVisual : MonoBehaviour
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
EventBus.UnsubscribeAllInChannel(_playerInfo.cid);
|
||||
EventBus.UnsubscribeChannel<PlayActionEvent>(_playerInfo.cid, PlayActionEventHandler);
|
||||
EventBus.UnsubscribeChannelClass<QueueActionEvent>(_playerInfo.cid, QueueActionEventHandler);
|
||||
EventBus.UnsubscribeChannel<ClearComActFlagAllRankNodesEvent>(_playerInfo.cid, ClearComActFlagAllRankNodesEventHandler);
|
||||
// EventBus.UnsubscribeAllInChannel(_playerInfo.cid);
|
||||
}
|
||||
public bool IsAnimationExist(string animationName)
|
||||
{
|
||||
return namedAnimancer.States.TryGet("ActionName", out var existingState) ? true : false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// play an animation with name
|
||||
/// </summary>
|
||||
/// <param name="animationName"></param>
|
||||
/// <param name="duration"></param>
|
||||
/// <param name="fadeMode"></param>
|
||||
private void InternalPlayAnimation(string animationName, float duration = FadeTime, FadeMode fadeMode = FadeMode)
|
||||
{
|
||||
_currentState = namedAnimancer.TryPlay(animationName, duration, fadeMode);
|
||||
if (_currentState == null)
|
||||
{
|
||||
BMLogger.LogError($"Null animation with name: {animationName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user