示例#1
0
文件: Warhead.cs 项目: xRoier/EXILED
 /// <summary>
 /// Called after the warhead has been detonated.
 /// </summary>
 public static void OnDetonated() => Detonated.InvokeSafely();
示例#2
0
        public void DestroyMatches()
        {
            var matches = GetMatches();

            if (!matches.Any())
            {
                if (HaveToDetonate())
                {
                    Detonated.Invoke(null, new EventArgs());
                    return;
                }

                // Check if there is two selected cells
                // it means that there was an unsuccessful swap, so swap back
                if (FirstTouched != null && LastTouched != null)
                {
                    Swap(FirstTouched, LastTouched);
                }
                // Invoke that there is no more matches on the field
                NoMoreMatches.Invoke(null, new EventArgs());

                //Remove cells selection
                ResetSelected();
                return;
            }

            // Consolidate intersected matches into the big one
            Consolidate(matches);

            for (var i = 0; i < matches.Count(); i++)
            {
                // Trying to get bonus cells for this match.
                // There can be more then one bonus for each match, cause bomb appears on
                // every intersection of vertical and horizontal match of the same color.
                var bonusCellsPlaces = GetBonusPlaceCells(matches[i]);
                var bonusCells       = GetBonusCells(matches[i].First().Type, matches[i], bonusCellsPlaces);
                foreach (var bonus in bonusCells)
                {
                    // Don't add bonus to the cell which already has a bonus
                    if (Grid[bonus.Col, bonus.Row] is BonusCell)
                    {
                        continue;
                    }
                    InvokeCellDeleted(bonus.Col, bonus.Row, Grid[bonus.Col, bonus.Row].Points);
                    Grid[bonus.Col, bonus.Row] = bonus;
                    BonusCreated(null, bonus);
                }


                foreach (var cell in matches[i])
                {
                    var col = cell.Col;
                    var row = cell.Row;

                    DeleteCell(col, row, cell.Points);
                }
            }

            // Now all bonuses are old
            ResetNewBonuses();

            // And nothing is selected
            ResetSelected();
        }