示例#1
0
        private void ShiftRows(LevelManipulator manipulator, int start, int delta)
        {
            var models   = manipulator.Models;
            var views    = manipulator.Views;
            var moveList = models.Where(p => p.Value.Y >= start).Select(p => p.Value).ToArray();
            var viewList = moveList.Select(m => views[m.Key]).ToArray();

            // Remove all of the models we're moving before we try to shift anything around so we don't have collisions.
            foreach (var model in moveList)
            {
                models.Remove(model.Key);
                views.Remove(model.Key);
            }

            for (var index = 0; index < moveList.Length; index++)
            {
                var model = moveList[index];
                var view  = viewList[index];

                var newModel = model.CloneAt(model.X, model.Y + delta);
                view.transform.localPosition = PlaceBubbleAction.GetBubbleLocation(newModel.X, newModel.Y);

                models[newModel.Key] = newModel;
                views[newModel.Key]  = view;
            }
        }
 public void PerformAlternate(LevelManipulator manipulator, int x, int y)
 {
     if (manipulator.Models.ContainsKey(BubbleData.GetKey(x, y)) && (manipulator.Modifier != null))
     {
         RemoveModifier(manipulator, x, y, manipulator.Modifier);
         placer.Perform(manipulator, x, y);
     }
 }
        public void Perform(LevelManipulator manipulator, int x, int y)
        {
            manipulator.PushState();

            bubblePlacer.Perform(manipulator, x, y);
            modifierPlacer.Perform(manipulator, x, y);

            manipulator.PopState();
        }
示例#4
0
        public void Perform(LevelManipulator manipulator, int x, int y)
        {
            foreach (var pair in manipulator.Views)
            {
                GameObject.Destroy(pair.Value);
            }

            manipulator.Models.Clear();
            manipulator.Views.Clear();

            GlobalState.EventService.Dispatch(new LevelModifiedEvent());
        }
        private void ApplyModifier(LevelManipulator manipulator, int x, int y, BubbleModifierInfo modifier)
        {
            var model     = manipulator.Models[BubbleData.GetKey(x, y)];
            var modifiers = new List <BubbleData.ModifierData>(model.modifiers ?? new BubbleData.ModifierData[0]);

            manipulator.SetBubbleType(model.Type);

            modifiers.Add(new BubbleData.ModifierData
            {
                type = modifier.Type,
                data = modifier.Data,
            });

            model.modifiers = modifiers.ToArray();
        }
示例#6
0
        private void RemoveRows(LevelManipulator manipulator, params int[] rows)
        {
            var rowList    = rows.ToList();
            var models     = manipulator.Models;
            var views      = manipulator.Views;
            var deleteList = models.Where(p => rowList.Contains(p.Value.Y)).Select(p => p.Value.Key).ToArray();

            foreach (var key in deleteList)
            {
                GameObject.Destroy(views[key]);

                models.Remove(key);
                views.Remove(key);
            }
        }
        public void Perform(LevelManipulator manipulator, int x, int y)
        {
            var key = BubbleData.GetKey(x, y);

            manipulator.Models.Remove(key);

            if (manipulator.Views.ContainsKey(key))
            {
                GameObject.Destroy(manipulator.Views[key]);
                manipulator.Views.Remove(key);
            }

            GlobalState.EventService.Dispatch(new LevelModifiedEvent());
            manipulator.RecomputeScores();
        }
        private void RemoveModifier(LevelManipulator manipulator, int x, int y, BubbleModifierInfo modifier)
        {
            var model = manipulator.Models[BubbleData.GetKey(x, y)];

            manipulator.SetBubbleType(model.Type);

            if (model.modifiers != null)
            {
                model.modifiers = model.modifiers.Where(m => m.type != modifier.Type).ToArray();

                if (model.modifiers.Length == 0)
                {
                    model.modifiers = null;
                }
            }
        }
        public void Perform(LevelManipulator manipulator, int x, int y)
        {
            var key      = BubbleData.GetKey(x, y);
            var modifier = manipulator.Modifier;

            if (manipulator.Models.ContainsKey(key) && (modifier != null))
            {
                var bubble      = manipulator.Models[key];
                var hasModifier = (bubble.modifiers != null) && bubble.modifiers.Any(m => m.type == modifier.Type);

                RemoveModifier(manipulator, x, y, modifier);

                if (!hasModifier)
                {
                    ApplyModifier(manipulator, x, y, modifier);
                }

                placer.Perform(manipulator, x, y);
            }
        }
        private void PlaceBubble(LevelManipulator manipulator, int x, int y, BubbleType type)
        {
            var key = BubbleData.GetKey(x, y);

            BubbleData.ModifierData[] modifiers = null;

            if (manipulator.Models.ContainsKey(key))
            {
                modifiers = manipulator.Models[key].modifiers;
            }

            deleter.Perform(manipulator, x, y);

            var definition     = manipulator.BubbleFactory.GetDefinitionByType(type);
            var prefabRenderer = definition.Prefab.GetComponentInChildren <SpriteRenderer>();

            if (prefabRenderer != null)
            {
                var instance = GameObject.Instantiate(manipulator.BubblePrefab);

                var image = instance.GetComponent <Image>();
                image.sprite = prefabRenderer.sprite;

                instance.name = string.Format("{0} ({1}, {2})", type, x, y);
                instance.transform.SetParent(manipulator.BubbleContainer, false);
                instance.transform.localPosition = GetBubbleLocation(x, y);

                var model = new BubbleData(x, y, type)
                {
                    modifiers = modifiers
                };
                manipulator.Views.Add(model.Key, instance);
                manipulator.Models.Add(model.Key, model);

                manipulator.BubbleFactory.ApplyEditorModifiers(instance, model);

                GlobalState.EventService.Dispatch(new LevelModifiedEvent());
            }
        }
示例#11
0
 public void PerformAlternate(LevelManipulator manipulator, int x, int y)
 {
     Perform(manipulator, x, y);
 }
 public void Perform(LevelManipulator manipulator, int x, int y)
 {
     PlaceBubble(manipulator, x, y, manipulator.BubbleType);
     manipulator.RecomputeScores();
 }
示例#13
0
 public void PerformAlternate(LevelManipulator manipulator, int x, int y)
 {
     RemoveRows(manipulator, y, y + 1);
     ShiftRows(manipulator, y + 2, -2);
 }
示例#14
0
 public void Perform(LevelManipulator manipulator, int x, int y)
 {
     ShiftRows(manipulator, y, 2);
 }