Ejemplo n.º 1
0
        private List <Block> GetBlocksForRemoval(Cell cell)
        {
            if (cell.Block == null || cell.Block.BlockParams == null)
            {
                Debug.LogError($"Cell {cell.BoardX},{cell.BoardY} has no block or block params!");
                return(null);
            }

            var onDest = cell.Block.BlockParams.OnClickDestruction;

            if (onDest.LinkOtherBlocksByColor)
            {
                return(GetColoredLinedBlocks(cell));
            }

            return(BoardSearch.GetTargetBlocksForRemoval(cell, onDest, _levelData, Map));
        }
Ejemplo n.º 2
0
        private List <Block> GetColoredLinedBlocks(Cell cell)
        {
            var onDest = cell.Block.BlockParams.OnClickDestruction;

            if (onDest.TargetBlocks != null && onDest.TargetBlocks.Count <= 0)
            {
                Debug.Log("No target was selected for color linking");
                return(null);
            }

            var target0 = GetCell(BoardSearch.GetPosDueToTargetOffset(cell.BoardPos, onDest.TargetBlocks[0]));

            if (target0 == null)
            {
                Debug.LogError($"Target0 was not fount on board, pos {cell.BoardPos}");
                return(null);
            }

            if (target0.IsEmpty || target0.Block.BlockParams.Color == null)
            {
                Debug.LogError($"Target0 color was not fount, pos {target0.BoardX},{target0.BoardY}");
                return(null);
            }

            //Currently for linking only use info of first element
            var linkedBlocks = onDest.OverrideTargetColor == null
                ? SearchColorLink(target0.Block)
                : SearchColorLink(target0.Block, onDest.OverrideTargetColor);

            if (linkedBlocks != null && linkedBlocks.Count >= onDest.MinLinkingNumber)
            {
                return(linkedBlocks);
            }
            Debug.Log("Not enough blocks for destruction. Will return null");
            return(null);
        }
Ejemplo n.º 3
0
 private void GeneratePathfindingGraph()
 {
     _graph = BoardSearch.GeneratePathfindingGraph(_levelData, Map);
 }
Ejemplo n.º 4
0
 private void DoForEachCell(Action <Cell, int, int> actionForCell)
 {
     BoardSearch.DoForEachCell(actionForCell, _levelData, Map);
 }
Ejemplo n.º 5
0
 private Cell GetCell(int x, int y, bool showLogs = true)
 {
     return(BoardSearch.GetCell(x, y, _levelData, Map, showLogs));
 }