private int SortFunc(Units enemy1, Units enemy2)
        {
            if (!(enemy1 != null) || !(enemy2 != null) || !enemy1.isLive || !enemy2.isLive)
            {
                return(0);
            }
            Units home = MapManager.Instance.GetHome((TeamType)this.m_Owner.teamType);

            if (home == null)
            {
                return(0);
            }
            float num  = UnitFeature.DistanceToTargetSqr(home.mTransform, enemy1.mTransform);
            float num2 = UnitFeature.DistanceToTargetSqr(home.mTransform, enemy2.mTransform);

            if (num < num2)
            {
                return(-1);
            }
            if (num == num2)
            {
                return(0);
            }
            return(1);
        }
Esempio n. 2
0
        public static List <Units> GetAllians(Units target, float distance, TargetTag tag, bool isAllians = true)
        {
            TeamType teamType = TeamType.None;

            if (isAllians)
            {
                teamType = (TeamType)target.teamType;
            }
            else if (target.teamType == 0)
            {
                teamType = TeamType.BL;
            }
            else if (target.teamType == 1)
            {
                teamType = TeamType.LM;
            }
            List <Units>  list     = new List <Units>();
            IList <Units> mapUnits = MapManager.Instance.GetMapUnits(teamType, tag);

            if (mapUnits == null)
            {
                return(list);
            }
            foreach (Units current in mapUnits)
            {
                if (!(current == null))
                {
                    if (UnitFeature.DistanceToPoint(target.transform.position, current.transform.position) <= distance)
                    {
                        list.Add(current);
                    }
                }
            }
            return(list);
        }
Esempio n. 3
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);
 }
Esempio n. 4
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]);
                            }
                        }
                    }
                }
            }
        }
    }
Esempio n. 5
0
 public static bool TargetInRange(Vector3 targetPos, EffectiveRangeType rangeType, Vector3 position, float direction = -1f, float param1 = 0f, float param2 = 0f)
 {
     if (direction == -1f)
     {
         return(UnitFeature.TargetInRange(targetPos, rangeType, position, Vector3.zero, param1, param2));
     }
     return(UnitFeature.TargetInRange(targetPos, rangeType, position, new Vector3(0f, 0f, direction), param1, param2));
 }
Esempio n. 6
0
    public static void FilterTargetsRef(Units self, ref List <Units> targets, FindType findType, object param)
    {
        if (targets != null && targets.Count > 0)
        {
            switch (findType)
            {
            case FindType.FirstIndex:
            {
                int num = (int)param;
                for (int i = 0; i < targets.Count; i++)
                {
                    if (i > num)
                    {
                        targets.RemoveAt(i);
                        i--;
                    }
                }
                break;
            }

            case FindType.Distance:
            {
                float num2 = (float)param * (float)param;
                for (int j = 0; j < targets.Count; j++)
                {
                    float num3 = UnitFeature.DistanceToTargetSqr(self.mTransform, targets[j].mTransform);
                    if (num3 > num2)
                    {
                        targets.RemoveAt(j);
                        j--;
                    }
                }
                break;
            }

            case FindType.Blood:
            {
                float num4 = (float)param;
                for (int k = 0; k < targets.Count; k++)
                {
                    if (targets[k].hp > targets[k].hp_max * num4)
                    {
                        targets.RemoveAt(k);
                        k--;
                    }
                }
                break;
            }
            }
        }
    }
Esempio n. 7
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);
 }
        private Units GetTowerPriorityTarget()
        {
            List <Units>  list     = new List <Units>();
            IList <Units> mapUnits = MapManager.Instance.GetMapUnits((TeamType)this.m_Owner.teamType, TargetTag.Hero);

            if (mapUnits == null)
            {
                return(null);
            }
            List <Units> list2 = new List <Units>();

            foreach (Units current in mapUnits)
            {
                if (UnitFeature.TargetInDistance(this.m_Owner.transform, current.transform, this.m_Owner.GetAttackRange(current)))
                {
                    list2.Add(current);
                }
            }
            if (mapUnits != null)
            {
                foreach (Units current2 in mapUnits)
                {
                    AIManager aiManager = current2.aiManager;
                    foreach (Units current3 in aiManager.GetRecentAttacker(2f))
                    {
                        if (current3 != null && current3.isLive && current3.isHero && this.IfChoose(current3))
                        {
                            list.Add(current3);
                        }
                    }
                }
            }
            List <Units> list3 = FindTargetHelper.FilterTargets(this.m_Owner, list, FindType.Distance, this.m_Owner.GetAttackRange(null));

            if (list3 != null && list3.Count > 0)
            {
                foreach (Units current4 in list3)
                {
                    if (current4.isHero)
                    {
                        return(current4);
                    }
                }
                return(list3[0]);
            }
            return(null);
        }
Esempio n. 9
0
    private List <int> GetShareUnits(Units target, float range)
    {
        List <int>    list     = new List <int>();
        IList <Units> mapUnits = MapManager.Instance.GetMapUnits((TeamType)target.teamType, global::TargetTag.Hero);

        if (mapUnits != null)
        {
            foreach (Units current in mapUnits)
            {
                if (current.unique_id != target.unique_id)
                {
                    if (UnitFeature.TargetInDistance(target.mTransform, current.mTransform, range))
                    {
                        list.Add(current.unique_id);
                    }
                }
            }
        }
        return(list);
    }
Esempio n. 10
0
        public static bool AnyEnemyInTowerRange(Units tower, Units ruleOut = null)
        {
            TeamType      teamType = (tower.teamType != 0) ? TeamType.LM : TeamType.BL;
            IList <Units> mapUnits = MapManager.Instance.GetMapUnits(teamType, TargetTag.HeroAndMonster);

            if (mapUnits == null)
            {
                return(false);
            }
            foreach (Units current in mapUnits)
            {
                if (UnitFeature.DistanceToTarget(tower.mTransform, current.mTransform) <= tower.GetAttackRange(current))
                {
                    if (!(ruleOut != null) || !(current == ruleOut))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 11
0
        public static int GetNearestTransOfTarget(Units target, Dictionary <string, Transform> points)
        {
            float num    = 999999f;
            int   result = -1;

            if (points != null)
            {
                int num2 = -1;
                foreach (string current in points.Keys)
                {
                    num2++;
                    Transform owner = points[current];
                    float     num3  = UnitFeature.DistanceToTarget(owner, target.mTransform);
                    if (num3 < num)
                    {
                        num    = num3;
                        result = num2;
                    }
                }
            }
            return(result);
        }
Esempio n. 12
0
        public static Units GetNearestTowerOfCustom(Units compareTarget, IList <Units> towers)
        {
            float num    = 999999f;
            Units result = null;

            if (towers != null)
            {
                foreach (Units current in towers)
                {
                    if (current.isLive)
                    {
                        float num2 = UnitFeature.DistanceToTarget(current.mTransform, compareTarget.mTransform);
                        if (num2 < num)
                        {
                            num    = num2;
                            result = current;
                        }
                    }
                }
            }
            return(result);
        }
Esempio n. 13
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);
 }
Esempio n. 14
0
 public static bool TargetInDistance(Transform owner, Transform target, float distance)
 {
     return(UnitFeature.DistanceToTarget(owner, target) <= distance);
 }
 private bool IfChoose(Units target)
 {
     return((!target.isMonster || target.teamType != 2) && (TeamManager.CanAttack(this.m_Owner, target) && target.CanBeSelected && !target.isItem && UnitFeature.DistanceToTarget(this.m_Owner.transform, target.transform) <= this.m_Owner.GetAttackRange(target)));
 }
 private bool IfChoose(Units target)
 {
     return(!(target == null) && (!target.isMonster || target.teamType != 2) && (target.isBuilding || UnitFeature.DistanceToTarget(this.m_Owner.transform, target.transform) <= this.m_Owner.warning_range) && (TeamManager.CanAttack(this.m_Owner, target) && target.CanBeSelected && target.isLive && !target.isItem));
 }
        public static bool IfChooseTarget(Units owner, Units target, bool isKillTarget = false, float range = 0f)
        {
            if (target == null || !target.isLive || !TeamManager.CanAttack(owner, target) || !target.CanBeSelected || target.isBuilding || target.isItem || (target.isMonster && target.teamType == 2) || !owner.CanBeSelected)
            {
                return(false);
            }
            if (!isKillTarget && target.isHero && UnitFeature.DistanceToTarget(owner.transform, target.transform) > owner.warning_range)
            {
                return(false);
            }
            Units home = MapManager.Instance.GetHome((TeamType)target.teamType);

            if (home == null)
            {
                return(true);
            }
            if (owner.MeiHuo.IsInState)
            {
                return(true);
            }
            if (range != 0f && !HeroTargetingSystem.IsInrange(owner.mTransform.position, target.mTransform.position, range))
            {
                return(false);
            }
            bool        arg_10E_0 = !StrategyManager.Instance.IsAuto() && owner.isPlayer;
            UtilCounter counter   = UtilManager.Instance.GetCounter(UtilType.Tower);

            if (counter != null)
            {
                TowerCounter towerCounter          = counter as TowerCounter;
                Units        towerOfLowestPriority = towerCounter.GetTowerOfLowestPriority(owner);
                if (towerOfLowestPriority != null)
                {
                    float num  = UnitFeature.DistanceToTargetSqr(owner.transform, towerOfLowestPriority.transform);
                    float num2 = UnitFeature.DistanceToTargetSqr(owner.transform, target.transform);
                    if (num2 > num)
                    {
                        return(false);
                    }
                }
            }
            bool flag = StrategyManager.Instance.IsHomeRecovery((TeamType)target.teamType);

            if (flag)
            {
                Vector3 recoveryPos = StrategyManager.Instance.GetRecoveryPos((TeamType)target.teamType);
                if (HeroTargetingSystem.IsInrange(target.transform.position, recoveryPos, 3f))
                {
                    return(false);
                }
            }
            Units nearestEnemyTowerOfTarget = TargetSelectHelper.GetNearestEnemyTowerOfTarget(target);

            if (nearestEnemyTowerOfTarget != null)
            {
                float attackRange = nearestEnemyTowerOfTarget.GetAttackRange(owner);
                if (HeroTargetingSystem.IsInrange(target.transform.position, nearestEnemyTowerOfTarget.transform.position, attackRange))
                {
                    float num3 = UnitFeature.DistanceToTarget(target, nearestEnemyTowerOfTarget);
                    if (owner.GetAttackRange(target) + num3 > attackRange && !HeroTargetingSystem.IsInrange(owner.transform.position, nearestEnemyTowerOfTarget.transform.position, attackRange))
                    {
                        return(true);
                    }
                    Units attackTarget = nearestEnemyTowerOfTarget.GetAttackTarget();
                    if (attackTarget != null && attackTarget == owner)
                    {
                        return(false);
                    }
                    List <Units> allians = TargetSelectHelper.GetAllians(nearestEnemyTowerOfTarget, attackRange, TargetTag.Monster, false);
                    return(allians != null && allians.Count > 1 && !target.isHero);
                }
            }
            return(true);
        }
Esempio n. 18
0
    public static List <Units> findTargets(Units self, Vector3 pos, SkillTargetCamp targetType, global::TargetTag targetTag, EffectiveRangeType rangeType, float param1 = 0f, float param2 = 0f, int max_num = -1)
    {
        List <Units> list    = new List <Units>();
        List <int>   targets = null;

        switch (targetType)
        {
        case SkillTargetCamp.Self:
            list.Add(self);
            break;

        case SkillTargetCamp.Enemy:
            targets = TeamManager.GetOtherTeam(self.team, Relation.Hostility, true);
            break;

        case SkillTargetCamp.Partener:
            targets = TeamManager.GetOtherTeam(self.team, Relation.Friendly, true);
            break;

        case SkillTargetCamp.AttackYouTarget:
        {
            Units attackedYouTarget = self.GetAttackedYouTarget();
            if (attackedYouTarget != null)
            {
                list.Add(attackedYouTarget);
            }
            targets = TeamManager.GetOtherTeam(self.team, Relation.Hostility, true);
            break;
        }

        case SkillTargetCamp.SkillHitTarget:
        {
            Units skillHitedTarget = self.GetSkillHitedTarget();
            if (skillHitedTarget != null)
            {
                list.Add(skillHitedTarget);
            }
            return(list);
        }

        case SkillTargetCamp.AttackTarget:
        {
            Units attackTarget = self.GetAttackTarget();
            if (attackTarget != null)
            {
                list.Add(attackTarget);
            }
            targets = TeamManager.GetOtherTeam(self.team, Relation.Hostility, true);
            break;
        }

        case SkillTargetCamp.SkillHitYouTarget:
        {
            Units skillHitedYouTarget = self.GetSkillHitedYouTarget();
            if (skillHitedYouTarget != null)
            {
                list.Add(skillHitedYouTarget);
            }
            return(list);
        }

        case SkillTargetCamp.SelectTarget:
            if (self.currentSkillOrAttack != null)
            {
                return(self.currentSkillOrAttack.attackTargets);
            }
            return(list);
        }
        if (list.Count <= 0)
        {
            switch (rangeType)
            {
            case EffectiveRangeType.JuXing:
            case EffectiveRangeType.YuanXing:
            case EffectiveRangeType.ShanXing:
            case EffectiveRangeType.Single:
            {
                float      radius    = (param1 <= param2) ? param2 : param1;
                int        layerMask = 1 << LayerMask.NameToLayer("Vehicle");
                Collider[] array     = Physics.OverlapSphere(pos, radius, layerMask);
                for (int i = 0; i < array.Length; i++)
                {
                    if (array[i] != null)
                    {
                        Collider   collider   = array[i];
                        GameObject gameObject = collider.transform.parent.gameObject;
                        Units      component  = gameObject.GetComponent <Units>();
                        if (max_num == -1 || list.Count < max_num)
                        {
                            if (TagManager.CheckTag(component, targetTag))
                            {
                                if (UnitFeature.TargetInRange(collider.transform.position, rangeType, pos, self.transform.eulerAngles, param1, param2))
                                {
                                    if (TeamManager.CheckTeam(self.gameObject, gameObject, targetType, null))
                                    {
                                        if (!(component == null) && component.isLive && component.CanSkillSelected)
                                        {
                                            if (!list.Contains(component))
                                            {
                                                list.Add(component);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                break;
            }

            case EffectiveRangeType.AllMap:
            {
                Dictionary <int, Units>             allMapUnits = MapManager.Instance.GetAllMapUnits();
                Dictionary <int, Units> .Enumerator enumerator  = allMapUnits.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    KeyValuePair <int, Units> current = enumerator.Current;
                    Units value = current.Value;
                    if (!(value == null) && value.isLive && value.CanSkillSelected)
                    {
                        if (max_num == -1 || list.Count < max_num)
                        {
                            if (TagManager.CheckTag(value, targetTag))
                            {
                                if (TeamManager.CheckTeamType(value.teamType, targets))
                                {
                                    if (!list.Contains(value))
                                    {
                                        list.Add(value);
                                    }
                                }
                            }
                        }
                    }
                }
                break;
            }

            case EffectiveRangeType.Link:
            {
                float num        = (param1 <= param2) ? param2 : param1;
                int   layerMask2 = 1 << LayerMask.NameToLayer("Vehicle");
                if (max_num > 0)
                {
                    if (!(self == null))
                    {
                        Units attackTarget2 = self.GetAttackTarget();
                        if (!(attackTarget2 == null))
                        {
                            list.Add(attackTarget2);
                            pos = attackTarget2.transform.position;
                            while (list.Count < max_num)
                            {
                                bool       flag   = false;
                                Units      units  = null;
                                float      num2   = -1f;
                                Collider[] array2 = Physics.OverlapSphere(pos, num, layerMask2);
                                for (int j = 0; j < array2.Length; j++)
                                {
                                    if (array2[j] != null)
                                    {
                                        Collider   collider2   = array2[j];
                                        GameObject gameObject2 = collider2.transform.parent.gameObject;
                                        Units      component2  = gameObject2.GetComponent <Units>();
                                        if (max_num != -1 && list.Count >= max_num)
                                        {
                                            break;
                                        }
                                        if (TagManager.CheckTag(component2, targetTag))
                                        {
                                            if (TeamManager.CheckTeam(self.gameObject, gameObject2, targetType, null))
                                            {
                                                if (!(component2 == null) && component2.isLive && component2.CanSkillSelected)
                                                {
                                                    if (!list.Contains(component2))
                                                    {
                                                        if ((units == null || num2 > (pos - component2.transform.position).sqrMagnitude) && (pos - component2.transform.position).sqrMagnitude < num * num)
                                                        {
                                                            units = component2;
                                                            num2  = (pos - component2.transform.position).sqrMagnitude;
                                                        }
                                                        if (units != null)
                                                        {
                                                            flag = true;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                if (!flag)
                                {
                                    break;
                                }
                                list.Add(units);
                                pos = units.transform.position;
                            }
                        }
                    }
                }
                break;
            }
            }
        }
        return(list);
    }
Esempio n. 19
0
    public static void SortTargets(Units self, SortType sortType, ref List <Units> target_units)
    {
        if (target_units != null && target_units.Count > 1)
        {
            switch (sortType)
            {
            case SortType.Hatred:
                target_units.Sort(delegate(Units a, Units b)
                {
                    if (a.unique_id == b.unique_id)
                    {
                        return(0);
                    }
                    int targetHatredValue  = self.GetTargetHatredValue(a);
                    int targetHatredValue2 = self.GetTargetHatredValue(b);
                    int result             = -1;
                    if (targetHatredValue > targetHatredValue2)
                    {
                        result = -1;
                    }
                    else if (targetHatredValue < targetHatredValue2)
                    {
                        result = 1;
                    }
                    return(result);
                });
                break;

            case SortType.Distance:
                target_units.Sort(delegate(Units a, Units b)
                {
                    if (a.unique_id == b.unique_id)
                    {
                        return(0);
                    }
                    float num = 0f;
                    if (a != null)
                    {
                        num = UnitFeature.DistanceToTargetSqr(self.mTransform, a.mTransform);
                    }
                    float num2 = 0f;
                    if (b != null)
                    {
                        num2 = UnitFeature.DistanceToTargetSqr(self.mTransform, b.mTransform);
                    }
                    int result = -1;
                    if (num > num2)
                    {
                        result = 1;
                    }
                    else if (num < num2)
                    {
                        result = -1;
                    }
                    return(result);
                });
                break;

            case SortType.Blood:
                target_units.Sort(delegate(Units a, Units b)
                {
                    if (a.unique_id == b.unique_id)
                    {
                        return(0);
                    }
                    float hp   = a.hp;
                    float hp2  = b.hp;
                    int result = -1;
                    if (hp > hp2)
                    {
                        result = 1;
                    }
                    else if (hp < hp2)
                    {
                        result = -1;
                    }
                    return(result);
                });
                break;

            case SortType.Magic:
                target_units.Sort(delegate(Units a, Units b)
                {
                    if (a.unique_id == b.unique_id)
                    {
                        return(0);
                    }
                    float mp   = a.mp;
                    float mp2  = b.mp;
                    int result = -1;
                    if (mp > mp2)
                    {
                        result = 1;
                    }
                    else if (mp < mp2)
                    {
                        result = -1;
                    }
                    return(result);
                });
                break;

            case SortType.Prority:
                target_units.Sort(delegate(Units a, Units b)
                {
                    if (a.unique_id == b.unique_id)
                    {
                        return(0);
                    }
                    int targetPorityValue  = self.GetTargetPorityValue(a);
                    int targetPorityValue2 = self.GetTargetPorityValue(b);
                    int result             = -1;
                    if (targetPorityValue > targetPorityValue2)
                    {
                        result = -1;
                    }
                    else if (targetPorityValue < targetPorityValue2)
                    {
                        result = 1;
                    }
                    return(result);
                });
                break;
            }
        }
    }
Esempio n. 20
0
 public void MoveToTarget(Units target, float stopDistance)
 {
     if (target != null && this.self.CanMove)
     {
         bool flag = false;
         if (this.curMoveState == EMoveState.MoveState_MoveToTarget)
         {
             if (this.curMoveStateTargetId == target.unique_id)
             {
                 if (DateTime.Now.Ticks - this.lastSearchPath > 5000000L)
                 {
                     flag = true;
                 }
             }
             else
             {
                 flag = true;
             }
         }
         else
         {
             flag = true;
         }
         if (!flag)
         {
             return;
         }
         this.curMoveState         = EMoveState.MoveState_MoveToTarget;
         this.curMoveStateTargetId = target.unique_id;
         this.lastSearchPath       = DateTime.Now.Ticks;
         if (Singleton <PvpManager> .Instance.IsInPvp)
         {
             if (this.self.isPlayer || (this.self.MirrorState && this.self.ParentUnit.isPlayer))
             {
                 this.self.InterruptAction(SkillInterruptType.Initiative);
                 float num = UnitFeature.DistanceToTarget(this.self.mTransform, target.mTransform);
                 if (num < stopDistance + 3f)
                 {
                     this.m_DistanceToTargetType = DistanceToTargetType.NearByTarget;
                 }
                 else
                 {
                     this.m_DistanceToTargetType = DistanceToTargetType.FarFromTarget;
                 }
                 if (GlobalSettings.Instance.PvpSetting.isPlayerMoveBeforeServer && this.navAgent != null)
                 {
                     this.navAgent.MoveToTarget(target, stopDistance);
                 }
                 this.SendMoveToTarget(target.unique_id, target.transform.position, stopDistance);
             }
         }
         else
         {
             this.self.InterruptAction(SkillInterruptType.Initiative);
             float num2 = UnitFeature.DistanceToTarget(this.self.mTransform, target.mTransform);
             if (num2 < stopDistance + 3f)
             {
                 this.m_DistanceToTargetType = DistanceToTargetType.NearByTarget;
             }
             else
             {
                 this.m_DistanceToTargetType = DistanceToTargetType.FarFromTarget;
             }
             if (this.navAgent != null)
             {
                 this.navAgent.MoveToTarget(target, stopDistance);
             }
         }
     }
 }
        public bool CheckInputTarget(InputTargetType targetType, GoalTarget goal)
        {
            if (goal != null)
            {
                Units unit = goal.m_Unit;
                if (targetType == InputTargetType.MoveTarget)
                {
                    return(unit != null && unit.isLive);
                }
                if (unit == null || !unit.isLive || !unit.CanBeSelected || !TeamManager.CanAttack(this.m_Owner, goal.m_Unit) || UnitFeature.DistanceToTarget(this.m_Owner.transform, unit.transform) > this.m_Owner.fog_range)
                {
                    return(false);
                }
                switch (targetType)
                {
                case InputTargetType.AttackTarget:
                case InputTargetType.KillTarget:
                case InputTargetType.BuffTarget:
                case InputTargetType.FixedTarget:
                case InputTargetType.AttackYouTarget:
                case InputTargetType.TauntTarget:
                case InputTargetType.GuardTarget:
                    return(true);

                case InputTargetType.SelectTarget:
                    return(this.m_Owner.isPlayer);
                }
            }
            return(false);
        }