121 lines
3.9 KiB
C#
121 lines
3.9 KiB
C#
using CSNetwork.Protocols;
|
|
using UnityEngine;
|
|
|
|
public class CECNPCModelDefaultPolicy
|
|
: CECNPCModelPolicy
|
|
{
|
|
CECModel m_pNPCModel;
|
|
|
|
public CECNPCModelDefaultPolicy(CECNPC pNPC)
|
|
{
|
|
|
|
}
|
|
|
|
public string GetActionName(int iAct, bool bAttackStart = false)
|
|
{
|
|
// Tạo builder thay cho static char[128]
|
|
var sb = new System.Text.StringBuilder();
|
|
|
|
// Thêm tên base action
|
|
sb.Append(CECNPC.GetBaseActionName(iAct));
|
|
|
|
// Nếu là attack action thì thêm hậu tố
|
|
if (CECNPC.IsAttackAction(iAct))
|
|
{
|
|
sb.Append(bAttackStart ? "Æð" : "Âä");
|
|
}
|
|
|
|
// Xử lý loại bỏ dấu nháy kép (nếu có)
|
|
string result = sb.ToString().Replace("\"", "");
|
|
|
|
// Trả về kết quả đã clean
|
|
return result;
|
|
}
|
|
|
|
public override bool PlayModelAction(int iAction, bool bRestart)
|
|
{
|
|
|
|
/* if (m_pNPCModel == null)
|
|
{
|
|
return false;
|
|
}
|
|
*/
|
|
bool result = false;
|
|
|
|
if (iAction == (int)NPCActionIndex.ACT_WOUNDED)
|
|
{
|
|
string szAct = GetActionName(iAction);
|
|
if (!_npcVisual.IsAnimationExist(szAct))
|
|
{
|
|
szAct = GetActionName((int)NPCActionIndex.ACT_WOUNDED2);
|
|
}
|
|
result = _npcVisual.TryPlayAction(szAct);
|
|
}
|
|
else if (iAction == (int)NPCActionIndex.ACT_ATTACK1 || iAction == (int)NPCActionIndex.ACT_ATTACK2)
|
|
{
|
|
//bool bHideFX = !CECOptimize::Instance().GetGFX().CanShowAttack(m_pNPC->GetNPCID(), m_pNPC->GetClassID());
|
|
result = _npcVisual.TryPlayAction(GetActionName(iAction, true));
|
|
if (result)
|
|
{
|
|
/* m_pNPCModel->QueueAction(GetActionName(iAction, false), 0, 0, false, false, bHideFX);
|
|
m_pNPCModel->QueueAction(GetActionName(CECNPC::ACT_GUARD), 300);*/
|
|
}
|
|
}
|
|
else if (iAction == (int)NPCActionIndex.ACT_IDLE)
|
|
{
|
|
result = _npcVisual.TryPlayAction(GetActionName(iAction));
|
|
if (result)
|
|
{
|
|
//m_pNPCModel->QueueAction(GetActionName((int)NPCActionIndex.ACT_STAND));
|
|
}
|
|
}
|
|
else if (iAction == (int)NPCActionIndex.ACT_NPC_IDLE1 || iAction == (int)NPCActionIndex.ACT_NPC_IDLE2)
|
|
{
|
|
result = _npcVisual.TryPlayAction(GetActionName(iAction));
|
|
if (result)
|
|
{
|
|
//m_pNPCModel->QueueAction(GetActionName((int)NPCActionIndex.ACT_NPC_STAND));
|
|
}
|
|
}
|
|
else if (iAction == (int)NPCActionIndex.ACT_NPC_ATTACK)
|
|
{
|
|
//bool bHideFX = !CECOptimize::Instance().GetGFX().CanShowAttack(m_pNPC->GetNPCID(), m_pNPC->GetClassID());
|
|
result = _npcVisual.TryPlayAction(GetActionName(iAction)); ;
|
|
if (result)
|
|
{
|
|
/*m_pNPCModel->QueueAction(GetActionName(iAction, false), 0, 0, false, false, bHideFX);
|
|
m_pNPCModel->QueueAction(GetActionName(CECNPC::ACT_NPC_STAND), 300);*/
|
|
}
|
|
}
|
|
else if (iAction == (int)NPCActionIndex.ACT_COMMON_BORN)
|
|
{
|
|
result = _npcVisual.TryPlayAction(GetActionName(iAction));
|
|
if (result)
|
|
{
|
|
//m_pNPCModel->QueueAction(GetActionName((int)NPCActionIndex.ACT_STAND));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
result = _npcVisual.TryPlayAction(GetActionName(iAction));
|
|
}
|
|
return result;
|
|
}
|
|
public override bool IsPlayingAction()
|
|
{
|
|
return _npcVisual.IsPlayAnimation();
|
|
}
|
|
public override bool IsPlayingAction(int iAction)
|
|
{
|
|
return _npcVisual.IsPlayAnimation(GetActionName(iAction));
|
|
}
|
|
public override bool HasAction(int iAction)
|
|
{
|
|
return _npcVisual.IsAnimationExist(GetActionName(iAction));
|
|
}
|
|
public override void SetNpcVisual(NPCVisual npcVisual)
|
|
{
|
|
_npcVisual = npcVisual;
|
|
}
|
|
}
|