Example #1
0
 public void RobotValidMove()
 {
     _map.MoveRelative(new Vector2Int(1, 0));
     Assert.That(_map.GetCurrentPosition(), Is.EqualTo(new Vector2Int(2, 1)));
     _map.MoveRelative(new Vector2Int(0, -1));
     Assert.That(_map.GetCurrentPosition(), Is.EqualTo(new Vector2Int(2, 0)));
 }
    //update explored maze on UI
    void updateExplored()
    {
        if (mazeWidth == 50)
        {
            mazeOffset = 190;
        }
        exploredMaze = exploration.GetExploredMap();
        for (int i = 0; i < exploredMazeObjects.Length; i++)
        {
            Destroy(exploredMazeObjects[i]);
        }
        counter = 0;


        for (int i = 0; i < mazeHeight; i++)
        {
            for (int j = 0; j < mazeWidth; j++)
            {
                Vector3  tempVector = new Vector3(xStart + (xSpace * j) + mazeOffset, 0, yStart - (ySpace * i));
                MazeCell mazeCell   = exploredMaze.GetCell(new Vector2Int(i, j));
                if (mazeCell == null)
                {
                    continue;
                }
                if (mazeCell.IsWallCell() == true)
                {
                    exploredMazeObjects[counter++] = Instantiate(wallPrefab, tempVector, Quaternion.identity);
                }
                else if (mazeCell.IsVisited() == false)
                {
                    exploredMazeObjects[counter++] = Instantiate(floorPrefab, tempVector, Quaternion.identity);
                }
                else if (exploredMaze.GetCell(new Vector2Int(i, j)).IsVisited())
                {
                    exploredMazeObjects[counter++] = Instantiate(visitedFloorPrefab, tempVector, Quaternion.identity);
                }
            }
        }
        Vector2Int vector        = exploredMaze.GetCurrentPosition();
        Vector3    robotPosition = new Vector3(xStart + (xSpace * vector.y) + mazeOffset, 0, yStart - (ySpace * vector.x));

        exploredMazeObjects[counter] = Instantiate(robotPrefab, robotPosition, Quaternion.identity);
        exploringRobot = exploredMazeObjects[counter++];
    }