using UnityEngine; namespace BrewMonster { /// /// Accelerated movement (starts slow, accelerates). /// Mirrors C++ CGfxAccMove exactly (A3DSkillGfxEvent2.cpp:267-295). /// 加速移动(从慢速开始,逐渐加速),完全镜像C++ CGfxAccMove。 /// public class CGfxAccMove : CGfxMoveBase { protected float m_fAcc; protected float m_fSpeed; public CGfxAccMove(GfxMoveMode mode) : base(mode) { m_fAcc = 1.0f; // default acceleration, same as C++ } /// /// Initialize accelerated movement from host to target. /// 初始化从施法者到目标的加速移动。 /// public override void StartMove(Vector3 vHost, Vector3 vTarget) { m_fSpeed = 0; if (m_bArea) { CalcRange((vTarget - vHost).normalized); m_vPos = vHost + GetRandOff(); } else { m_vPos = vHost; } Vector3 vDir = vTarget - m_vPos; m_vMoveDir = vDir.normalized; } /// /// Tick accelerated movement. Returns true when target is hit. /// 更新加速移动。当命中目标时返回true。 /// public override bool TickMove(uint dwDeltaTime, Vector3 vHostPos, Vector3 vTargetPos) { float fDelta = dwDeltaTime / 1000.0f; Vector3 vFlyDir = vTargetPos - m_vPos; float fDist = Normalize(ref vFlyDir); float fVEnd = m_fSpeed + m_fAcc * fDelta; float fFlyDist = (m_fSpeed + fVEnd) * fDelta * 0.5f; m_fSpeed = fVEnd; if (fFlyDist >= fDist) { return true; // target hit / 命中目标 } m_vPos += vFlyDir * fFlyDist; m_vMoveDir = vFlyDir; return false; } /// /// Override to also read acceleration from param value. /// 重写以从参数值中读取加速度。 /// public override void SetParam(GFX_SKILL_PARAM param) { base.SetParam(param); m_fAcc = param.value.fVal; // C# union access: param.value.fVal } } }