public void SetBallSize(Ball.Size size) { if (Ball == null) { return; } Ball.SetSize(size); }
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); }