Exemplo n.º 1
0
    void RecurseNeighbourPowerBricks(BrickData brick, List <BrickData> visited)
    {
        if (visited.Contains(brick) || !LXFMLHelper.IsPowerBrick(brick.design.id, brick.materialId))
        {
            return;
        }
        else
        {
            visited.Add(brick);
        }

        foreach (BrickData connected in brick.NeighbourBricks)
        {
            RecurseNeighbourPowerBricks(connected, visited);
        }
    }
Exemplo n.º 2
0
    void AddLasers(List <BrickData> bricksList, int direction)
    {
        for (int i = 0; i < bricksList.Count; i++)
        {
            if (LXFMLHelper.IsPowerBrick(bricksList[i].design.id, bricksList[i].materialId))
            {
                //Check upper and lower bricks
                int     numUpperSlots = LXFMLHelper.UpperSlots(bricksList[i].design.id);
                int     numLowerSlots = LXFMLHelper.LowerSlots(bricksList[i].design.id);
                Vector2 brickOrigin   = GetBrickOrigin(bricksList[i].id);

                int inc            = 0;
                int j              = Mathf.RoundToInt(brickOrigin.x);
                int numUpperBricks = 0;


                while (inc < numUpperSlots)
                {
                    LXFMLCell upperCell = _grid.GetCellAt(j, (int)brickOrigin.y + bricksList[i].design.height);
                    if (upperCell != null && !upperCell.IsEmpty)
                    {
                        if (upperCell.Data.Brick.design.type == BrickType.Normal || upperCell.Data.Brick.design.type == BrickType.SlopeDown || upperCell.Data.Brick.design.type == BrickType.CurveOut)
                        {
                            numUpperBricks++;
                        }
                        else
                        {
                            if (upperCell.Data.IsOrigin)
                            {
                                numUpperBricks++;
                            }
                        }
                    }
                    j += bricksList[i].Orientation;
                    inc++;
                }

                inc = 0;
                j   = Mathf.RoundToInt(brickOrigin.x);
                int numLowerBricks = 0;

                while (inc < numLowerSlots)
                {
                    LXFMLCell lowerCell = _grid.GetCellAt(j, (int)brickOrigin.y - 1);
                    if (lowerCell != null && !lowerCell.IsEmpty)
                    {
                        if (lowerCell.Data.Brick.design.type == BrickType.Normal || lowerCell.Data.Brick.design.type == BrickType.SlopeUp || lowerCell.Data.Brick.design.type == BrickType.CurveIn)
                        {
                            numLowerBricks++;
                        }
                        else
                        {
                            if (lowerCell.Data.IsOrigin)
                            {
                                numLowerBricks++;
                            }
                            else
                            {
                                if (j == GetBrickOrigin(lowerCell.Data.Brick.id).x)
                                {
                                    numLowerBricks++;
                                }
                            }
                        }
                    }
                    j += bricksList[i].Orientation;
                    inc++;
                }

                if (numLowerBricks == numLowerSlots && numUpperBricks == numUpperSlots)
                {
                    CreateLaser(bricksList[i], direction);
                }
            }
        }
    }