Exemplo n.º 1
0
        void clearDeadFromNearbyEnemiesList()
        {
            List <PlayerControllerComponent> nearbyEnemiesToRemove = new List <PlayerControllerComponent>();

            for (int i = 0; i < nearbyEnemies.Count; i++)
            {
                PlayerControllerComponent pcc = nearbyEnemies[i];
                if (pcc.isDead())
                {
                    nearbyEnemiesToRemove.Add(pcc);
                }
            }
            nearbyEnemies.RemoveAll(item => nearbyEnemiesToRemove.Contains(item));
        }
Exemplo n.º 2
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         //TODO: check if enemy
         PlayerControllerComponent otherPcc = other.transform.GetComponent <PlayerControllerComponent>();
         if (otherPcc.isDead())
         {
             return;
         }
         if (!nearbyEnemies.Contains(otherPcc))
         {
             // add enemy to nearby list.
             nearbyEnemies.Add(otherPcc);
         }
     }
 }