public MazeSaveTextCreator(IPlaneBuilder _planeBuilder, IPlaneElementsBounds _elementsBounds, List <string> _saveText, IMazeSpecialElementsSeeker _saveSystemBoundary) { planeBuilder = _planeBuilder; elementsBounds = _elementsBounds; saveText = _saveText; saveSystemBoundary = _saveSystemBoundary; }
public void CreateSaveText_ContainCheck() { List <Vector2> listOfMazeElementsThatAreMazeWall = new List <Vector2>(); listOfMazeElementsThatAreMazeWall.Add(new Vector2(0, 0)); listOfMazeElementsThatAreMazeWall.Add(new Vector2(0, 1)); listOfMazeElementsThatAreMazeWall.Add(new Vector2(0, 3)); listOfMazeElementsThatAreMazeWall.Add(new Vector2(0, 4)); Vector3 gamePlaneCenter = new Vector3(0, 0, 0); Vector3 gamePlaneSize = new Vector3(10, 10, 10); IPlaneElementsBounds planeElementsBounds = GetPlaneElementsBounds(new Bounds(new Vector3(0, 0, 0), new Vector3(10, 10, 10))); IPlaneBuilder planeBuilder = GetPlaneBuilderMock(new Vector2(10, 10), listOfMazeElementsThatAreMazeWall); MazeSaveTextCreator mazeSaveTextCreator = new MazeSaveTextCreator(planeBuilder, planeElementsBounds, new List <string>(), Substitute.For <IMazeSpecialElementsSeeker>()); List <string> saveTextToCheck = mazeSaveTextCreator.CreateSaveText(); Assert.AreEqual(saveTextToCheck[0].Contains(gamePlaneCenter.ToString()), true);// Bounds format: "Center: (0,0, 0,0, 0,0), Extents: (5,0, 5,0, 5,0)" Assert.AreEqual(saveTextToCheck[0].Contains("5,0, 5,0, 5,0"), true); Assert.AreEqual(saveTextToCheck[3].Contains("10,0, 10,0"), true); Assert.AreEqual(saveTextToCheck[4].Contains("0,0, 0,0"), true); Assert.AreEqual(saveTextToCheck[5].Contains("0,0, 1,0"), true); Assert.AreEqual(saveTextToCheck[6].Contains("0,0, 3,0"), true); Assert.AreEqual(saveTextToCheck[7].Contains("0,0, 4,0"), true); }
public PlaneBuilder(IFirstUpLeftMazeElementPositionProvider _firstUpLeftMazeElementPositionProvider, INumberOfMazeElementsInGamePlaneArea _numberOfMazeElementsInGamePlaneArea, IPlaneBuilder _planeBuilder, IPlaneElementsBounds _planeElementsBounds) { firstUpLeftMazeElementPositionProvider = _firstUpLeftMazeElementPositionProvider; numberOfMazeElementsInGamePlaneArea = _numberOfMazeElementsInGamePlaneArea; PlaneBuilder = _planeBuilder; PlaneElementsBounds = _planeElementsBounds; }
public NeighboursPathFindParametersProcessor(IPlaneBuilder _planeBuilder, IMazeElement _destinationMazeElement, IAStarDistanceHeuristic _aStarDistanceHeuristic) { planeBuilder = _planeBuilder; destinationMazeElement = _destinationMazeElement; aStarDistanceHeuristic = _aStarDistanceHeuristic; }
List <IMazeElement> CreateNeighbourList(IPlaneBuilder planeBuilder, IMazeElement mazeElement) { List <IMazeElement> mazeElementsList = new List <IMazeElement>(); mazeElementsList.Add(planeBuilder.GetFromMazeArray((int)mazeElement.Index.x - 1, (int)mazeElement.Index.y)); mazeElementsList.Add(planeBuilder.GetFromMazeArray((int)mazeElement.Index.x + 1, (int)mazeElement.Index.y)); mazeElementsList.Add(planeBuilder.GetFromMazeArray((int)mazeElement.Index.x, (int)mazeElement.Index.y - 1)); mazeElementsList.Add(planeBuilder.GetFromMazeArray((int)mazeElement.Index.x, (int)mazeElement.Index.y + 1)); return(mazeElementsList); }
public GamePlaneLoader(IPlaneBuilder _planeBuilder, ISaveTextReader _saveTextReader, IGamePlaneDeleter _gamePlaneDeleter, IMazeWallseLoader _mazeWallseLoader, IMazeInOutPoints _mazeInOutPoints) { planeBuilder = _planeBuilder; saveTextReader = _saveTextReader; gamePlaneDeleter = _gamePlaneDeleter; mazeWallseLoader = _mazeWallseLoader; mazeInOutPoints = _mazeInOutPoints; }
public DijkstraPathFinder(IPlaneBuilder _planeBuilder, IUnexploredMazeElements _unexploredMazeElements, IMazeElement _startMazeElement, IMazeElement _destinationMazeElement, IPathFindProcessMetric _pathFindProcessMetric) { planeBuilder = _planeBuilder; unexploredMazeElements = _unexploredMazeElements; startMazeElement = _startMazeElement; destinationMazeElement = _destinationMazeElement; pathFindProcessMetric = _pathFindProcessMetric; }
public void _2_2_GetNeighboursOfMazeElement_CheckIfresultIsEqualWithCorrect() { Vector2 gamePlaneSize = new Vector2(10, 10); IPlaneBuilder planeBoundry = GetPlaneBuilderMock(gamePlaneSize); PlaneBuilder planeBuilder = Substitute.For <PlaneBuilder>(); planeBuilder.SetPlaneController(planeBoundry); IMazeElement currentMazeElement = planeBoundry.GetFromMazeArray(2, 8); List <IMazeElement> neighbourMazeElementList = planeBuilder.GetNeighboursOfMazeElement(currentMazeElement); List <IMazeElement> list = CreateNeighbourList(planeBoundry, currentMazeElement); Assert.AreEqual(neighbourMazeElementList, list); }
public void CreateSaveText_CountCheck() { List <Vector2> listOfMazeElementsThatAreMazeWall = new List <Vector2>(); listOfMazeElementsThatAreMazeWall.Add(new Vector2(0, 0)); listOfMazeElementsThatAreMazeWall.Add(new Vector2(0, 1)); listOfMazeElementsThatAreMazeWall.Add(new Vector2(0, 3)); listOfMazeElementsThatAreMazeWall.Add(new Vector2(0, 4)); IPlaneElementsBounds planeElementsBounds = GetPlaneElementsBounds(new Bounds(new Vector3(0, 0, 0), new Vector3(10, 10, 10))); IPlaneBuilder planeBuilder = GetPlaneBuilderMock(new Vector2(10, 10), listOfMazeElementsThatAreMazeWall); MazeSaveTextCreator mazeSaveTextCreator = new MazeSaveTextCreator(planeBuilder, planeElementsBounds, new List <string>(), Substitute.For <IMazeSpecialElementsSeeker>()); List <string> saveTextToCheck = mazeSaveTextCreator.CreateSaveText(); Assert.AreEqual(saveTextToCheck.Count, 8); }
public void _1_1_UpdateMazeElementsToProcessList_DirectionRight_CountCheck() { bool newIsMazeWallForRootMazeElement = true; Vector2 currentMouseOnMazeElementIndex = new Vector2(5, 0); Vector2 lastMouseClickMazeElementIndex = new Vector2(0, 0); Vector2 gamePlaneSize = new Vector2(10, 10); Vector2 indexesOfMazeElementsBelongingToAnotherMazeWall = new Vector2(3, 0); IMouse mouse = GetMouseMock(currentMouseOnMazeElementIndex, lastMouseClickMazeElementIndex); IPlaneBuilder planeBuilder = GetPlaneBuilder(gamePlaneSize, indexesOfMazeElementsBelongingToAnotherMazeWall); Direction processDirection = Direction.Right; List <IMazeElement> mazeElementsToProcess = new List <IMazeElement>(); MazeElementsListUpdate mazeElementsListToProcess = new MazeElementsListUpdate(mouse, planeBuilder); mazeElementsListToProcess.UpdateList(mazeElementsToProcess, processDirection, newIsMazeWallForRootMazeElement); Assert.AreEqual(mazeElementsListToProcess.mazeElementsToProcess.Count, 5); }
public void SetNeighboursForMazeElement(IPlaneBuilder planeBuilder) { Vector2 gamePlaneSize = planeBuilder.IntagerNumberOfMazeElementsOnXAndY; for (int i = 0; i < (int)gamePlaneSize.x; i++) { for (int j = 0; j < (int)gamePlaneSize.y; j++) { IMazeElement mazeElement = planeBuilder.GetFromMazeArray(i, j); List <IMazeElement> NeighboursList = new List <IMazeElement>(); //Debug.Log(planeBuilder.GetFromMazeArray(Mathf.Clamp((int)mazeElement.Index.x - 1, 0, (int)planeBuilder.IntagerNumberOfMazeElementsOnXAndY.x - 1), (int)mazeElement.Index.y).Index); NeighboursList.Add(planeBuilder.GetFromMazeArray(Mathf.Clamp((int)mazeElement.Index.x - 1, 0, (int)planeBuilder.IntagerNumberOfMazeElementsOnXAndY.x - 1), (int)mazeElement.Index.y)); NeighboursList.Add(planeBuilder.GetFromMazeArray(Mathf.Clamp((int)mazeElement.Index.x + 1, 0, (int)planeBuilder.IntagerNumberOfMazeElementsOnXAndY.x - 1), (int)mazeElement.Index.y)); NeighboursList.Add(planeBuilder.GetFromMazeArray((int)mazeElement.Index.x, Mathf.Clamp((int)mazeElement.Index.y - 1, 0, (int)planeBuilder.IntagerNumberOfMazeElementsOnXAndY.y - 1))); NeighboursList.Add(planeBuilder.GetFromMazeArray((int)mazeElement.Index.x, Mathf.Clamp((int)mazeElement.Index.y + 1, 0, (int)planeBuilder.IntagerNumberOfMazeElementsOnXAndY.y - 1))); planeBuilder.GetNeighboursOfMazeElement(planeBuilder.GetFromMazeArray(i, j)).Returns(NeighboursList); } } }
public void Awake() { Mouse = GameObject.Find("GameMaster").GetComponent <MouseBoundry>(); planeBuilder = GameObject.Find("Plane").GetComponent <PlaneBoundry>(); MazeEditor = new MazeEditor( new MazeElementProcessing( new FirstMazeElementProcessing(Mouse), new MazeElementsInLineProcessing( new ProcessDirectionUpdate(Mouse), new FarthestMazeElementFromLastMouseClickMazeElement(Mouse), Mouse, new MazeElementsListToProcess( new MazeElementsListUpdate(Mouse, planeBuilder), new ReversalOfMazeElements(), new ChangesOfMazeElements(), new MazeElementsListFinalProcess()))), Mouse, this); }
public virtual IPathFindAlgo CreatePathFindAlgo( EPathFindAlgorithms ePathFindAlgorithm, IMazeSpecialElementsSeeker pathFindAlgoBoundary, List <IMazeElement> pathFromStartToEnd, IPlaneBuilder planeBuilder, List <IMazeElement> unexploredMazeElementsList, List <IMazeElement> openList, List <IMazeElement> closeList, IPathFindProcessMetric pathFindProcessMetric) { PathFindAlgo pathFindAlgo = null; switch (ePathFindAlgorithm) { case EPathFindAlgorithms.DijkstraAlgorithm: pathFindAlgo = new PathFindAlgo( pathFindAlgoBoundary, pathFromStartToEnd, new DijkstraPathFinder( planeBuilder, new UnexploredMazeElements( planeBuilder, unexploredMazeElementsList), pathFindAlgoBoundary.FindStartPlaceForPathFinding(), pathFindAlgoBoundary.FindDestinationPlaceForPathFinding(), pathFindProcessMetric), new MazeRestarter( planeBuilder)); break; case EPathFindAlgorithms.EuclideanAStar: pathFindAlgo = new PathFindAlgo( pathFindAlgoBoundary, pathFromStartToEnd, new AStarPathFinder( pathFindAlgoBoundary.FindStartPlaceForPathFinding(), pathFindAlgoBoundary.FindDestinationPlaceForPathFinding(), new OpenCloseListController( openList, closeList), new NeighboursPathFindParametersProcessor( planeBuilder, pathFindAlgoBoundary.FindDestinationPlaceForPathFinding(), new AStarEuclideanDistanceHeuristic()), pathFindProcessMetric), new MazeRestarter( planeBuilder)); break; case EPathFindAlgorithms.ManhattanAStar: pathFindAlgo = new PathFindAlgo( pathFindAlgoBoundary, pathFromStartToEnd, new AStarPathFinder( pathFindAlgoBoundary.FindStartPlaceForPathFinding(), pathFindAlgoBoundary.FindDestinationPlaceForPathFinding(), new OpenCloseListController( openList, closeList), new NeighboursPathFindParametersProcessor( planeBuilder, pathFindAlgoBoundary.FindDestinationPlaceForPathFinding(), new AStarManhattanDistanceHeuristic()), pathFindProcessMetric), new MazeRestarter( planeBuilder)); break; } return(pathFindAlgo); }
public MazeElementsListUpdate(IMouse _mouseBoundary, IPlaneBuilder _planeBuilder) { mouseBoundary = _mouseBoundary; planeBuilder = _planeBuilder; }
public Director(IPlaneBuilder builder) { _builder = builder; }
public MazeMetric(IPlaneBuilder _planeBuilder) { planeBuilder = _planeBuilder; }
public GamePlaneDeleter(IPlaneBuilder _planeBuilder) { planeBuilder = _planeBuilder; }
public MazeRestarter(IPlaneBuilder _planeBuilder) { planeBuilder = _planeBuilder; }
public FirstUpLeftMazeElementPositionProvider(IPlaneBuilder _planeController, IPlaneElementsBounds _planeElementsBounds) { planeController = _planeController; planeElementsBounds = _planeElementsBounds; }
public void SetPlaneController(IPlaneBuilder _planeBuilder) { PlaneBuilder = _planeBuilder; }
public UnexploredMazeElements(IPlaneBuilder _planeBuilder, List <IMazeElement> _unexploredMazeElementsList) { planeBuilder = _planeBuilder; unexploredMazeElementsList = _unexploredMazeElementsList; }
public void SetBuilder(IPlaneBuilder b) { this.builder = b; }