Example #1
0
        private void RemoveRandomFromBoard(int removedIndex)
        {
            var deleter = new DeleteBubbleAction();
            var placer  = new PlaceBubbleAction();

            var allRandomBubbles = GetAllRandomBubbles();

            manipulator.PushState();

            foreach (var bubble in allRandomBubbles)
            {
                var modifier      = bubble.modifiers.First(m => m.type == BubbleModifierType.Random);
                var modifierIndex = int.Parse(modifier.data);

                if (modifierIndex == removedIndex)
                {
                    // Delete randoms that were part of this group
                    deleter.Perform(manipulator, bubble.X, bubble.Y);
                }
                else if (modifierIndex > removedIndex)
                {
                    // Shift higher random groups down to fill the gap
                    modifier.data = (modifierIndex - 1).ToString();
                    manipulator.SetBubbleType(bubble.Type);
                    placer.Perform(manipulator, bubble.X, bubble.Y);
                }
            }

            manipulator.PopState();
        }
        private void DeleteAction()
        {
            deleter.Perform(Manipulator, data.X, data.Y);

            Complete();
        }