Exemple #1
0
 private void OnCrystalCreated(EnemyCrystal crystal)
 {
     if (!crystals.Contains(crystal))
     {
         crystals.Add(crystal);
     }
 }
Exemple #2
0
 private void OnCrystalDestroyed(EnemyCrystal crystal)
 {
     if (crystals.Contains(crystal))
     {
         crystals.Remove(crystal);
     }
 }
Exemple #3
0
        public EnemyCrystal FindValidCrystal(Transform unitTransform)
        {
            EnemyCrystal c = null;
            float        closestDistance = 1000000;

            foreach (EnemyCrystal crystal in crystals)
            {
                if (!crystal.isTargeted)
                {
                    var distance = Vector2.Distance(unitTransform.position, crystal.transform.position);
                    if (distance < closestDistance)
                    {
                        closestDistance = distance;
                        c = crystal;
                    }
                }
            }
            return(c);
        }