示例#1
0
 public static Units findClosestTarget(Vector3 cur_pos, List <Units> targets)
 {
     if (targets != null)
     {
         float num  = 1000f;
         int   num2 = -1;
         for (int i = 0; i < targets.Count; i++)
         {
             Units units = targets[i];
             if (units != null)
             {
                 float num3 = UnitFeature.DistanceToPointSqr(cur_pos, units.transform.position);
                 if (num3 < num)
                 {
                     num  = num3;
                     num2 = i;
                 }
             }
         }
         if (num2 != -1)
         {
             Units units2 = targets[num2];
             if (units2 != null)
             {
                 return(units2);
             }
         }
     }
     return(null);
 }
示例#2
0
    private void GetShareExpRangeUnits(Units inAttacker, Units inTarget, float range, List <Units> inAllShareExpUnits)
    {
        if (inAllShareExpUnits == null)
        {
            return;
        }
        inAllShareExpUnits.Clear();
        if (inAttacker == null || inTarget == null)
        {
            return;
        }
        IList <Units> mapUnits = MapManager.Instance.GetMapUnits((TeamType)inAttacker.teamType, global::TargetTag.Hero);

        if (mapUnits != null && mapUnits.Count > 0)
        {
            for (int i = 0; i < mapUnits.Count; i++)
            {
                if (!(mapUnits[i] == null))
                {
                    if (mapUnits[i].unique_id != inAttacker.unique_id)
                    {
                        if (mapUnits[i].unique_id != inTarget.unique_id)
                        {
                            if (UnitFeature.DistanceToPointSqr(mapUnits[i].mTransform.position, inAttacker.mTransform.position) <= range * range)
                            {
                                inAllShareExpUnits.Add(mapUnits[i]);
                            }
                        }
                    }
                }
            }
        }
    }
示例#3
0
 public static IList <Units> TargetsFromNearToFar(IList <Units> enemys, Units units = null)
 {
     for (int i = 0; i <= enemys.Count - 1; i++)
     {
         for (int j = 0; j < enemys.Count - i - 1; j++)
         {
             if (UnitFeature.DistanceToPointSqr(units.transform.position, enemys[j].transform.position) > UnitFeature.DistanceToPointSqr(units.transform.position, enemys[j + 1].transform.position))
             {
                 Units value = enemys[j];
                 enemys[j]     = enemys[j + 1];
                 enemys[j + 1] = value;
             }
         }
     }
     return(enemys);
 }
示例#4
0
 public static Units findDyingTarget(Vector3 cur_pos, List <Units> targets)
 {
     if (targets != null)
     {
         float num  = 1000f;
         float num2 = -1f;
         int   num3 = -1;
         for (int i = 0; i < targets.Count; i++)
         {
             Units units = targets[i];
             if (units != null && units.isLive)
             {
                 float num4 = UnitFeature.DistanceToPointSqr(cur_pos, units.transform.position);
                 if (num4 < num)
                 {
                     float num5 = units.hp;
                     if (num5 < num2 || num2 == -1f)
                     {
                         num  = num4;
                         num3 = i;
                         num2 = num5;
                     }
                 }
             }
         }
         if (num3 != -1)
         {
             Units units2 = targets[num3];
             if (units2 != null)
             {
                 return(units2);
             }
         }
     }
     return(null);
 }