static MiroV1BlackDotBase GetNearestBlackDot( MiroV1BulletEmitterBase em, List <MiroV1BlackDotBase> dots) { MiroV1BlackDotBase nearestBD = null; float distMin = 1000000.0f; foreach (MiroV1BlackDotBase bd in dots) { if (bd == null) { continue; } Vector3 posBDot = bd.transform.position; Vector3 posEM = em.transform.position; Vector3 offset = posEM - posBDot; offset.z = 0.0f; float dist = offset.magnitude; if (dist < distMin) { distMin = dist; nearestBD = bd; } } return(nearestBD); }
public void DelinkEmitters() { if (_emitter != null) { _emitter.RmAbsorber(); _emitter = null; _EmitterDeLinked.Invoke(); } }
public void ConfigTargetBlackDotTFFor( MiroV1BulletEmitterBase em, List <int> keys, Dictionary <int, List <MiroV1BlackDotBase> > dicBkDots) { Transform tgt = null; bool IsEmitting = em.IsON(); if (!IsEmitting) { return; } for (int i = 0; i < keys.Count; i++) { int precd = keys [i]; List <MiroV1BlackDotBase> dots = dicBkDots [precd]; for (int j = dots.Count - 1; j >= 0; j--) { var dot = dots [j]; /* * if (dot.ContainAttacker (em)) { * em.SetTarget (dot.transform); * dot.AddAttacker (em); * return; * }*/ bool bAttackMax = dot.IsAttackerMax(); if (bAttackMax) { dots.RemoveAt(j); } } MiroV1BlackDotBase nearestBD = GetNearestBlackDot(em, dots); if (nearestBD != null) { tgt = nearestBD.transform; break; } } if (tgt == null) { tgt = transform; } em.SetTarget(tgt); MiroV1BlackDotBase bdot = tgt.GetComponent <MiroV1BlackDotBase> (); if (bdot != null) { bdot.AddAttacker(em); } }
public void SetModelSetting(MiroV1ModelSetting modelSetting) { _modelSetting = modelSetting; foreach (GameObject gb in _Plants) { MiroV1BulletEmitterBase em = gb.GetComponentInChildren <MiroV1BulletEmitterBase> (); em._modelSetting = modelSetting; } }
void RemoveSleepingEmitters() { for (int i = _ems.Count - 1; i >= 0; i--) { MiroV1BulletEmitterBase em = _ems [i]; if (!em.isActiveAndEnabled) { _ems.RemoveAt(i); } } }
public bool AddAttacker(MiroV1BulletEmitterBase em) { if (_attackers.Contains(em)) { return(true); } if (_attackers.Count >= _HPMax) { return(false); } _attackers.Add(em); return(true); }
public void RemoveAttacker(MiroV1BulletEmitterBase em) { _attackers.Remove(em); }
public bool ContainAttacker(MiroV1BulletEmitterBase em) { return(_attackers.Contains(em)); }
public void LinkEmitter(MiroV1BulletEmitterBase em) { _emitter = em; _emitter.SetAbsorber(this); }