示例#1
0
 public void SetBallSize(Ball.Size size)
 {
     if (Ball == null)
     {
         return;
     }
     Ball.SetSize(size);
 }
示例#2
0
    public List <Cell> AddBalls(int numOfBall, int numOfType, Ball.Size size)
    {
        List <Cell> emptyCells = new List <Cell>();

        foreach (Cell cell in mCells)
        {
            if (cell.IsEmpty)
            {
                emptyCells.Add(cell);
            }
        }

        System.Random     rnd         = new System.Random();
        List <Cell>       randomCells = emptyCells.OrderBy(x => rnd.Next()).Take(numOfBall).ToList <Cell>();
        List <Ball.Color> colors      = new List <Ball.Color>();

        for (int i = 0; i < numOfBall; i++)
        {
            Cell cell = randomCells[i];
            if (cell)
            {
                cell.AttachBall(DataManager.Instance.TakeRandomBall(numOfType));
                cell.SetBallSize(size);

                if (cell.Ball && cell.Ball.BallSize == Ball.Size.Dot)
                {
                    colors.Add(cell.Ball.BallColor);
                }
            }
        }

        if (colors.Count > 0)
        {
            EventDispatcher.TriggerEvent <BallChangeEvent>(new BallChangeEvent(BallChangeEnum.Change, colors));
        }

        return(randomCells);
    }