private void Awake()
    {
        m_Parent         = GetComponentInParent <BricksRow>();
        m_ParentParticle = GetComponentInParent <ParticleSystem>();

        m_ParticleColor = new Color(0, 1, 0, 0.5f);
    }
        //Cria uma nova BrickRow, baseado no número máximo de Bricks que ela pode conter
        private BricksRow GenerateBrickRow(int maxBricks)
        {
            BricksRow row = new BricksRow();

            Random random = new Random();

            int next = random.Next(1, maxBricks + 1); //Pois ele exclue o último maior range

            if (maxBricks - next == 0)
            {
                row.Bricks.Add(next);
                return(row);
            }

            while (row.Bricks.Sum() < maxBricks)
            {
                next = random.Next(1, maxBricks - next + 1);

                if (row.Bricks.Sum() + next <= maxBricks)
                {
                    row.Bricks.Add(next);
                }
            }

            return(row);
        }
        //Descobre quais espaços da linha são "vazios"
        private BricksRow GetClearRowPaths(BricksRow wallRow)
        {
            BricksRow res = new BricksRow();

            int soma = 0;

            for (int i = 0; i < wallRow.Bricks.Count - 1; i++) // -1 pois ignoramos o último brick, pois o final dele é no final da parede
            {
                soma += wallRow.Bricks[i];
                res.Bricks.Add(soma);
            }

            return(res);
        }
Ejemplo n.º 4
0
 private void Awake()
 {
     m_Parent = GetComponentInParent <BricksRow>();
 }