/// <summary> /// 移动棋子到新的位置 /// </summary> /// <param name="chess">待移动的棋子</param> /// <param name="moveDirection">移动方向</param> /// <param name="newBlankPosition">新的空白格子</param> private void MoveChessToNext(ChessBase chess, Direction moveDirection, BlankPosition newBlankPosition) { int oldPosition = chess.Position; int newPosition = chess.NextPosition; this.BlankPosition = chess.ChessMove(newBlankPosition, moveDirection, Common.GridColumns); chess.Position = chess.NextPosition; this.MoveAnimation(chess.Element, newPosition, oldPosition, moveDirection); }
/// <summary> /// 尝试将棋子移动到下一个指定的位置 /// </summary> /// <param name="chess">待移动的棋子</param> /// <param name="moveDirection">移动方向</param> /// <param name="newBlankPosition">新的空白格子</param> private void TryMoveToNext(ChessBase chess, Direction moveDirection, BlankPosition newBlankPosition) { List <ChessBase> chessList = this.CurrentNode.CurrentCode.GetChessList(); chessList[this.ChessIndex].Position = chess.NextPosition; long nodeCode = chessList.GetLayoutCode(); if (nodeCode != this.CurrentNode.ParentCode && !this.StepCodeDict.Keys.Contains(nodeCode)) { PathNode node = new PathNode { CurrentCode = nodeCode, ParentCode = this.CurrentNode.CurrentCode, //BlankPosition = chess.ChessMove(this.CurrentNode.BlankPosition, moveDirection, Common.GridColumns), BlankPosition = chess.ChessMove(newBlankPosition, moveDirection, Common.GridColumns), IsLast = chessList.LayoutFinished() }; this.NextNodeList.Add(node); } }