예제 #1
0
        public static Units GetNearestEnemyTowerOfSelf(Units self)
        {
            TeamType      teamType = (self.teamType != 0) ? TeamType.LM : TeamType.BL;
            IList <Units> mapUnits = MapManager.Instance.GetMapUnits(teamType, TargetTag.Building);

            return(TargetSelectHelper.GetNearestTowerOfCustom(self, mapUnits));
        }
        public override bool SelectMapTarget()
        {
            bool flag = !StrategyManager.Instance.IsAuto() && this.m_Owner.isPlayer;

            if (flag)
            {
                return(true);
            }
            Units recentAttackTower = TargetSelectHelper.GetRecentAttackTower(this.m_Owner);

            if (recentAttackTower != null)
            {
                base.SetInputTarget(InputTargetType.AttackTarget, recentAttackTower);
                return(true);
            }
            Units       units   = null;
            UtilCounter counter = UtilManager.Instance.GetCounter(UtilType.Tower);

            if (counter != null)
            {
                TowerCounter towerCounter = counter as TowerCounter;
                units = towerCounter.GetTowerOfLowestPriority(this.m_Owner);
            }
            if (units != null)
            {
                base.SetInputTarget(InputTargetType.AttackTarget, units);
                return(true);
            }
            return(false);
        }
        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);
        }
예제 #4
0
        public static int GetNearestGuidePointIdx(Units target)
        {
            Dictionary <string, Transform> guidePoints = MapManager.Instance.GetGuidePoints((TeamType)target.teamType);

            if (guidePoints.Count == 0)
            {
                return(-1);
            }
            return(TargetSelectHelper.GetNearestTransOfTarget(target, guidePoints));
        }
        public bool SelectGuideTarget()
        {
            Monster monster = this.m_Owner as Monster;

            if (monster != null && monster.FromNeutralMonster)
            {
                return(false);
            }
            Transform nearestGuidePoint = TargetSelectHelper.GetNearestGuidePoint(this.m_Owner);

            return(nearestGuidePoint != null);
        }
예제 #6
0
        public static Transform GetNearestGuidePoint(Units target)
        {
            Dictionary <string, Transform> guidePoints = MapManager.Instance.GetGuidePoints((TeamType)target.teamType);

            if (guidePoints.Count == 0)
            {
                return(null);
            }
            int nearestTransOfTarget = TargetSelectHelper.GetNearestTransOfTarget(target, guidePoints);

            if (nearestTransOfTarget == -1 || nearestTransOfTarget == guidePoints.Count)
            {
                return(null);
            }
            return(MapManager.Instance.GetGuidePoint((TeamType)target.teamType, 0, nearestTransOfTarget));
        }
        public override bool SelectMapTarget()
        {
            if (this.SelectGuideTarget())
            {
                return(false);
            }
            Units targetsOfPorityAndDistance = this.GetTargetsOfPorityAndDistance();

            if (targetsOfPorityAndDistance != null && this.IfChoose(targetsOfPorityAndDistance))
            {
                base.SetInputTarget(InputTargetType.AttackTarget, targetsOfPorityAndDistance);
                return(true);
            }
            Units nearestEnemyTowerOfSelf = TargetSelectHelper.GetNearestEnemyTowerOfSelf(this.m_Owner);

            if (nearestEnemyTowerOfSelf != null)
            {
                base.SetInputTarget(InputTargetType.AttackTarget, nearestEnemyTowerOfSelf);
                return(true);
            }
            base.SetInputTarget(InputTargetType.AttackTarget, null);
            return(false);
        }
예제 #8
0
        public static Units GetNearestEnemyTowerOfTarget(Units target)
        {
            IList <Units> mapUnits = MapManager.Instance.GetMapUnits((TeamType)target.teamType, TargetTag.Tower);

            return(TargetSelectHelper.GetNearestTowerOfCustom(target, mapUnits));
        }
        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);
        }