コード例 #1
0
ファイル: Game.cs プロジェクト: kthompson/GameOfFifteen
 private bool CanMoveTo(Position pos)
 {
     return pos.X < Width && pos.Y < Height &&
            pos.X >= 0 && pos.Y >= 0;
 }
コード例 #2
0
ファイル: Game.cs プロジェクト: kthompson/GameOfFifteen
 public int this[Position p]
 {
     get { return this[p.X, p.Y]; }
     set { this[p.X, p.Y] = value; }
 }
コード例 #3
0
ファイル: Game.cs プロジェクト: kthompson/GameOfFifteen
        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;
        }