Exemplo n.º 1
0
 void SpreadEvilGuys()
 {
     for (int i = 0; i < World.enemies.Count; ++i)
     {
         SC         sc      = World.enemies[i].GetComponent <SC>();
         GameObject nearest = World.GetNearestEnemy(sc);
         if (nearest != null)
         {
             SC    otherSc  = nearest.GetComponent <SC>();
             float distance = Vector3.Distance(sc.position, otherSc.position) - sc.radius - otherSc.radius;
             if (distance < 0)
             {
                 Vector3 direction = 0.125f * (otherSc.position - sc.position);
                 sc.position      -= direction;
                 otherSc.position += direction;
                 sc.Correct();
                 otherSc.Correct();
             }
         }
     }
 }