public BoardPosition GetMovePosition() { BoardPosition position = RobotStatus.GetPosition(); BoardPosition pos = null; if (position != null) { Tuple <int, char> moveInfo = GetMoveInfo(position.Direction); int blockSize = BoardStatus.GetBlockSize(); int offset = BoardStatus.GetOffset(); int boardHeight = BoardStatus.GetBoardDimension().Height; pos = position.Clone(); switch (moveInfo.Item2) { case 'X': int XBlock = position.XBlock + moveInfo.Item1; int xBlock = (position.XBlock - 1) + moveInfo.Item1; pos.XBlock = XBlock; pos.X = (xBlock * blockSize) + offset; break; case 'Y': int YBlock = position.YBlock + moveInfo.Item1; pos.YBlock = YBlock; pos.Y = boardHeight - (YBlock * blockSize) + offset; break; } Directions dir = (Directions)Enum.Parse(typeof(Directions), GetDirectionName(position.Direction)); RobotStatus.SetDirectionOrigin((char)dir); } return(pos); }
public BoardPosition GetPlacePosition(int XBlock, int YBlock, char F) { int xBlock = XBlock - 1; int yBlock = YBlock; int blockSize = BoardStatus.GetBlockSize(); int offset = BoardStatus.GetOffset(); int boardHeight = BoardStatus.GetBoardDimension().Height; BoardPosition position = new BoardPosition() { XBlock = XBlock, YBlock = YBlock, Direction = GetInternalDirection(F), X = (xBlock * blockSize) + offset, Y = boardHeight - (yBlock * blockSize) + offset }; RobotStatus.SetDirectionOrigin(F); return(position); }