コード例 #1
0
ファイル: BattleField.cs プロジェクト: FoC-/SnakeBattle.Net
 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");
     }
 }
コード例 #2
0
ファイル: FieldComparer.cs プロジェクト: FoC-/SnakeBattle.Net
 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);
 }
コード例 #3
0
ファイル: BattleField.cs プロジェクト: FoC-/SnakeBattle.Net
 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] };
 }