private void SetKillTarget()
        {
            List <Units> list        = new List <Units>();
            GoalTarget   inputTarget = base.GetInputTarget(InputTargetType.KillTarget);

            if (inputTarget != null && inputTarget.m_Unit != null && HeroTargetingSystem.IfChooseTarget(this.m_Owner, inputTarget.m_Unit, true, 0f) && inputTarget.m_Unit.isHero)
            {
                return;
            }
            List <Units> allians = TargetSelectHelper.GetAllians(this.m_Owner, this.m_Owner.warning_range + 3f, TargetTag.HeroAndMonster, false);

            foreach (Units current in allians)
            {
                if (current.hp / current.hp_max <= 0.3f)
                {
                    list.Add(current);
                }
            }
            foreach (Units current2 in list)
            {
                if (current2.isLive && HeroTargetingSystem.IfChooseTarget(this.m_Owner, current2, true, 0f))
                {
                    base.SetInputTarget(InputTargetType.KillTarget, current2);
                    return;
                }
            }
            base.SetInputTarget(InputTargetType.KillTarget, null);
        }
        private Units GetPriorityTarget()
        {
            IEnumerable <Units> recentAttacker = this.m_Owner.aiManager.GetRecentAttacker(3f);

            foreach (Units current in recentAttacker)
            {
                if (HeroTargetingSystem.IfChooseTarget(this.m_Owner, current, false, 0f) && current.isHero)
                {
                    return(current);
                }
            }
            return(null);
        }
 public static bool InAnyOfTowersRange(Vector3 self, List <Units> towers)
 {
     if (towers == null)
     {
         return(false);
     }
     foreach (Units current in towers)
     {
         if (HeroTargetingSystem.IsInrange(self, current.mTransform.position, current.attack_range + 1f))
         {
             return(true);
         }
     }
     return(false);
 }
        private Units GetNormalTarget()
        {
            List <Units> list = MapManager.Instance.EnumEnemyMapUnits(this.m_Owner.TeamType, TargetTag.HeroAndMonster).ToList <Units>();

            if (list.Count > 0)
            {
                list.Sort(new Comparison <Units>(this.SortFunc));
                foreach (Units current in list)
                {
                    if (HeroTargetingSystem.IfChooseTarget(this.m_Owner, current, false, 0f))
                    {
                        return(current);
                    }
                }
            }
            return(null);
        }
        protected override bool IfNeedChangeTarget()
        {
            this.m_timer.interval = 1f;
            if (this.m_timer.CanUpdate())
            {
                return(true);
            }
            object outputTarget = base.GetOutputTarget(OutputTargetType.OutputAttackTarget);

            if (outputTarget == null)
            {
                return(true);
            }
            Units target = outputTarget as Units;
            bool  flag   = HeroTargetingSystem.IfChooseTarget(this.m_Owner, target, false, 0f);

            return(!flag);
        }
        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);
        }