fix gfx hit not sych with animation. Fix wrong animation timing with long weapon. Add animation scaling speed

This commit is contained in:
Tran Hai Nam
2026-05-17 15:48:29 +07:00
parent 285697bf8b
commit c851c46292
9 changed files with 10163 additions and 300 deletions
@@ -15,7 +15,7 @@ MonoBehaviour:
m_DefaultGroup: 712e3991f28e549e7a56ee582a977810
m_currentHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
Hash: 584471775533227dbfd66c0814b46e32
m_OptimizeCatalogSize: 0
m_BuildRemoteCatalog: 0
m_CatalogRequestsTimeout: 0
File diff suppressed because it is too large Load Diff
@@ -9754,7 +9754,7 @@ Transform:
m_GameObject: {fileID: 5579818482848807075}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 2.89, y: -8.21, z: -0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@@ -9768,7 +9768,7 @@ ParticleSystem:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5579818482848807075}
serializedVersion: 8
lengthInSec: 100000
lengthInSec: 5
simulationSpeed: 1
stopAction: 0
cullingMode: 0
@@ -9843,7 +9843,7 @@ ParticleSystem:
startLifetime:
serializedVersion: 2
minMaxState: 0
scalar: Infinity
scalar: 1
minScalar: 5
maxCurve:
serializedVersion: 2
@@ -11085,7 +11085,7 @@ ParticleSystem:
m_RotationOrder: 4
separateAxes: 0
ColorModule:
enabled: 0
enabled: 1
gradient:
serializedVersion: 2
minMaxState: 1
@@ -11110,17 +11110,17 @@ ParticleSystem:
ctime6: 0
ctime7: 0
atime0: 0
atime1: 65535
atime2: 0
atime1: 18504
atime2: 37586
atime3: 0
atime4: 0
atime5: 0
atime6: 0
atime7: 0
m_Mode: 0
m_ColorSpace: -1
m_ColorSpace: 0
m_NumColorKeys: 2
m_NumAlphaKeys: 2
m_NumAlphaKeys: 3
minGradient:
serializedVersion: 2
key0: {r: 1, g: 1, b: 1, a: 1}
@@ -14666,7 +14666,7 @@ ParticleSystem:
ringBufferMode: 0
ringBufferLoopRange: {x: 0, y: 1}
emitterVelocityMode: 0
looping: 1
looping: 0
prewarm: 0
playOnAwake: 1
useUnscaledTime: 0
@@ -15504,7 +15504,7 @@ ParticleSystem:
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 1
value: 0.21538544
inSlope: 0
outSlope: 0
tangentMode: 0
@@ -15926,8 +15926,8 @@ ParticleSystem:
maxColor: {r: 1, g: 1, b: 1, a: 1}
maxGradient:
serializedVersion: 2
key0: {r: 1, g: 1, b: 1, a: 1}
key1: {r: 1, g: 1, b: 1, a: 0}
key0: {r: 1, g: 1, b: 1, a: 0.22352941}
key1: {r: 1, g: 1, b: 1, a: 1}
key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
@@ -15943,8 +15943,8 @@ ParticleSystem:
ctime6: 0
ctime7: 0
atime0: 0
atime1: 45875
atime2: 0
atime1: 12336
atime2: 23901
atime3: 0
atime4: 0
atime5: 0
@@ -15953,7 +15953,7 @@ ParticleSystem:
m_Mode: 0
m_ColorSpace: 0
m_NumColorKeys: 2
m_NumAlphaKeys: 2
m_NumAlphaKeys: 3
minGradient:
serializedVersion: 2
key0: {r: 1, g: 1, b: 1, a: 1}
@@ -28,7 +28,7 @@ Transform:
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
m_LocalScale: {x: 0.33, y: 0.33, z: 0.33}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 3864086195955648519}
@@ -4919,7 +4919,7 @@ Transform:
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
m_LocalScale: {x: 0.33, y: 0.33, z: 0.33}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 3864086195955648519}
@@ -9752,7 +9752,7 @@ Transform:
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
m_LocalScale: {x: 0.33, y: 0.33, z: 0.33}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 3864086195955648519}
@@ -9780,7 +9780,7 @@ ParticleSystem:
startDelay:
serializedVersion: 2
minMaxState: 0
scalar: 0
scalar: 0.1
minScalar: 0
maxCurve:
serializedVersion: 2
@@ -9840,7 +9840,7 @@ ParticleSystem:
startLifetime:
serializedVersion: 2
minMaxState: 0
scalar: 0.355
scalar: 0.4
minScalar: 5
maxCurve:
serializedVersion: 2
@@ -14641,7 +14641,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4849499681526862356}
serializedVersion: 2
m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
@@ -14655,7 +14655,7 @@ Transform:
- {fileID: 5381404926944729450}
- {fileID: 5689587104162002440}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!198 &547135593973638648
ParticleSystem:
m_ObjectHideFlags: 0
@@ -19484,7 +19484,7 @@ Transform:
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 3864086195955648519}
@@ -20823,25 +20823,25 @@ ParticleSystem:
maxGradient:
serializedVersion: 2
key0: {r: 1, g: 1, b: 1, a: 1}
key1: {r: 1, g: 1, b: 1, a: 0}
key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0}
key1: {r: 1, g: 1, b: 1, a: 1}
key2: {r: 1, g: 1, b: 1, a: 0.7619142}
key3: {r: 1, g: 1, b: 1, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
key5: {r: 0, g: 0, b: 0, a: 0}
key6: {r: 0, g: 0, b: 0, a: 0}
key7: {r: 0, g: 0, b: 0, a: 0}
ctime0: 0
ctime1: 65535
ctime2: 0
ctime3: 0
ctime2: 65535
ctime3: 65535
ctime4: 0
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime1: 65535
atime2: 0
atime3: 0
atime1: 25058
atime2: 34695
atime3: 65535
atime4: 0
atime5: 0
atime6: 0
@@ -20849,7 +20849,7 @@ ParticleSystem:
m_Mode: 0
m_ColorSpace: 0
m_NumColorKeys: 2
m_NumAlphaKeys: 2
m_NumAlphaKeys: 4
minGradient:
serializedVersion: 2
key0: {r: 1, g: 1, b: 1, a: 1}
@@ -24375,7 +24375,7 @@ Transform:
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 3864086195955648519}
@@ -25714,25 +25714,25 @@ ParticleSystem:
maxGradient:
serializedVersion: 2
key0: {r: 1, g: 1, b: 1, a: 1}
key1: {r: 1, g: 1, b: 1, a: 0}
key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0}
key1: {r: 1, g: 1, b: 1, a: 1}
key2: {r: 1, g: 1, b: 1, a: 0.7619142}
key3: {r: 1, g: 1, b: 1, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
key5: {r: 0, g: 0, b: 0, a: 0}
key6: {r: 0, g: 0, b: 0, a: 0}
key7: {r: 0, g: 0, b: 0, a: 0}
ctime0: 0
ctime1: 65535
ctime2: 0
ctime3: 0
ctime2: 65535
ctime3: 65535
ctime4: 0
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime1: 65535
atime2: 0
atime3: 0
atime1: 25058
atime2: 34695
atime3: 65535
atime4: 0
atime5: 0
atime6: 0
@@ -25740,7 +25740,7 @@ ParticleSystem:
m_Mode: 0
m_ColorSpace: 0
m_NumColorKeys: 2
m_NumAlphaKeys: 2
m_NumAlphaKeys: 4
minGradient:
serializedVersion: 2
key0: {r: 1, g: 1, b: 1, a: 1}
@@ -29266,7 +29266,7 @@ Transform:
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
m_LocalScale: {x: 0.33, y: 0.33, z: 0.33}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 3864086195955648519}
@@ -34099,7 +34099,7 @@ Transform:
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 3864086195955648519}
@@ -35438,25 +35438,25 @@ ParticleSystem:
maxGradient:
serializedVersion: 2
key0: {r: 1, g: 1, b: 1, a: 1}
key1: {r: 1, g: 1, b: 1, a: 0}
key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0}
key1: {r: 1, g: 1, b: 1, a: 1}
key2: {r: 1, g: 1, b: 1, a: 0.7619142}
key3: {r: 1, g: 1, b: 1, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
key5: {r: 0, g: 0, b: 0, a: 0}
key6: {r: 0, g: 0, b: 0, a: 0}
key7: {r: 0, g: 0, b: 0, a: 0}
ctime0: 0
ctime1: 65535
ctime2: 0
ctime3: 0
ctime2: 65535
ctime3: 65535
ctime4: 0
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime1: 65535
atime2: 0
atime3: 0
atime1: 25058
atime2: 34695
atime3: 65535
atime4: 0
atime5: 0
atime6: 0
@@ -35464,7 +35464,7 @@ ParticleSystem:
m_Mode: 0
m_ColorSpace: 0
m_NumColorKeys: 2
m_NumAlphaKeys: 2
m_NumAlphaKeys: 4
minGradient:
serializedVersion: 2
key0: {r: 1, g: 1, b: 1, a: 1}
@@ -38990,7 +38990,7 @@ Transform:
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 3864086195955648519}
@@ -40329,25 +40329,25 @@ ParticleSystem:
maxGradient:
serializedVersion: 2
key0: {r: 1, g: 1, b: 1, a: 1}
key1: {r: 1, g: 1, b: 1, a: 0}
key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0}
key1: {r: 1, g: 1, b: 1, a: 1}
key2: {r: 1, g: 1, b: 1, a: 0.7619142}
key3: {r: 1, g: 1, b: 1, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
key5: {r: 0, g: 0, b: 0, a: 0}
key6: {r: 0, g: 0, b: 0, a: 0}
key7: {r: 0, g: 0, b: 0, a: 0}
ctime0: 0
ctime1: 65535
ctime2: 0
ctime3: 0
ctime2: 65535
ctime3: 65535
ctime4: 0
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime1: 65535
atime2: 0
atime3: 0
atime1: 25058
atime2: 34695
atime3: 65535
atime4: 0
atime5: 0
atime6: 0
@@ -40355,7 +40355,7 @@ ParticleSystem:
m_Mode: 0
m_ColorSpace: 0
m_NumColorKeys: 2
m_NumAlphaKeys: 2
m_NumAlphaKeys: 4
minGradient:
serializedVersion: 2
key0: {r: 1, g: 1, b: 1, a: 1}
@@ -67,7 +67,6 @@ namespace BrewMonster.Scripts
public override bool Tick(float dwDeltaTime)
{
base.Tick(dwDeltaTime * 1000);
//BMLogger.Log($" m_OverTimeCnt m_dwCounter:{m_OverTimeCnt.m_dwCounter}, m_dwPeriod:{m_OverTimeCnt.m_dwPeriod} ");
if (m_OverTimeCnt.IncCounter(dwDeltaTime * 1000,out float fCounter,out float fPeriod))
{
m_bFinished = true;
+104 -116
View File
@@ -1,4 +1,4 @@
using BrewMonster.Managers;
using BrewMonster.Managers;
using BrewMonster.Network;
using BrewMonster.PerfectWorld.Scripts.Vfx;
using BrewMonster.Scripts;
@@ -1688,20 +1688,20 @@ namespace BrewMonster
}
// melee attack
CECAttackEvent pAttack1 = CECAttacksMan.Instance.AddMeleeAttack(
CECAttackEvent pAttack = CECAttacksMan.Instance.AddMeleeAttack(
GetPlayerInfo().cid, idTarget, idWeapon, dwModifier, nDamage, nTimeFly);
if (pAttack1 != null)
if (pAttack != null)
{
if (!IsDead() && (dwModifier & (uint)MOD.MOD_RETORT) == 0
&& (dwModifier & (uint)MOD.MOD_ATTACK_AURA) == 0
&& PlayAttackAction(nAttackSpeed, ref piAttackTime, pAttack1)
&& PlayAttackAction(nAttackSpeed, ref piAttackTime, pAttack)
&& (dwModifier & (uint)MOD.MOD_BEAT_BACK) == 0)
{
}
else
{
pAttack1.m_bSignaled = true;
pAttack.m_bSignaled = true;
}
}
}
@@ -1721,11 +1721,11 @@ namespace BrewMonster
CECAttackerEvents attackerEvents = CECAttacksMan.Instance.FindAttackByAttacker(GetPlayerInfo().cid);
if (attackerEvents)
{
CECAttackEvent pAttack1 = attackerEvents.Find(idSkill, nSection);
if (pAttack1 != null)
pAttack = attackerEvents.Find(idSkill, nSection);
if (pAttack != null)
{
// Ãæ¹¥»÷µÄ·ÇµÚÒ»´ÎÉ˺¦ÏûÏ¢
pAttack1.AddTarget(idTarget, dwModifier, nDamage);
pAttack.AddTarget(idTarget, dwModifier, nDamage);
goto EXIT;
}
else
@@ -1755,7 +1755,6 @@ namespace BrewMonster
&& PlaySkillAttackAction(idSkill, nAttackSpeed, ref unusedInt, nSection, pAttack)
&& (dwModifier & (uint)MOD.MOD_BEAT_BACK) == 0)
{
pAttack.m_bSignaled = true;
}
else
{
@@ -1805,38 +1804,30 @@ namespace BrewMonster
// ==============================
if (GetMoveEnv() == (int)MoveEnvironment.MOVEENV_GROUND)
{
string szActRise = EC_Utility.BuildActionName(action, weapon_type, "起");
string szActFall = EC_Utility.BuildActionName(action, weapon_type, "落");
nTime1 = m_pPlayerCECModel.GetComActTimeSpanByName(szActRise);
nTime2 = m_pPlayerCECModel.GetComActTimeSpanByName(szActFall);
// 调整动画速度以匹配攻击速度 / Adjust animation speed to match attack speed
if (nAttackSpeed > 0)
{
float vScale = (nTime1 + nTime2) / (float)nAttackSpeed;
if (vScale > 0f)
m_pPlayerCECModel.SetPlaySpeed(vScale);
}
// “起? 动作(挥起)
szAct = EC_Utility.BuildActionName(action, weapon_type, "起");
int iTransTime = 200;
m_pActionController.PlayNonSkillActionWithName(iAction, szAct, true, iTransTime, bHideFX, attackEvent,COMACT_FLAG_MODE_ONCE_MULTIIGNOREGFX);
//swing sfx
//workaround for sound effect delay, it need to trigger via weapon combine action
SFXManager.Instance.PlaySkillSfxAtPointAsync(soundPath, Vector3.zero,iTransTime/1000f).Forget();
m_pActionController.PlayNonSkillActionWithName(iAction, szActRise, true, iTransTime, bHideFX, attackEvent, COMACT_FLAG_MODE_ONCE_MULTIIGNOREGFX);
// if (pRightHandWeapon != null && IsUsingMagicWeapon())
// pRightHandWeapon.PlayActionByName(_GenWeaponActionName(szActRise, m_iGender), 1.0f, true, iTransTime, true, iAction, bHideFX);
SFXManager.Instance.PlaySkillSfxAtPointAsync(soundPath, Vector3.zero, iTransTime / 1000f).Forget();
szAct = EC_Utility.BuildActionName(action, weapon_type, "落");
m_pActionController.QueueNonSkillActionWithName(iAction, szAct, 0, false, bHideFX);
//hit sfx
//workaround for sound effect delay, it need to trigger via weapon combine action
//.1f is a magic number to make sure the sound effect is triggered after the action is finished
SFXManager.Instance.PlaySkillSfxAtPointAsync(hitSoundPath, Vector3.zero,iTransTime/1000f+.1f).Forget();
//PlayNonSkillActionWithName(iAction, szAct, true, 200, true, ref pActFlag, COMACT_FLAG_MODE_ONCE_MULTIIGNOREGFX);gagága
/*
if (pRightHandWeapon != null && IsUsingMagicWeapon())
pRightHandWeapon.PlayActionByName(_GenWeaponActionName(szAct, m_iGender), 1.0f, true, 200, true, iAction, bHideFX);
nTime1 = _pPlayerModel.GetComActTimeSpanByName(szAct);
// “收” 动作(挥下)
szAct = $"{action.data.action_prefix}_{action.data.action_weapon_suffix[weapon_type].suffix}Âä";
QueueNonSkillActionWithName(iAction, szAct, 0, false, bHideFX);
if (pRightHandWeapon != null && IsUsingMagicWeapon())
pRightHandWeapon.QueueAction(_GenWeaponActionName(szAct, m_iGender), 0, iAction, false, false, bHideFX);
nTime2 = _pPlayerModel.GetComActTimeSpanByName(szAct);*/
m_pActionController.QueueNonSkillActionWithName(iAction, szActFall, 0, false, bHideFX);
// if (pRightHandWeapon != null && IsUsingMagicWeapon())
// pRightHandWeapon.QueueAction(_GenWeaponActionName(szActFall, m_iGender), 0, iAction, false, false, bHideFX);
SFXManager.Instance.PlaySkillSfxAtPointAsync(hitSoundPath, Vector3.zero, iTransTime / 1000f + .1f).Forget();
}
// ==============================
// Air Attack
@@ -1851,59 +1842,49 @@ namespace BrewMonster
GetProfession() == (int)PROFESSION.PROF_MONK ||
GetProfession() == (int)PROFESSION.PROF_GHOST)
{
szActionMiddleName = "空中翅膀"; // tấn công trên không
szActionMiddleName = "空中翅膀"; // Air with wings / 空中翅膀
}
else
{
szActionMiddleName = "空中飞剑"; // rơi xuống hoặc bay
szActionMiddleName = "空中飞剑"; // Air with sword / 空中飞剑
}
szAct = EC_Utility.BuildActionName(action, weapon_type, "起", szActionMiddleName);
//EventBus.PublishChannel(m_PlayerInfo.cid, new PlayActionEvent(szShapeName, szAct, 200, true));
m_pActionController.PlayNonSkillActionWithName(iAction, szAct, true, 200);
string szActRiseAir = EC_Utility.BuildActionName(action, weapon_type, "起", szActionMiddleName);
string szActFallAir = EC_Utility.BuildActionName(action, weapon_type, "落", szActionMiddleName);
nTime1 = m_pPlayerCECModel.GetComActTimeSpanByName(szActRiseAir);
nTime2 = m_pPlayerCECModel.GetComActTimeSpanByName(szActFallAir);
// 调整动画速度以匹配攻击速度 / Adjust animation speed to match attack speed
if (nAttackSpeed > 0)
{
float vScale = (nTime1 + nTime2) / (float)nAttackSpeed;
if (vScale > 0f)
m_pPlayerCECModel.SetPlaySpeed(vScale);
}
m_pActionController.PlayNonSkillActionWithName(iAction, szActRiseAir, true, 200);
// if (pRightHandWeapon != null && IsUsingMagicWeapon())
// pRightHandWeapon.PlayActionByName(_GenWeaponActionName(szAct, m_iGender), 1.0f, true, 200, true, iAction, bHideFX);
// nTime1 = m_pPlayerModel.GetComActTimeSpanByName(szAct);
szAct = EC_Utility.BuildActionName(action, weapon_type, "落", szActionMiddleName);
//EventBus.PublishChannelClass(m_PlayerInfo.cid, queueActionEvent);
m_pActionController.QueueNonSkillActionWithName(iAction, szAct, 0, false, false, true, false);
// pRightHandWeapon.PlayActionByName(_GenWeaponActionName(szActRiseAir, m_iGender), 1.0f, true, 200, true, iAction, bHideFX);
m_pActionController.QueueNonSkillActionWithName(iAction, szActFallAir, 0, false, false, true, false);
// if (pRightHandWeapon != null && IsUsingMagicWeapon())
// pRightHandWeapon.QueueAction(_GenWeaponActionName(szAct, m_iGender), 0, iAction, false, false, bHideFX);
// nTime2 = m_pPlayerModel.GetComActTimeSpanByName(szAct);
// pRightHandWeapon.QueueAction(_GenWeaponActionName(szActFallAir, m_iGender), 0, iAction, false, false, bHideFX);
}
// ==============================
// Kết thúc bằng FightStand
// Queue FightStand / 结束动作
// ==============================
PLAYER_ACTION stand_action = m_PlayerActions[(int)PLAYER_ACTION_TYPE.ACT_FIGHTSTAND];
szAct = EC_Utility.BuildActionName(stand_action, 0);
int iTranstime = 300;
m_pActionController.QueueNonSkillActionWithName(iAction, szAct, iTranstime, false, false, true, false);
/* QueueNonSkillActionWithName(ACT_FIGHTSTAND, szAct, 300, false, bHideFX, true);
m_pActionController.QueueNonSkillActionWithName(iAction, szAct, 300, false, false, true, false);
// if (pRightHandWeapon != null && IsUsingMagicWeapon())
// pRightHandWeapon.QueueAction(_GenWeaponActionName(szAct, m_iGender), 300, iAction, false, false, bHideFX, true);
if (pRightHandWeapon != null && IsUsingMagicWeapon())
pRightHandWeapon.QueueAction(_GenWeaponActionName(szAct, m_iGender), 300, iAction, false, false, bHideFX, true);*/
// if (pRightHandWeapon != null && IsUsingMagicWeapon())
// pRightHandWeapon.SetPlaySpeed(vScale);
// ==============================
// Điều chỉnh tốc độ phát animation theo tốc độ tấn công
// ==============================
/* if (nAttackSpeed > 0)
{
float vScale = (nTime1 + nTime2) / (float)nAttackSpeed;
if (vScale > 0f)
{
m_pPlayerModel.SetPlaySpeed(vScale);
if (pRightHandWeapon != null && IsUsingMagicWeapon())
pRightHandWeapon.SetPlaySpeed(vScale);
}
}
attackTime = nTime1 + nTime2;*/
attackTime = nTime1 + nTime2;
// ==============================
// Cập nhật vị trí weapon hanger (vũ khí)
@@ -2601,29 +2582,38 @@ namespace BrewMonster
var atkMan = CECAttacksMan.Instance;
// int nExecuteTime = GNET::ElementSkill::GetExecuteTime(idSkill, 0); // 获取技能执行时间 / Get skill execute time
int nExecuteTime = ElementSkill.GetExecuteTime((uint)idSkill, 0); // 临时值 / Temporary value
if (GetMoveEnv() == (int)MoveEnvironment.MOVEENV_GROUND)
{
szAct = EC_Utility.BuildActionName(data, weapon_type, "_施放起_");
GetSkillSectionActionName(ref szAct, idSkill, nSection);
nTime1 = m_pPlayerCECModel.GetComActTimeSpanByName(szAct); // 获取动作时长 / Get action time span
var pAct = m_pPlayerCECModel.GetComActByName(szAct);
if (pAct!=null) bInfinite |= pAct.IsLooping();
string szAct2 = EC_Utility.BuildActionName(data, weapon_type, "_施放落_");
GetSkillSectionActionName(ref szAct2, idSkill, nSection);
nTime2 = m_pPlayerCECModel.GetComActTimeSpanByName(szAct2);
pAct = m_pPlayerCECModel.GetComActByName(szAct2);
if (pAct!=null) bInfinite |= pAct.IsLooping();
// 调整动画速度以匹配攻击速度 / Adjust animation speed to match attack speed
if (!bInfinite && nExecuteTime > 0)
{
float vScale = (nTime1 + nTime2) / (float)nExecuteTime;
if (vScale > 0)
{
m_pPlayerCECModel.SetPlaySpeed(vScale * 1.2f);
}
}
if (!PlaySkillAttackActionWithName(idSkill, szAct, bHideFX, attackEvent))
{
return false;
}
// nTime1 = m_pPlayerModel.GetComActTimeSpanByName(szAct); // 获取动作时长 / Get action time span
// pAct = m_pPlayerModel.GetComActByName(szAct);
// if (pAct) bInfinite |= pAct.IsInfinite();
nTime1 = 1000; // 临时值 / Temporary value
szAct = EC_Utility.BuildActionName(data, weapon_type, "_施放落_");
GetSkillSectionActionName(ref szAct, idSkill, nSection);
QueueSkillAttackActionWithName(idSkill, szAct, 0, bHideFX);
// nTime2 = m_pPlayerModel.GetComActTimeSpanByName(szAct);
// pAct = m_pPlayerModel.GetComActByName(szAct);
// if (pAct) bInfinite |= pAct.IsInfinite();
nTime2 = 1000; // 临时值 / Temporary value
QueueSkillAttackActionWithName(idSkill, szAct2, 0, bHideFX);
}
else
{
@@ -2645,6 +2635,25 @@ namespace BrewMonster
szActionMiddleName += "_施放起_";
szAct = EC_Utility.BuildActionName(data, weapon_type, szActionMiddleName);
GetSkillSectionActionName(ref szAct, idSkill, nSection);
nTime1 = m_pPlayerCECModel.GetComActTimeSpanByName(szAct);
var pAct = m_pPlayerCECModel.GetComActByName(szAct);
if (pAct!=null) bInfinite |= pAct.IsLooping();
string szAct2Air = $"{data.ActionPrefix}_{szActionMiddleName}_施法行_{data.action_weapon_suffix[weapon_type].Suffix}";
GetSkillSectionActionName(ref szAct2Air, idSkill, nSection);
nTime2 = m_pPlayerCECModel.GetComActTimeSpanByName(szAct2Air);
pAct = m_pPlayerCECModel.GetComActByName(szAct2Air);
if (pAct!=null) bInfinite |= pAct.IsLooping();
// 调整动画速度以匹配攻击速度 / Adjust animation speed to match attack speed
if (!bInfinite && nExecuteTime > 0)
{
float vScale = (nTime1 + nTime2) / (float)nExecuteTime;
if (vScale > 0)
{
m_pPlayerCECModel.SetPlaySpeed(vScale * 1.2f);
}
}
if (!PlaySkillAttackActionWithName(idSkill, szAct, bHideFX, attackEvent))
{
@@ -2654,39 +2663,15 @@ namespace BrewMonster
// if (pRightHandWeapon && IsUsingMagicWeapon())
// pRightHandWeapon.PlayActionByName(_GenWeaponActionName(szAct, m_iGender), 1.0f, true, 200, true, ACT_CASTSKILL, bHideFX);
// nTime1 = m_pPlayerModel.GetComActTimeSpanByName(szAct);
// pAct = m_pPlayerModel.GetComActByName(szAct);
// if (pAct) bInfinite |= pAct.IsInfinite();
nTime1 = 1000; // 临时值 / Temporary value
szAct = $"{data.ActionPrefix}_{szActionMiddleName}_施法行_{data.action_weapon_suffix[weapon_type].Suffix}";
GetSkillSectionActionName(ref szAct, idSkill, nSection);
QueueSkillAttackActionWithName(idSkill, szAct, 0, bHideFX);
QueueSkillAttackActionWithName(idSkill, szAct2Air, 0, bHideFX);
// if (pRightHandWeapon && IsUsingMagicWeapon())
// pRightHandWeapon.QueueAction(_GenWeaponActionName(szAct, m_iGender), 0, ACT_CASTSKILL, false, false, bHideFX);
// nTime2 = m_pPlayerModel.GetComActTimeSpanByName(szAct);
// pAct = m_pPlayerModel.GetComActByName(szAct);
// if (pAct) bInfinite |= pAct.IsInfinite();
nTime2 = 1000; // 临时值 / Temporary value
}
// int nExecuteTime = GNET::ElementSkill::GetExecuteTime(idSkill, 0); // 获取技能执行时间 / Get skill execute time
int nExecuteTime = 2000; // 临时值 / Temporary value
// 调整动画速度以匹配攻击速度 / Adjust animation speed to match attack speed
if (!bInfinite)
{
if (nExecuteTime > 0)
{
float vScale = (nTime1 + nTime2) / (float)nExecuteTime;
// m_pPlayerModel.SetPlaySpeed(vScale * 1.2f);
// if (pRightHandWeapon && IsUsingMagicWeapon())
// pRightHandWeapon.SetPlaySpeed(vScale * 1.2f);
}
piAttackTime = nTime1 + nTime2;
}
else
@@ -4091,7 +4076,8 @@ namespace BrewMonster
public bool IsLoop;
public CECAttackEvent AttackEvent;
public int Rank;
public PlayActionEvent(string animationName, int iTransTime, bool isForceStopPrevious = false, CECAttackEvent attackEvent = null, bool isLoop = false)
public float PlaySpeed;
public PlayActionEvent(string animationName, int iTransTime, bool isForceStopPrevious = false, CECAttackEvent attackEvent = null, bool isLoop = false, float playSpeed = 1.0f)
{
this.ChannelAct = null;
this.AnimationName = animationName;
@@ -4100,8 +4086,9 @@ namespace BrewMonster
AttackEvent = attackEvent;
IsLoop = isLoop;
Rank = 0;
PlaySpeed = playSpeed;
}
public PlayActionEvent(ref ChannelAct channelAct, string animationName, int iTransTime, bool isForceStopPrevious = false, CECAttackEvent attackEvent = null, bool isLoop = false, int rank = 0)
public PlayActionEvent(ref ChannelAct channelAct, string animationName, int iTransTime, bool isForceStopPrevious = false, CECAttackEvent attackEvent = null, bool isLoop = false, int rank = 0, float playSpeed = 1.0f)
{
this.ChannelAct = channelAct;
this.AnimationName = animationName;
@@ -4110,6 +4097,7 @@ namespace BrewMonster
AttackEvent = attackEvent;
IsLoop = isLoop;
Rank = rank;
PlaySpeed = playSpeed;
}
}
public struct PLAYER_ACTION
+39 -26
View File
@@ -359,7 +359,7 @@ public class A3DCombActDynData
// if (!m_bNoFx)
// TriggerSFxFromEventList();
Resume();
UpdateAct(0);
UpdateAct(0, m_pECModel.GetPlaySpeed());
if(true /*!m_bNoFx*/)
{
LoadFXFromEventList();
@@ -499,6 +499,13 @@ public class A3DCombActDynData
public void Stop(bool bStopAct, bool bForceStopFx = false )
{
RemoveAllActiveFx();
if (ActiveAttackEvent != null)
{
Debug.Log($"[Nam Debug]Stop: ActiveAttackEvent.m_bSignaled = true, Action name: {m_pAct.m_strName}");
ActiveAttackEvent.m_bSignaled = true;
}
// FlushDamageInfo();
// ClearParentInfo();
@@ -530,11 +537,9 @@ public class A3DCombActDynData
// if (pChannel)
// pChannel->StopAction(m_pAct->GetRank(m_nChannel));
}
public void UpdateAct(uint dwDeltaTime)
public void UpdateAct(uint dwDeltaTime, float fPlaySpeed = 1f)
{
m_dwTimeSpan += (int)dwDeltaTime;
if (m_pECModel.IsActionStopped())
return;
if(true/*!m_bNoFx*/)
UpdateEvent((uint)m_dwTimeSpan, 0);
@@ -581,7 +586,7 @@ public class A3DCombActDynData
{
m_nCurActLoop = 0;
m_nCurActIndex++;
EventBus.PublishChannel(m_pECModel.GetId(), new PlayActionEvent( pNext.m_strName, m_nTransTime, false, ActiveAttackEvent, pNext.CalcLoopNum()==-1 && pNext.GetTimeSpan() > 10));
EventBus.PublishChannel(m_pECModel.GetId(), new PlayActionEvent( pNext.m_strName, m_nTransTime, false, null, pNext.CalcLoopNum()==-1 && pNext.GetTimeSpan() > 10, fPlaySpeed));
}
}
}
@@ -629,19 +634,7 @@ public class A3DCombActDynData
}
public bool IsActionStopped()
{
if(m_pAct.IsLooping())
{
return false;
}
if(m_nCurLoop >= m_pAct.m_nLoops)
{
return true;
}
if(m_pAct.m_ActLst.Count == 0)
{
return true;
}
return false;
return m_pAct.m_ActLst.Count == 0 || (m_pAct.m_nLoops != -1 && m_nCurLoop >= m_pAct.m_nLoops);
}
void LoopCurAct(ACTION_INFO pCur, uint dwDeltaTime)
{
@@ -650,7 +643,6 @@ public class A3DCombActDynData
void LoopNext(uint dwDeltaTime)
{
m_nCurLoop++;
if (!IsActionStopped())
{
RemoveAllActiveFx();
@@ -1118,6 +1110,7 @@ public class CECModel
private Transform m_transform;
private bool m_bAbsTrack = false;
private bool m_bFirstActPlayed = false;
private float m_fPlaySpeed = 1.0f;
public bool InheritParentId() => m_bInheritParentId;
public void SetId(int nId) => m_nId = nId;
public int GetId() => m_nId;
@@ -1507,13 +1500,34 @@ public class CECModel
return m_pMapModel.m_ActionMap.TryGetValue(szActName, out A3DCombinedAction combinedAction) ? combinedAction : null;
}
//Final trigger function
public int GetComActTimeSpanByName(string szActName)
{
A3DCombinedAction combinedAction = GetComActByName(szActName);
if (combinedAction == null || combinedAction.m_ActLst == null || combinedAction.m_ActLst.Count == 0)
return 0;
int totalMs = 0;
foreach (var actInfo in combinedAction.m_ActLst)
{
if (actInfo == null || string.IsNullOrEmpty(actInfo.m_strName))
continue;
AnimationClip clip = GetAnimationClip(actInfo.m_strName);
if (clip != null)
totalMs += Mathf.Max(1, Mathf.RoundToInt(clip.length * 1000f));
}
return totalMs;
}
public void SetPlaySpeed(float vScale)
{
m_fPlaySpeed = vScale;
}
public float GetPlaySpeed() => m_fPlaySpeed;
public bool QueueAction(int nChannel, string szActName, int nTransTime, uint dwUserData, bool bForceStopPrevAct, bool bCheckTailDup, bool bNoFx, bool bResetSpeed, bool bResetActFlag, CECAttackEvent attackEvent=null, uint dwNewFlagMode=0){
if(szActName == null || szActName == string.Empty)
{
return false;
}
A3DCombinedAction pComAct = GetComActByName(szActName);
if (pComAct == null)
return false;
@@ -1586,7 +1600,7 @@ public class CECModel
}
public bool Tick(uint dwDeltaTime)
{
UpdateChannelActs(dwDeltaTime);
UpdateChannelActs((uint)(dwDeltaTime * m_fPlaySpeed));
return true;
}
void UpdateChannelActs(uint dwUpdateTime)
@@ -1606,13 +1620,11 @@ public class CECModel
bActFinished = node.m_pActive.IsActionStopped();
else
bActFinished = node.m_pActive.IsActionStopped();
if (bActFinished)
{
if (node.m_dwFlagMode != COMACT_FLAG_MODE_NONE && node.m_pActFlag)
{
node.m_pActFlag = true;
if (node.m_dwFlagMode != COMACT_FLAG_MODE_ONCE_MULTIIGNOREGFX)
node.m_dwFlagMode = (int)COMACT_FLAG_MODE_NONE;
@@ -1621,14 +1633,15 @@ public class CECModel
if (node.m_QueuedActs.Count > 0)
{
A3DCombActDynData pNext = node.m_QueuedActs[0];
if (pNext.GetStopPrevAct())
{
node.m_pActive.Stop(true);
//StopChildrenAct();
}
else
{
node.m_pActive.Stop(false);
}
// script
//m_pMapModel->OnScriptPlayAction(this, i, pNext->GetComAct()->GetName());
@@ -1641,7 +1654,7 @@ public class CECModel
node.m_pActive = null;
node.m_pActive = pNext;
node.m_pActive.Play(i, 1f, node.m_pActive.GetTransTime(), 0/**m_EventMasks[i]*/, true, m_bAbsTrack, pNext.GetNoFxFlag());
//pNext.UpdateAct(dwUpdateTime);
pNext.UpdateAct(dwUpdateTime, m_fPlaySpeed);
node.m_QueuedActs.RemoveAt(0);
m_bAbsTrack = false;
}
@@ -1653,7 +1666,7 @@ public class CECModel
}
else
{
node.m_pActive.UpdateAct(dwUpdateTime);
node.m_pActive.UpdateAct(dwUpdateTime, m_fPlaySpeed);
}
}
}
@@ -303,7 +303,7 @@ namespace BrewMonster
}
int iTransTime = 0;
EventBus.PublishChannel(m_pPlayer.GetPlayerInfo().cid, new PlayActionEvent(szActName,iTransTime));
//EventBus.PublishChannel(m_pPlayer.GetPlayerInfo().cid, new PlayActionEvent(szActName,iTransTime));
return true;
}
+12 -77
View File
@@ -1,4 +1,3 @@
using System;
using Animancer;
using BrewMonster;
using System.Collections.Generic;
@@ -12,10 +11,10 @@ namespace BrewMonster
public string AnimationName;
public bool IsForceStopPrevious;
public int ITransTime;
public CECAttackEvent AttackEvent;
public bool IsLoop;
public ChannelAct ChannelAct;
public int Rank;
public float PlaySpeed;
}
public class PlayerVisual : MonoBehaviour
{
@@ -26,7 +25,6 @@ namespace BrewMonster
[SerializeField] private AnimancerState _currentState;
[SerializeField] private Queue<AnimationQueue> _animationQueue = new Queue<AnimationQueue>();
[SerializeField] private List<string> _animationList = new List<string>();
[SerializeField] private bool isHit;
[SerializeField] private int id;
[SerializeField] private bool isDebug;
[SerializeField] private bool debugNamePlateBounds;
@@ -34,7 +32,6 @@ namespace BrewMonster
private const float FadeTime = 100;
private const FadeMode FadeMode = Animancer.FadeMode.FixedDuration;
QueueActionEvent queueActionEvent;
private string previousAnimationName;
private void PlayActionEventHandler(PlayActionEvent @event)
{
@@ -56,24 +53,25 @@ namespace BrewMonster
{
AnimationName = @event.AnimationName,
IsForceStopPrevious = @event.IsForceStopPrevious,
AttackEvent = @event.AttackEvent,
ITransTime = @event.ITransTime,
ChannelAct = @event.ChannelAct,
Rank = @event.Rank
Rank = @event.Rank,
PlaySpeed = @event.PlaySpeed
});
_animationList = _animationQueue.Select(q => q.AnimationName).ToList();
return;
}
}
previousAnimationName = @event.AnimationName;
InternalPlayAnimation(@event.AnimationName, @event.ITransTime, FadeMode);
ApplyAnimationEndCallbacks(@event.AttackEvent, @event.ChannelAct, @event.Rank, @event.AnimationName, @event.IsLoop);
InternalPlayAnimation(@event.AnimationName, @event.ITransTime, FadeMode, @event.PlaySpeed);
ApplyAnimationEndCallbacks(@event.AnimationName, @event.IsLoop);
}
public void InitPlayerEventDoneHandler()
{
namedAnimancer = GetComponentInChildren<NamedAnimancerComponent>();
if (namedAnimancer == null)
{
BrewMonster.BMLogger.LogWarning("InitPlayerEventDoneHandler animancer == null");
BMLogger.LogWarning("InitPlayerEventDoneHandler animancer == null");
return;
}
var player = GetComponentInParent<CECPlayer>();
@@ -89,7 +87,6 @@ namespace BrewMonster
_playerInfo = player.GetPlayInfo();
id = _playerInfo.cid;
EventBus.SubscribeChannel<PlayActionEvent>(_playerInfo.cid, PlayActionEventHandler);
EventBus.SubscribeChannelClass<QueueActionEvent>(_playerInfo.cid, QueueActionEventHandler);
EventBus.SubscribeChannel<ClearComActFlagAllRankNodesEvent>(_playerInfo.cid, ClearComActFlagAllRankNodesEventHandler);
_eventBusSubscribed = true;
}
@@ -102,7 +99,6 @@ namespace BrewMonster
if (!_eventBusSubscribed)
return;
EventBus.UnsubscribeChannel<PlayActionEvent>(_playerInfo.cid, PlayActionEventHandler);
EventBus.UnsubscribeChannelClass<QueueActionEvent>(_playerInfo.cid, QueueActionEventHandler);
EventBus.UnsubscribeChannel<ClearComActFlagAllRankNodesEvent>(_playerInfo.cid, ClearComActFlagAllRankNodesEventHandler);
_eventBusSubscribed = false;
}
@@ -131,54 +127,14 @@ namespace BrewMonster
{
_animationQueue.Clear();
_animationList = _animationQueue.Select(q => q.AnimationName).ToList();
if (isHit)
{
ApplyDamage();
}
//todo: this is dummy to force change to idle state
// EventBus.PublishChannel(_playerInfo.cid, new PlayActionEvent("站立_通用"));
}
private void QueueActionEventHandler(QueueActionEvent @event)
{
if (!EnqueueAnimation(@event))
{
BMLogger.LogError("HoangDev : EnqueueAnimation Failed");
}
}
private void Update()
{
PlayNext();
}
public bool EnqueueAnimation(QueueActionEvent @event)
{
if (namedAnimancer == null)
{
return false;
}
if(previousAnimationName == @event.AnimationName)
{
return false;
}
previousAnimationName = @event.AnimationName;
_animationQueue.Enqueue(new AnimationQueue
{
AnimationName = @event.AnimationName,
IsForceStopPrevious = @event.IsForceStopPrevious,
ITransTime = @event.ITransTime,
AttackEvent = @event.AttackEvent,
IsLoop = @event.IsLoop,
ChannelAct = @event.ChannelAct,
Rank = @event.Rank
});
_animationList = _animationQueue.Select(q => q.AnimationName).ToList();
if (!isHit)
{
queueActionEvent = @event;
isHit = @event.IsHitAnim;
}
return true;
}
/// <summary>
/// This function is used to enqueue an animation for looping when the animancer is not set to looping
/// </summary>
@@ -199,7 +155,6 @@ namespace BrewMonster
{
AnimationName = animationName,
IsForceStopPrevious = false,
AttackEvent = null,
IsLoop = true
});
_animationList = _animationQueue.Select(q => q.AnimationName).ToList();
@@ -219,45 +174,24 @@ namespace BrewMonster
_currentState = null;
}
if (_currentState != null && _currentState.NormalizedTime < 1f) return;
if (isHit)// have it relative to check _currentState == null?
{
ApplyDamage();
}
var animationQueue = _animationQueue.Dequeue();
_animationList = _animationQueue.Select(q => q.AnimationName).ToList();
previousAnimationName = animationQueue.AnimationName;
InternalPlayAnimation(animationQueue.AnimationName, animationQueue.ITransTime, FadeMode);
ApplyAnimationEndCallbacks(animationQueue.AttackEvent, animationQueue.ChannelAct, animationQueue.Rank, animationQueue.AnimationName,animationQueue.IsLoop);
InternalPlayAnimation(animationQueue.AnimationName, animationQueue.ITransTime, FadeMode, animationQueue.PlaySpeed);
ApplyAnimationEndCallbacks(animationQueue.AnimationName, animationQueue.IsLoop);
}
private void ApplyAnimationEndCallbacks(CECAttackEvent attackEvent, ChannelAct channelAct, int rank, string animationName, bool isLoop)
private void ApplyAnimationEndCallbacks( string animationName, bool isLoop)
{
if (_currentState == null) return;
_currentState.Events.OnEnd = () =>
{
if (attackEvent != null)
attackEvent.m_bSignaled = true;
if(isLoop)
{
EnqueueAnimationForLooping(animationName);
}
if (channelAct == null || string.IsNullOrEmpty(animationName))
return;
var node = channelAct.GetNodeByRank((byte)rank);
node?.m_pActive?.m_ActionNames?.Remove(animationName);
};
}
void ApplyDamage()
{
if (queueActionEvent == null)
{
return;
}
isHit = false;
queueActionEvent.SetFlag(true, queueActionEvent.AttackEvent);
queueActionEvent = null;
}
private void OnDestroy()
{
UnregisterPlayerEventHandlers();
@@ -281,7 +215,7 @@ namespace BrewMonster
/// <param name="animationName"></param>
/// <param name="duration"></param>
/// <param name="fadeMode"></param>
private void InternalPlayAnimation(string animationName, float duration = FadeTime, FadeMode fadeMode = FadeMode)
private void InternalPlayAnimation(string animationName, float duration = FadeTime, FadeMode fadeMode = FadeMode, float playSpeed = 1.0f)
{
if (namedAnimancer == null)
{
@@ -292,6 +226,7 @@ namespace BrewMonster
{
_currentState = namedAnimancer.TryPlay(animationName, duration / 1000, fadeMode);
_currentState.Time = 0;
_currentState.Speed = playSpeed > 0f ? playSpeed : 1.0f;
_currentAnimationName = animationName;
return;
}