예제 #1
0
        public List <Point> GetAllPositionsToMove(Point position)
        {
            _animalSpeed = _field.Animals[position.Y, position.X].Speed;

            List <Point> PositionsToMove = new List <Point>();

            for (int i = position.Y - _animalSpeed; i < position.Y + _animalSpeed + 1; i++)
            {
                for (int j = position.X - _animalSpeed; j < position.X + _animalSpeed + 1; j++)
                {
                    Point pointToAdd = new Point(j, i);
                    if (((pointToAdd.X >= 0) && (pointToAdd.Y >= 0) && (pointToAdd.X < _field.Width) && (pointToAdd.Y < _field.Heigth)) &&
                        _positionChecker.CheckEmpty(pointToAdd) && (pointToAdd != new Point(position.X, position.Y)))
                    {
                        PositionsToMove.Add(pointToAdd);
                    }
                }
            }
            return(PositionsToMove);
        }
예제 #2
0
        public List <Point> FindNearestAnimals(Point position)
        {
            int          visionRange = _field.Animals[position.Y, position.X].VisionRange;
            List <Point> animals     = new List <Point>();

            for (int i = position.Y - visionRange; i < position.Y + visionRange; i++)
            {
                for (int j = position.X - visionRange; j < position.X + visionRange; j++)
                {
                    Point currentPoint = new Point(j, i);
                    if ((position != currentPoint) &&
                        (currentPoint.X >= 0) && (currentPoint.Y >= 0) && (currentPoint.X < _field.Width) && (currentPoint.Y < _field.Heigth) &&
                        !_positionChecker.CheckEmpty(currentPoint))
                    {
                        animals.Add(new Point(j, i));
                    }
                }
            }

            return(animals);
        }