Пример #1
0
 public SwitchMode Compare(Vector target)
 {
     if (target.Y < Position.Y)
         return SwitchMode.Up;
     else if (target.Y > Position.Y)
         return SwitchMode.Down;
     else
         throw new ArgumentException("Invalid target {target}.");
 }
Пример #2
0
 public EndTrack(Vector position, Direction direction)
     : base(position, direction)
 {
 }
Пример #3
0
 public StartTrack(Vector position, Direction direction)
     : base(position, direction)
 {
 }
Пример #4
0
        public BaseTrack[] GetTracksFacing(Vector position, params Direction[] directions)
        {
            var results = new List<BaseTrack>();

            Vector pos;
            BaseTrack target;

            foreach (var direction in directions)
            {
                if (direction == Direction.None)
                    continue;

                pos = position.Facing(direction);
                target = GetTrackAt(pos);

                if (target == null)
                    continue;

                results.Add(target);
            }

            return results.ToArray();
        }
Пример #5
0
 public SwitchTrack(Vector position, Direction direction, ConsoleKey key)
     : base(position, direction)
 {
     _key = key;
     _mode = SwitchMode.Down;
 }
Пример #6
0
        public BaseTrack GetTrackAt(Vector position)
        {
            foreach (var track in _tracks)
                if (track.Position.Equals(position))
                    return track;

            return null;
        }
Пример #7
0
 public BaseTrack(Vector position, Direction direction)
 {
     _position = position;
     _direction = direction;
 }
Пример #8
0
 public DefaultTrack(Vector position, Direction direction)
     : base(position, direction)
 {
 }
Пример #9
0
 public SwitchOutTrack(Vector position, Direction direction, ConsoleKey key)
     : base(position, direction, key)
 {
 }
Пример #10
0
 public bool Equals(Vector other)
 {
     return (X == other.X) && (Y == other.Y);
 }