private void MoveToWeakestTarget()
        {
            //// Logcat.I("There is not enemy to avoid, moving to weakest target");
            Point unit = AIUtils.GetWeakestTarget(this.Unit.UnitsMap);

            if (unit != default)
            {
                Dictionary <Point, List <Point> > allPaths = AIUtils.GetAllPaths(this.Board, this.Unit.UnitsMap, this.Unit.GetPosition(), true);
                AIPlacementHelper.MoveToTarget(this, allPaths, this.Unit, this.Range, unit);
            }
        }
예제 #2
0
        private void TryToAttack(BoardController boardController)
        {
            Dictionary <Point, List <Point> > allPaths = AIUtils.GetAllPaths(this.unit.Board, this.unit.UnitsMap, this.unit.GetPosition());
            Unit targetInLine = AIUtils.GetUnitInLine(this.unit.UnitsMap, this.unit.GetPosition(), allPaths);

            if (targetInLine != null)
            {
                this.unit.Target = targetInLine;
                //// Logcat.I(this, $"Target identified {targetInLine.GetPosition()}");
                Attack(boardController);
            }
        }
예제 #3
0
        public override void Execute(Point target)
        {
            this.allPaths = AIUtils.GetAllPaths(this.Board, this.Unit.UnitsMap, this.Unit.GetPosition(), true);
            KeyValuePair <Point, int> targetUnit = AIUtils.GetClosestTarget(this.Unit.UnitsMap, this.Unit.GetPosition(), this.Range);

            if (!targetUnit.Equals(default(KeyValuePair <Point, int>)))
            {
                AIPlacementHelper.MoveToClosestTarget(this, this.validPaths, this.Unit, this.Range, targetUnit.Key);
                ((EnemyUnit)this.Unit).Target = PointUtils.GetDistance(this.Unit.GetPosition(), targetUnit.Key) <= 1 ? this.Unit.UnitsMap.Get(targetUnit.Key) : null;
                return;
            }

            Point unitPosition = GetTarget();

            AIPlacementHelper.MoveToTarget(this, this.allPaths, this.Unit, this.Range, unitPosition);
            ((EnemyUnit)this.Unit).Target = PointUtils.GetDistance(this.Unit.GetPosition(), unitPosition) <= 1 ? this.Unit.UnitsMap.Get(unitPosition) : null;
        }