Example #1
0
        public GameData MakeMove(Cell[] path)
        {
            var resultMap = Map.Clone() as CellType[, ];

            var keeperCell = path[0];
            var boxCell    = path[path.Length - 1];
            var targetCell = GetTargetCell(path[path.Length - 2], boxCell, Map);

            resultMap[keeperCell.X, keeperCell.Y] = initialGameData.Map[keeperCell.X, keeperCell.Y] == CellType.LOCATION ? CellType.LOCATION : CellType.EMPTY;
            resultMap[boxCell.X, boxCell.Y]       = initialGameData.Map[boxCell.X, boxCell.Y] == CellType.LOCATION ? CellType.KEEPER_ON_LOCATION : CellType.KEEPER;
            resultMap[targetCell.X, targetCell.Y] = initialGameData.Map[targetCell.X, targetCell.Y] == CellType.LOCATION ? CellType.BOX_ON_LOCATION : CellType.BOX;

            var gameData = new GameData(resultMap);

            gameData.initialGameData = this.initialGameData;

            return(gameData);
        }