예제 #1
0
        public override bool CanProcessTurn(GameContext context, Hero hero)
        {
            var towerPosition   = context.MyUnits.FirstOrDefault(u => u.UnitType == UnitType.Tower).Position;
            var myTowerPosition = new Position(towerPosition.X + (hero.Team == 0 ? -1 : 1), towerPosition.Y);
            var targetUnit      = context.MyUnits.Where(u => u.UnitType != UnitType.Tower).OrderBy(u => MathUtils.GetDistance(myTowerPosition, u.Position)).FirstOrDefault();
            var enemyTower      = context.EnemyUnits.FirstOrDefault(u => u.UnitType == UnitType.Tower);

            if (targetUnit != null)
            {
                if (hero.Health < hero.MaxHealth * 0.30 ||
                    context.MyUnits.Where(u => MathUtils.GetDistance(u, enemyTower) < MathUtils.GetDistance(hero, enemyTower)).Count() < 2)
                {
                    context.Move(myTowerPosition);
                    return(true);
                }

                return(false);
            }
            else
            {
                if (MathUtils.GetDistance(hero.Position, myTowerPosition) == 0)
                {
                    return(false);
                }

                context.Move(myTowerPosition);
                return(true);
            }
        }
예제 #2
0
        public override bool CanProcessTurn(GameContext context, Hero hero)
        {
            var targetUnit = context.MyUnits.Where(u => u.UnitType != UnitType.Tower).OrderBy(u => MathUtils.GetDistance(u, hero)).FirstOrDefault();

            if (targetUnit != null)
            {
                var targetPosition = new Position(targetUnit.Position.X + (hero.Team == 0 ? -1 : 1), targetUnit.Position.Y);
                context.Move(targetPosition);
                return(true);
            }

            return(false);
        }