Beispiel #1
0
 public static Direction ToDirection(this Bomberman.Api.Point for_, Bomberman.Api.Point to, params Bomberman.Api.Element[] preset)
 {
     if (to.IsElementAs(preset))
     {
         return(for_.ToDirection(to));
     }
     return(Direction.Stop);
 }
Beispiel #2
0
 public static IEnumerable <Bomberman.Api.Point> GetNear(this Bomberman.Api.Point point, params Bomberman.Api.Element[] preset)
 {
     foreach (var near in point.GetNear())
     {
         if (near.IsElementAs(preset))
         {
             yield return(near);
         }
     }
 }
Beispiel #3
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 #4
0
 public static Direction ToDirectionOrStop(this Bomberman.Api.Point for_, Bomberman.Api.Point to)
 {
     if (for_ == to)
     {
         return(Direction.Stop);
     }
     else
     {
         return(for_.ToDirection(to));
     }
 }
Beispiel #5
0
 // Не проверено
 public static IEnumerable <Bomberman.Api.Point> GetNearOfRadius(this Bomberman.Api.Point point, int radius, bool isKrest, params Bomberman.Api.Element[] preset)
 {
     for (var i = point.Y - radius; i < point.Y + radius; i++)
     {
         var endJ = 2 * radius - Math.Abs(point.X - i);
         for (var j = Math.Abs(point.X - i); j < endJ; j++)
         {
             yield return(new Bomberman.Api.Point(j, i));
         }
     }
 }
Beispiel #6
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 #7
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 #8
0
 public static bool IsElementAs(this Bomberman.Api.Point point, params Bomberman.Api.Element[] preset) => preset.Contains(point.ToElement());