示例#1
0
    public bool checkAndExplodeSameColorBall(Ball bullet, int wallHits)
    {
        //Debug.Log("Checking...");
        // get list same colors
        List <GridCell> listSameColors = _gridManager.GetListNeighborsSameColorRecursive(bullet);
        bool            isExploded     = listSameColors.Count >= 2;

        // check explode
        if (isExploded)
        {
            // remove all same colors
            listSameColors.Add(bullet.GetGridPosition());
            int noBallsSameColor = listSameColors.Count;
            foreach (GridCell cell in listSameColors)
            {
                cell.Ball.EffectExplodeBall();
                removeBallFromGrid(cell);
            }

            // remove unrelated/ unhold balls
            int noBallFallingDown = removeAllUnHoldBall();

            if (_scoreEvent != null)
            {
                int calScore = _score.CalculateScore(noBallsSameColor, noBallFallingDown, wallHits);
                _score.AddBallsBroken(noBallsSameColor + noBallFallingDown);
                _score.SetScore(_score.GetScore() + calScore);
                _scoreEvent(_score.GetScore(), _score.GetBallsBroken());
            }
        }

        return(isExploded);
    }