public void OnHitTarget() { FixedPoint m_minDis2 = new FixedPoint(999999); CCreature target = null; List <long> list = CCreatureMgr.GetCreatureList(); for (int i = 0; i < list.Count; i++) { CCreature creature = CCreatureMgr.Get(list[i]); if (m_listHited != null && m_listHited.Contains((int)list[i])) { continue; } if (m_caster == creature || m_caster.bCamp(creature) || creature.IsDie() || creature == m_rec) { continue; } FixedPoint abDis2 = FPCollide.GetDis2(m_rec.GetPos(), creature.GetPos()); if (abDis2 < new FixedPoint(m_triggerData.Length * m_triggerData.Length)) { if (abDis2 < m_minDis2) { target = creature; m_minDis2 = abDis2; } } } if (target != null) { if (m_listHited == null) { m_listHited = new List <int>(); } Debug.Log("添加单位:" + target.GetUid()); m_listHited.Add((int)target.GetUid()); OnHitAddBuff(m_caster, target, m_listHited); VTrigger vTri = GetVTrigger(); if (vTri != null && m_rec != null && m_rec.GetVObject() != null) { Vector3 sh = m_rec.GetVObject().GetHitHeight(); Vector3 th = target.GetVObject().GetHitHeight(); vTri.SetLineStartPos(GetPos().ToVector3() + sh); vTri.SetLineTargetPos(target.GetPos().ToVector3() + th); } } else { Destory(); } }
public override bool Create(int csvId, string name, Vector2d pos, Vector2d dir, float scale = 1) { base.Create(csvId, name, pos, dir, scale); VTrigger vTri = GetVTrigger(); if (vTri != null) { // 设置起始点为当前闪电原点 vTri.SetLineStartPos(vTri.m_baseInfo.m_pos); } return(true); }