public void UpdateList(List <IMazeElement> _mazeElementsToProcess, Direction _processDirection, bool newIsMazeWallForRootMazeElement)
    {
        mazeElementsToProcess = _mazeElementsToProcess;

        Vector2 LastMouseClickMazeElementIndex = mouseBoundary.GetLastMouseClickMazeElementIndex();
        Vector2 CurrenMouseOntMazeElementIndex = mouseBoundary.GetCurrentMouseOnMazeElementIndex();

        AddToListMouseClickOnMazeElement(LastMouseClickMazeElementIndex, newIsMazeWallForRootMazeElement);
        switch (_processDirection)
        {
        case Direction.Left:
        {
            for (int i = (int)LastMouseClickMazeElementIndex.x - 1; i >= (int)CurrenMouseOntMazeElementIndex.x; i--)
            {
                IMazeElement MazeElementBoundary = planeBuilder.GetFromMazeArray(i, (int)LastMouseClickMazeElementIndex.y);
                AddToListIfNotBelongToAnotherWall(MazeElementBoundary, newIsMazeWallForRootMazeElement);
            }

            break;
        }

        case Direction.Right:
        {
            for (int i = (int)LastMouseClickMazeElementIndex.x + 1; i <= (int)CurrenMouseOntMazeElementIndex.x; i++)
            {
                IMazeElement MazeElementBoundary = planeBuilder.GetFromMazeArray(i, (int)LastMouseClickMazeElementIndex.y);
                AddToListIfNotBelongToAnotherWall(MazeElementBoundary, newIsMazeWallForRootMazeElement);
            }
            break;
        }

        case Direction.Up:
        {
            for (int i = (int)LastMouseClickMazeElementIndex.y - 1; i >= (int)CurrenMouseOntMazeElementIndex.y; i--)
            {
                IMazeElement MazeElementBoundary = planeBuilder.GetFromMazeArray((int)LastMouseClickMazeElementIndex.x, i);
                AddToListIfNotBelongToAnotherWall(MazeElementBoundary, newIsMazeWallForRootMazeElement);
            }

            break;
        }

        case Direction.Down:
        {
            for (int i = (int)LastMouseClickMazeElementIndex.y + 1; i <= (int)CurrenMouseOntMazeElementIndex.y; i++)
            {
                IMazeElement MazeElementBoundary = planeBuilder.GetFromMazeArray((int)LastMouseClickMazeElementIndex.x, i);
                AddToListIfNotBelongToAnotherWall(MazeElementBoundary, newIsMazeWallForRootMazeElement);
            }
            break;
        }

        default:
        {
            throw new System.NotImplementedException();
        }
        }
    }
    public void ChangeMazeElementsInListFromTo(IMouse MouseBoundry, Direction processDirection, List <IMazeElement> mazeElementsToProcess, bool newIsMazeWallForRoot)
    {
        Vector2 firstMazeElementToReverseIndex = MouseBoundry.GetLastMouseClickMazeElementIndex();
        Vector2 lastMazeElementToReverseIndex  = MouseBoundry.GetCurrentMouseOnMazeElementIndex();;
        Change  change;

        switch (processDirection)
        {
        case Direction.Left:
        {
            change = new Change(ChangeOnLeftDirection);
            break;
        }

        case Direction.Right:
        {
            change = new Change(ChangeOnRightDirection);
            break;
        }

        case Direction.Up:
        {
            change = new Change(ChangeOnUpDirection);
            break;
        }

        case Direction.Down:
        {
            change = new Change(ChangeOnDownDirection);
            break;
        }

        default:
        {
            throw new System.NotImplementedException();
        }
        }

        change(firstMazeElementToReverseIndex, lastMazeElementToReverseIndex, mazeElementsToProcess, newIsMazeWallForRoot);
    }
Beispiel #3
0
    public void Execute()
    {
        mazeElementsInLineUpdateOffset -= Time.deltaTime;
        if (mazeElementsInLineUpdateOffset <= 0)
        {
            mazeElementsInLineUpdateOffset = 0.5f;

            Direction processDirection = processDirectionUpdate.ExecuteUpdate();
            if (processDirectionUpdate.WasProcessDirectionChange())
            {
                mazeElementsListToProcess.ReverseFromToInList(mouse.GetLastMouseClickMazeElementIndex(), farthestMazeEleFromLastMouseClickMazeEle.CurrentFarthestMazeElementIndex, processDirectionUpdate.GetLastCheckDirection());
            }

            farthestMazeEleFromLastMouseClickMazeEle.UpdateIfCurrentMazeEleIsGreater(processDirection);

            if (DidCurrentMazeEleRewound(processDirection))
            {
                RewoundProcess(processDirection);
            }

            ProgressProcess(processDirection);
        }
    }
 public void SetNewFarthestMazeEleOnHorizontalLineOfLastClickMazeEle()
 {
     CurrentFarthestMazeElementIndex = new Vector2(MouseBoundary.GetCurrentMouseOnMazeElementIndex().x, MouseBoundary.GetLastMouseClickMazeElementIndex().y);
 }