示例#1
0
    public void RemoveTilesInSelectionField()
    {
        List <Vector2> previousSelectionFieldAvailableGridPositions = selectionFieldAvailableGridPositions;
        List <Vector2> nextSelectionFieldAvailableGridPositions     = new List <Vector2>();

        List <Vector2> selectionFieldTileGridPositions = TileGrid.Instance.FilterNonEmptyOrNonTiles(SelectionFieldStatusView.SelectionFieldGridPositions);

        foreach (Vector2 selectionFieldGridPosition in selectionFieldTileGridPositions)
        {
            if (!TileGenerator.CheckGridPositionEmptyOrNotUserGenerated(selectionFieldGridPosition) || CheckGridPositionPreviouslyOccupiedByLastSelectionField(selectionFieldGridPosition))
            {
                nextSelectionFieldAvailableGridPositions.Add(selectionFieldGridPosition);
            }
        }

        List <Vector2> outdatedSelectionFieldAvailableGridPositions = previousSelectionFieldAvailableGridPositions.Except(nextSelectionFieldAvailableGridPositions).ToList();
        List <Vector2> newSelectionFieldAvailableGridPositions      = nextSelectionFieldAvailableGridPositions.Except(previousSelectionFieldAvailableGridPositions).ToList();

        TileGenerator.SpawnTiles(outdatedSelectionFieldAvailableGridPositions);
        TileGenerator.RemoveTiles(newSelectionFieldAvailableGridPositions, true);

        selectionFieldAvailableGridPositions = nextSelectionFieldAvailableGridPositions;
    }
示例#2
0
    public void ReplaceNewTilesInSelectionField()
    {
        List <Vector2> rectangulatedTileGrid = rectangulatedTileGridStatus.LastUpdatedRectangulatedTileGrid;

        //levelVolume

        //Vector2 selectionFieldStartPosition = LevelEditorSelectionFieldStatusView.SelectionFieldStartGridPosition;

        //GridHelper.SortIntoRectangles(Grid)

        List <Vector2> previousSelectionFieldAvailableGridPositions = selectionFieldAvailableGridPositions;
        List <Vector2> nextSelectionFieldAvailableGridPositions     = new List <Vector2>();

        List <Vector2> selectionFieldTileGridPositions = TileGrid.Instance.FilterNonEmptyOrNonTiles(SelectionFieldStatusView.SelectionFieldGridPositions);

        foreach (Vector2 selectionFieldGridPosition in selectionFieldTileGridPositions)
        {
            if (TileGenerator.CheckGridPositionEmptyOrNotUserGenerated(selectionFieldGridPosition) || CheckGridPositionPreviouslyOccupiedByLastSelectionField(selectionFieldGridPosition))
            {
                nextSelectionFieldAvailableGridPositions.Add(selectionFieldGridPosition);
            }
        }

        List <Vector2> outdatedSelectionFieldAvailableGridPositions = previousSelectionFieldAvailableGridPositions.Except(nextSelectionFieldAvailableGridPositions).ToList();
        List <Vector2> newSelectionFieldAvailableGridPositions      = nextSelectionFieldAvailableGridPositions.Except(previousSelectionFieldAvailableGridPositions).ToList();

        if (newSelectionFieldAvailableGridPositions.Count > spawnLimit)
        {
            selectionFieldTileSpawnLimitReachedEvent.Dispatch();
            return;
        }

        TileGenerator.RemoveTiles(outdatedSelectionFieldAvailableGridPositions, true, newSelectionFieldAvailableGridPositions);
        TileGenerator.SpawnTiles(newSelectionFieldAvailableGridPositions);

        selectionFieldAvailableGridPositions = nextSelectionFieldAvailableGridPositions;
    }