public override bool SelectVisiableTarget()
        {
            bool flag = !StrategyManager.Instance.IsAuto() && this.m_Owner.isPlayer;

            if (flag)
            {
                List <Units> list = FindTargetHelper.findTargets(this.m_Owner, this.m_Owner.trans.position, SkillTargetCamp.AttackTarget, TargetTag.HeroAndMonster, (this.m_Owner.atk_type != 1) ? (this.m_Owner.attack_range + 2f) : 6.5f);
                FindTargetHelper.SortTargets(this.m_Owner, GlobalSettings.Instance.AttackSortType, ref list);
                if (list != null && list.Count > 0)
                {
                    GoalTarget inputTarget = base.GetInputTarget(InputTargetType.AttackTarget);
                    if (inputTarget == null || (inputTarget != null && inputTarget.m_Unit.isBuilding))
                    {
                        base.SetInputTarget(InputTargetType.AttackTarget, list[0]);
                        base.SetSelectTarget(list[0]);
                        return(true);
                    }
                }
                return(false);
            }
            if (!this.IfNeedChangeTarget())
            {
                return(true);
            }
            Units nextTarget = this.GetNextTarget();

            if (nextTarget == null)
            {
                base.SetInputTarget(InputTargetType.AttackTarget, null);
                return(false);
            }
            base.SetInputTarget(InputTargetType.AttackTarget, nextTarget);
            return(true);
        }
        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);
        }
Пример #3
0
        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);
        }
        private void SetMoveTarget()
        {
            GoalTarget inputTarget = base.GetInputTarget(InputTargetType.MoveTarget);

            if (inputTarget == null || inputTarget.m_Unit == null)
            {
                base.SetInputTarget(InputTargetType.MoveTarget, this.m_FollowTarget);
            }
        }
        private void DespawnBuffTarget()
        {
            Units      triggerUnit = TriggerManager.GetTriggerUnit();
            GoalTarget inputTarget = base.GetInputTarget(InputTargetType.BuffTarget);

            if (inputTarget != null && inputTarget.m_Unit != null && triggerUnit.unique_id == inputTarget.m_Unit.unique_id)
            {
                base.SetInputTarget(InputTargetType.BuffTarget, null);
            }
        }
Пример #6
0
        public Units GetGuardTarget()
        {
            GoalTarget inputTarget = this.GetInputTarget(InputTargetType.GuardTarget);

            if (inputTarget != null)
            {
                return(inputTarget.m_Unit);
            }
            return(null);
        }
Пример #7
0
        public Units GetAttackYouTarget()
        {
            GoalTarget inputTarget = this.GetInputTarget(InputTargetType.AttackYouTarget);

            if (inputTarget != null)
            {
                return(inputTarget.m_Unit);
            }
            return(null);
        }
        public override void DefendTower(Units attacker, Units tower)
        {
            GoalTarget inputTarget = base.GetInputTarget(InputTargetType.GuardTarget);

            if (inputTarget == null || inputTarget.m_Unit == null || !inputTarget.m_Unit.isLive)
            {
                base.SetInputTarget(InputTargetType.GuardTarget, attacker);
                if (this.delayClear == null)
                {
                    this.delayClear = new Task(this.DelayClearGuardTarget(attacker, tower), true);
                }
            }
        }
 public override void UpdateTargetState()
 {
     for (int i = 0; i < this.m_Goals.Length; i++)
     {
         GoalTarget goalTarget = this.m_Goals[i];
         if (!base.CheckInputTarget((InputTargetType)i, goalTarget))
         {
             if (goalTarget != null && goalTarget.m_Unit != null)
             {
                 goalTarget.m_Unit.MarkAsTarget(false);
             }
             base.SetInputTarget((InputTargetType)i, null);
         }
     }
 }
Пример #10
0
 protected void SetInputTarget(InputTargetType targetType, Units target)
 {
     if (target != null)
     {
         if (this.m_Goals[(int)targetType] != null)
         {
             bool flag = this.m_Goals[(int)targetType].m_Unit == target;
             this.m_Goals[(int)targetType].Set(targetType, target);
         }
         else
         {
             GoalTarget goalTarget = new GoalTarget();
             goalTarget.Set(targetType, target);
             this.m_Goals[(int)targetType] = goalTarget;
         }
     }
     else
     {
         this.m_Goals[(int)targetType] = null;
     }
 }