示例#1
0
    public bool AreTheseCoordinatesAvailable(List <Vector2Int> _coordinates, Direction _direction = Direction.Left)
    {
        //Checks if the potential coordinates exist within the grid and are not already occupied by colored blocks
        for (int i = 0; i < _coordinates.Count; i++)
        {
            if (!allBlocks.ContainsKey(_coordinates[i]) || allBlocks[_coordinates[i]].state > BlockState.None)
            {
                //Checks if the block has reached the bottom or a colored block
                if (_coordinates[i].y < 0 || (_direction == Direction.Down && allBlocks[_coordinates[i]].state > BlockState.None))
                {
                    //Delegate potential
                    mainBlockManager.SetShape();
                    List <GridBlock> _madeBlocks = GetAllMadeLines();
                    if (_madeBlocks.Count >= gridSize.x)
                    {
                        ClearBlocks(_madeBlocks);
                        MoveAllUsedBlocksDown(_madeBlocks.Count / gridSize.x, GetLowestYBlock(_madeBlocks));
                    }
                    if (CheckIfGameOver())
                    {
                        gameController.EndGame();
                    }
                    return(false);
                }
                return(false);
            }
        }

        return(true);
    }