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); }
protected override bool doAction() { int skill_index = this.skillData.config.skill_index; List <SkillDataKey> skillsByIndex = base.unit.getSkillsByIndex(skill_index); if (skillsByIndex == null || skillsByIndex.Count < 3) { return(false); } if (this.targetUnits == null) { return(false); } for (int i = 0; i < this.targetUnits.Count; i++) { List <Units> list = new List <Units>(); list.Add(this.targetUnits[i]); if (TeamManager.CanAttack(base.unit, list[0])) { StartSkillAction startSkillAction = ActionManager.StartSkill(skillsByIndex[1], base.unit, list, this.targetPosition, true, null); startSkillAction.OnSkillDamageCallback = new Callback <BaseSkillAction, List <Units> >(this.OnSkillDamage); startSkillAction.OnSkillEndCallback = new Callback <BaseSkillAction>(this.OnSkillEnd); this.AddAction(startSkillAction); } else { StartSkillAction startSkillAction2 = ActionManager.StartSkill(skillsByIndex[2], base.unit, list, this.targetPosition, true, null); startSkillAction2.OnSkillDamageCallback = new Callback <BaseSkillAction, List <Units> >(this.OnSkillDamage); startSkillAction2.OnSkillEndCallback = new Callback <BaseSkillAction>(this.OnSkillEnd); this.AddAction(startSkillAction2); } } return(true); }
public List <Units> GetListOfRecentlySensedOpponents(Relation relation, TargetTag tagType = TargetTag.All, bool isVisibile = true, bool isCheckTaunted = false, SortType sortType = SortType.None, FindType findType = FindType.None, object param = null) { this.target_units.Clear(); bool flag = false; for (int i = 0; i < this.m_MemoryId.Count; i++) { int num = this.m_MemoryId[i]; MemoryRecord memoryRecord = this.m_MemoryMap[num]; if (memoryRecord != null) { if (!isVisibile || memoryRecord.bWithingFOV) { Units unit = MapManager.Instance.GetUnit(num); if (unit == null || !unit.isLive) { this.m_MemoryMap[num] = null; } else if (relation == Relation.Hostility) { if (TeamManager.CanAttack(this.m_Owner, unit)) { if (isCheckTaunted && unit.ChaoFeng.IsInState) { this.target_units.Clear(); this.target_units.Add(unit); flag = true; break; } if (TagManager.CheckTag(unit, tagType)) { this.target_units.Add(unit); } } } else if (relation == Relation.Companion && TeamManager.CanAssist(this.m_Owner, unit)) { if (TagManager.CheckTag(unit, tagType)) { this.target_units.Add(unit); } } } } } if (!flag) { if (sortType != SortType.None) { FindTargetHelper.SortTargets(this.m_Owner, sortType, ref this.target_units); } if (findType != FindType.None) { FindTargetHelper.FilterTargetsRef(this.m_Owner, ref this.target_units, findType, param); } } return(this.target_units); }
public override bool SelectMapTarget() { Units targetsOfPorityAndDistance = this.m_SensoryMemory.GetTargetsOfPorityAndDistance(); if (targetsOfPorityAndDistance != null && TeamManager.CanAttack(this.m_Owner, targetsOfPorityAndDistance)) { base.SetInputTarget(InputTargetType.FixedTarget, targetsOfPorityAndDistance); return(true); } return(false); }
private bool RightTarget() { this.targetUnit = null; if (this.targetObj != null && !PlayerControlMgr.Instance.GetPlayer().IsForceClickGroud) { this.targetUnit = this.targetObj.GetComponentInParent <Units>(); if (this.targetUnit != null && this.targetUnit.isLive && TeamManager.CanAttack(this.self, this.targetUnit) && this.targetUnit.CanBeSelected) { this.validTargetUnit = true; return(true); } } return(false); }
public static Units GetRecentAttackTower(Units target) { AIManager aiManager = target.aiManager; if (aiManager == null) { return(null); } foreach (Units current in aiManager.GetRecentAttacker(3f)) { if (current != null && current.isLive && current.isTower && TeamManager.CanAttack(current, target)) { return(current); } } return(null); }
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); }
public static Units FindAutoSkillTarget(Units self, Vector3 pos, global::TargetTag targetTag, float radius, SkillTargetCamp skillTargetCamp = SkillTargetCamp.None, Skill skill = null) { List <Units> target_units = new List <Units>(); Units target = null; if (targetTag == global::TargetTag.Hero) { target = PlayerControlMgr.Instance.GetSelectedTarget(); if (target != null && Vector3.Distance(pos, target.mTransform.position) < radius) { return(target); } target = null; } else { if (skill == null) { target = FindTargetHelper.FindNearst(self, pos, targetTag); } else { target = FindTargetHelper.findClosestTarget(self, pos, skillTargetCamp, targetTag, skill.data.selectRangeType, skill.data.selectRange1, skill.data.selectRange2); } if (target != null && Vector3.Distance(pos, target.mTransform.position) < radius) { return(target); } target = null; } IList <Units> allHeroes = MapManager.Instance.GetAllHeroes(); for (int i = 0; i < allHeroes.Count; i++) { target = allHeroes[i]; if (Vector3.Distance(self.mTransform.position, target.mTransform.position) <= radius) { if (!(target == null) && target.isLive && target.CanSkillSelected && target.IsManualSelectable()) { if ((TeamManager.CanAttack(self, target) || (self != target && target.isHero && skillTargetCamp == SkillTargetCamp.AllWhitOutSelf) || skillTargetCamp == SkillTargetCamp.Partener || skillTargetCamp == SkillTargetCamp.All) && !target_units.Contains(target)) { target_units.Add(target); } } } } target = null; if (target_units.Count == 0) { return(target); } IList <Units> mapUnits = MapManager.Instance.GetMapUnits(self.TeamType, global::TargetTag.Hero); Units x = mapUnits.FirstOrDefault(delegate(Units unit) { target = unit.GetAttackTarget(); if (target == null) { target = unit.GetSkillHitedTarget(); } if (target == null) { target = unit.GetAttackedYouTarget(); } if (target == null) { target = unit.GetSkillHitedYouTarget(); } return(target_units.Contains(target)); }); if (x == null) { FindTargetHelper.SortTargets(self, GlobalSettings.Instance.AttackSortType, ref target_units); target = target_units[0]; } return(target); }