Ejemplo n.º 1
0
    public Clickable GetRandomFreeCellForBorn(Clickable excetions)
    {
        Clickable cell = null;

        List <int> tempArr = new List <int>();

        for (int i = 0; i < cells.Length; i++)
        {
            /*
             * bool isBusy = false;
             * for (int j = 0; j < excetions.Length; j++)
             * {
             *  if (excetions[j].num == i)
             *      isBusy = true;
             * }
             *
             * if(!isBusy)*/
            if (excetions == null || (excetions != null && excetions.num != i))
            {
                tempArr.Add(i);
            }
        }

        do
        {
            if (tempArr.Count == 0)
            {
                return(cells[0]);
            }


            int randomNum = Random.Range(0, tempArr.Count - 1);
            int num       = tempArr[randomNum];

            cell = cells[num];

            tempArr.RemoveAt(randomNum);
        } while (!cell.IsFree() /*!cell.IsFreeForBorn()*/);

        return(cell);
    }