Example #1
0
        public override bool CanProcessTurn(GameContext context, Hero hero)
        {
            var targetUnit = context.EnemyUnits.Where(u => MathUtils.GetDistance(u, hero) <= hero.MovementSpeed + hero.AttackRange).OrderBy(u => u.Health).FirstOrDefault(u => u.Health <= hero.AttackDamage);

            if (targetUnit != null &&
                hero.Health > hero.MaxHealth * 0.4)
            {
                var position = MathUtils.GetPointAlongLine(hero.Position, targetUnit.Position, hero.AttackRange);
                context.MoveAttack(position, targetUnit.UnitId);
                return(true);
            }

            return(false);
        }
Example #2
0
        public override bool CanProcessTurn(GameContext context, Hero hero)
        {
            var targetHero = context.EnemyHeroes.FirstOrDefault(h => h.Health < hero.AttackDamage * 2);

            if (targetHero != null)
            {
                if (MathUtils.GetDistance(hero, targetHero) <= hero.AttackRange)
                {
                    context.Attack(targetHero.UnitId, hero.HeroType.ToString());
                    return(true);
                }
                else if (MathUtils.GetDistance(targetHero, hero) <= hero.MovementSpeed + hero.AttackRange)
                {
                    var position = MathUtils.GetPointAlongLine(hero.Position, targetHero.Position, hero.AttackRange);
                    context.MoveAttack(position, targetHero.UnitId);
                    return(true);
                }
            }

            return(false);
        }