using UnityEngine; namespace BrewMonster { /// /// Meteoric movement (falls from sky). /// Mirrors C++ CGfxMeteoricMove exactly (A3DSkillGfxEvent2.cpp:144-188). /// 流星移动(从天空坠落),完全镜像C++ CGfxMeteoricMove。 /// public class CGfxMeteoricMove : CGfxMoveBase { protected Vector3 m_vFallVel; protected float m_fRadius; private const float _fall_height = 10.0f; // fall height, same as C++ private const float _fall_speed = 8.0f; // fall speed (units per second), same as C++ public CGfxMeteoricMove(GfxMoveMode mode) : base(mode) { m_fRadius = 2.0f; // default radius, same as C++ } /// /// Initialize meteoric movement above target. /// 在目标上方初始化流星移动。 /// public override void StartMove(Vector3 vHost, Vector3 vTarget) { m_vPos = vTarget; m_vPos.y += _fall_height; if (m_bOneOfCluser) { float fRandAng = Random.value * Mathf.PI * 2f; float fRadius = Random.value * m_fRadius; m_vPos.x += Mathf.Cos(fRandAng) * fRadius; m_vPos.z += Mathf.Sin(fRandAng) * fRadius; } m_vMoveDir = -Vector3.up; m_vFallVel = _fall_speed * m_vMoveDir; } /// /// Tick meteoric movement. Returns true when hits ground. /// 更新流星移动。当撞击地面时返回true。 /// public override bool TickMove(uint dwDeltaTime, Vector3 vHostPos, Vector3 vTargetPos) { m_vPos += m_vFallVel * (dwDeltaTime / 1000.0f); return m_vPos.y <= vTargetPos.y; } /// /// Override to also read radius from param value. /// 重写以从参数值中读取半径。 /// public override void SetParam(GFX_SKILL_PARAM param) { base.SetParam(param); m_fRadius = param.value.fVal; // C# union access: param.value.fVal } } }