Ejemplo n.º 1
0
 private bool CanMoveTo(Position pos)
 {
     return pos.X < Width && pos.Y < Height &&
            pos.X >= 0 && pos.Y >= 0;
 }
Ejemplo n.º 2
0
 public int this[Position p]
 {
     get { return this[p.X, p.Y]; }
     set { this[p.X, p.Y] = value; }
 }
Ejemplo n.º 3
0
        public bool MoveBy(Position moveBy)
        {
            var current = this.CurrentPosition;
            var newPos = current + moveBy;
            if (!CanMoveTo(newPos))
                return false;

            this.MoveCount++;
            var source = this[current];
            var dest = this[newPos];

            this[current] = dest;
            this[newPos] = source;

            this.CurrentPosition = newPos;

            return true;
        }