Beispiel #1
0
        public List <Point> Get(Point startPoint, int size, params Element[] elements)
        {
            var topLeft     = startPoint.ShiftLeft(size).ShiftTop(size);
            var bottomRight = startPoint.ShiftRight(size).ShiftBottom(size);

            return(Get(startPoint, size, topLeft, bottomRight, elements));
        }
Beispiel #2
0
        public int CountNear(Point point, Element element)
        {
            if (point.IsOutOf(Size))
            {
                return(0);
            }

            int count = 0;

            if (IsAt(point.ShiftLeft(), element))
            {
                count++;
            }
            if (IsAt(point.ShiftRight(), element))
            {
                count++;
            }
            if (IsAt(point.ShiftTop(), element))
            {
                count++;
            }
            if (IsAt(point.ShiftBottom(), element))
            {
                count++;
            }
            return(count);
        }
Beispiel #3
0
        private void InitSidePoints()
        {
            _sidePoints.Clear();
            var sideDirections = _sideDirections[Direction];

            foreach (var sideDirection in sideDirections)
            {
                var sidePoint = new Point();

                switch (sideDirection)
                {
                case Direction.Up:
                    sidePoint = Point.ShiftTop();
                    break;

                case Direction.Right:
                    sidePoint = Point.ShiftRight();
                    break;

                case Direction.Down:
                    sidePoint = Point.ShiftBottom();
                    break;

                case Direction.Left:
                    sidePoint = Point.ShiftLeft();
                    break;
                }

                _sidePoints.Add(sidePoint);
            }
        }
Beispiel #4
0
 public static bool IsNear(this Point startPoint, Point point)
 {
     return(startPoint.ShiftTop().Equals(point) ||
            startPoint.ShiftRight().Equals(point) ||
            startPoint.ShiftBottom().Equals(point) ||
            startPoint.ShiftLeft().Equals(point));
 }
Beispiel #5
0
        public bool IsNear(Point point, Element element, int near = 1)
        {
            if (point.IsOutOf(Size))
            {
                return(false);
            }

            for (int i = 1; i <= near; i++)
            {
                if (IsAt(point.ShiftLeft(i), element))
                {
                    return(true);
                }
                if (IsAt(point.ShiftRight(i), element))
                {
                    return(true);
                }
                if (IsAt(point.ShiftTop(i), element))
                {
                    return(true);
                }
                if (IsAt(point.ShiftBottom(i), element))
                {
                    return(true);
                }
            }
            return(true);
        }
Beispiel #6
0
        // лево, верх, право, низ
        public static IEnumerable <Bomberman.Api.Point> GetNear(this Bomberman.Api.Point point)
        {
            yield return(point.ShiftLeft());

            yield return(point.ShiftTop());

            yield return(point.ShiftRight());

            yield return(point.ShiftBottom());
        }
Beispiel #7
0
        public bool IsNear(Point point, Element element)
        {
            if (point.IsOutOf(Size))
            {
                return(false);
            }

            return(IsAt(point.ShiftLeft(), element) ||
                   IsAt(point.ShiftRight(), element) ||
                   IsAt(point.ShiftTop(), element) ||
                   IsAt(point.ShiftBottom(), element));
        }
Beispiel #8
0
        public static Bomberman.Api.Point Shift(this Bomberman.Api.Point point, Direction direction, int delta = 1)
        {
            switch (direction)
            {
            case Direction.Left: return(point.ShiftLeft(delta));

            case Direction.Up: return(point.ShiftTop(delta));

            case Direction.Right: return(point.ShiftRight(delta));

            case Direction.Down: return(point.ShiftBottom(delta));
            }
            throw new ArgumentException("Передано неверное направление");
        }
Beispiel #9
0
        private void InitUnknownNextTickPoints()
        {
            _nextTickPoints.Clear();

            var top = Point.ShiftTop();

            _nextTickPoints.Add(new Tuple <MovePosition, Point>(MovePosition.Top, top));

            var bottom = Point.ShiftBottom();

            _nextTickPoints.Add(new Tuple <MovePosition, Point>(MovePosition.Bottom, bottom));

            var right = Point.ShiftRight();

            _nextTickPoints.Add(new Tuple <MovePosition, Point>(MovePosition.Right, right));

            var left = Point.ShiftLeft();

            _nextTickPoints.Add(new Tuple <MovePosition, Point>(MovePosition.Left, left));
        }
Beispiel #10
0
 // Можно прямо здесь зашить невозможность создать направление в стенку.
 public static Direction ToDirection(this Bomberman.Api.Point for_, Bomberman.Api.Point to)
 {
     if (for_.ShiftLeft() == to)
     {
         return(Direction.Left);
     }
     if (for_.ShiftTop() == to)
     {
         return(Direction.Up);
     }
     if (for_.ShiftRight() == to)
     {
         return(Direction.Right);
     }
     if (for_.ShiftBottom() == to)
     {
         return(Direction.Down);
     }
     return(Direction.Stop);
 }
Beispiel #11
0
        public bool IsDestroyableNear(Point point)
        {
            List <Element> enemy = new List <Element>()
            {
                Element.DESTROYABLE_WALL,
                Element.OTHER_BOMBERMAN,
                Element.MEAT_CHOPPER
            };

            if (point.IsOutOf(Size))
            {
                return(false);
            }
            bool desicion = false;

            if (!this.IsAt(point.ShiftLeft(1), Element.WALL))
            {
                if (enemy.Contains(this.GetAt(point.ShiftLeft(1))))
                {
                    desicion = true;
                }
                if (!this.IsAt(point.ShiftLeft(2), Element.WALL))
                {
                    if (enemy.Contains(this.GetAt(point.ShiftLeft(2))))
                    {
                        desicion = true;
                    }

                    if (!this.IsAt(point.ShiftLeft(3), Element.WALL))
                    {
                        if (enemy.Contains(this.GetAt(point.ShiftLeft(3))))
                        {
                            desicion = true;
                        }
                    }
                }
            }
            if (!this.IsAt(point.ShiftRight(1), Element.WALL))
            {
                if (enemy.Contains(this.GetAt(point.ShiftRight(1))))
                {
                    desicion = true;
                }
                if (!this.IsAt(point.ShiftRight(2), Element.WALL))
                {
                    if (enemy.Contains(this.GetAt(point.ShiftRight(2))))
                    {
                        desicion = true;
                    }

                    if (!this.IsAt(point.ShiftRight(3), Element.WALL))
                    {
                        if (enemy.Contains(this.GetAt(point.ShiftRight(3))))
                        {
                            desicion = true;
                        }
                    }
                }
            }
            if (!this.IsAt(point.ShiftTop(1), Element.WALL))
            {
                if (enemy.Contains(this.GetAt(point.ShiftTop(1))))
                {
                    desicion = true;
                }
                if (!this.IsAt(point.ShiftTop(2), Element.WALL))
                {
                    if (enemy.Contains(this.GetAt(point.ShiftTop(2))))
                    {
                        desicion = true;
                    }

                    if (!this.IsAt(point.ShiftTop(3), Element.WALL))
                    {
                        if (enemy.Contains(this.GetAt(point.ShiftTop(3))))
                        {
                            desicion = true;
                        }
                    }
                }
            }
            if (!this.IsAt(point.ShiftBottom(1), Element.WALL))
            {
                if (enemy.Contains(this.GetAt(point.ShiftBottom(1))))
                {
                    desicion = true;
                }
                if (!this.IsAt(point.ShiftBottom(2), Element.WALL))
                {
                    if (enemy.Contains(this.GetAt(point.ShiftBottom(2))))
                    {
                        desicion = true;
                    }

                    if (!this.IsAt(point.ShiftBottom(3), Element.WALL))
                    {
                        if (enemy.Contains(this.GetAt(point.ShiftBottom(3))))
                        {
                            desicion = true;
                        }
                    }
                }
            }
            var  percsPoint   = GetPerks();
            bool BonusContain = false;

            //help me

            if (!this.IsAt(point.ShiftLeft(1), Element.WALL))
            {
                if (percsPoint.Contains(point.ShiftLeft(1)))
                {
                    BonusContain = true;
                }
                if (!this.IsAt(point.ShiftLeft(2), Element.WALL))
                {
                    if (percsPoint.Contains((point.ShiftLeft(2))))
                    {
                        BonusContain = true;
                    }

                    if (!this.IsAt(point.ShiftLeft(3), Element.WALL))
                    {
                        if (percsPoint.Contains((point.ShiftLeft(3))))
                        {
                            BonusContain = true;
                        }
                    }
                }
            }
            if (!this.IsAt(point.ShiftRight(1), Element.WALL))
            {
                if (percsPoint.Contains((point.ShiftRight(1))))
                {
                    BonusContain = true;
                }
                if (!this.IsAt(point.ShiftRight(2), Element.WALL))
                {
                    if (percsPoint.Contains((point.ShiftRight(2))))
                    {
                        BonusContain = true;
                    }

                    if (!this.IsAt(point.ShiftRight(3), Element.WALL))
                    {
                        if (percsPoint.Contains((point.ShiftRight(3))))
                        {
                            BonusContain = true;
                        }
                    }
                }
            }
            if (!this.IsAt(point.ShiftTop(1), Element.WALL))
            {
                if (percsPoint.Contains((point.ShiftTop(1))))
                {
                    BonusContain = true;
                }
                if (!this.IsAt(point.ShiftTop(2), Element.WALL))
                {
                    if (percsPoint.Contains((point.ShiftTop(2))))
                    {
                        BonusContain = true;
                    }

                    if (!this.IsAt(point.ShiftTop(3), Element.WALL))
                    {
                        if (percsPoint.Contains((point.ShiftTop(3))))
                        {
                            BonusContain = true;
                        }
                    }
                }
            }
            if (!this.IsAt(point.ShiftBottom(1), Element.WALL))
            {
                if (percsPoint.Contains((point.ShiftBottom(1))))
                {
                    BonusContain = true;
                }
                if (!this.IsAt(point.ShiftBottom(2), Element.WALL))
                {
                    if (percsPoint.Contains((point.ShiftBottom(2))))
                    {
                        BonusContain = true;
                    }

                    if (!this.IsAt(point.ShiftBottom(3), Element.WALL))
                    {
                        if (percsPoint.Contains((point.ShiftBottom(3))))
                        {
                            BonusContain = true;
                        }
                    }
                }
            }

            if (!BonusContain)
            {
                return(desicion);
            }
            return(false);
        }