Example #1
0
 public Cell<Content> RelativeCell(Direction direction, Position fieldHead, Position chipHead, Position chipCell)
 {
     switch (direction)
     {
         case Direction.North:
             return NorthView(fieldHead, chipHead, chipCell);
         case Direction.West:
             return WestView(fieldHead, chipHead, chipCell);
         case Direction.East:
             return EastView(fieldHead, chipHead, chipCell);
         case Direction.South:
             return SouthView(fieldHead, chipHead, chipCell);
         default:
             throw new ArgumentOutOfRangeException("direction");
     }
 }
Example #2
0
 private static bool FieldIsSelf(Fighter fighter, Position fieldCell)
 {
     if (fighter.Head != null && fighter.Head.X == fieldCell.X && fighter.Head.Y == fieldCell.Y) return true;
     if (fighter.Tail != null && fighter.Tail.X == fieldCell.X && fighter.Tail.Y == fieldCell.Y) return true;
     return fighter.Body.Any(b => b.X == fieldCell.X && b.Y == fieldCell.Y);
 }
Example #3
0
 private Cell<Content> SouthView(Position fieldHead, Position chipHead, Position chipCell)
 {
     var x = fieldHead.X - chipCell.X + chipHead.X;
     var y = fieldHead.Y - chipCell.Y + chipHead.Y;
     return new Cell<Content> { X = x, Y = y, Content = this[x, y] };
 }