Пример #1
0
        /// <summary>
        /// Return gridcells group with id matched bubbles around free gridcell
        /// </summary>
        /// <param name="freeGCell"></param>
        /// <returns></returns>
        public MatchGroup GetIdArea(GridCell freeGCell, int id)
        {
            MatchGroup res        = new MatchGroup();
            MatchGroup equalNeigh = new MatchGroup();
            MatchGroup neighTemp;

            if (freeGCell)
            {
                NeighBors nCells = new NeighBors(freeGCell, id); // res.Add(freeGCell);
                equalNeigh.AddRange(nCells.EqualIDCells);        //equalNeigh.AddRange(gCell.EqualNeighBornCells());
                while (equalNeigh.Length > 0)
                {
                    res.AddRange(equalNeigh.cells);
                    neighTemp = new MatchGroup();
                    foreach (var item in equalNeigh.cells)
                    {
                        nCells = new NeighBors(item, id);
                        neighTemp.AddRange(nCells.EqualIDCells); // neighTemp.AddRange(item.EqualNeighBornCells());
                    }
                    equalNeigh = neighTemp;
                    equalNeigh.Remove(res.cells);
                }
            }
            res.Remove(freeGCell);
            return(res);
        }
Пример #2
0
        private void SetBomb(MatchGroup m)
        {
            if (m == null)
            {
                return;
            }
            GridCell c = m.lastMatchedCell;
            DynamicClickBombObjectData b = null;

            switch (m.GetGroupType())
            {
            case MatchGroupType.HorBomb:
                b = MatchSet.GetDynamicClickBombObject(BombDir.Horizontal, m.lastMatchedID);
                break;

            case MatchGroupType.VertBomb:
                b = MatchSet.GetDynamicClickBombObject(BombDir.Vertical, m.lastMatchedID);
                break;

            case MatchGroupType.Bomb:
                b = MatchSet.GetDynamicClickBombObject(BombDir.Radial, m.lastMatchedID);
                break;

            case MatchGroupType.ColorBomb:
                b = MatchSet.GetDynamicClickBombObject(BombDir.Color, m.lastMatchedID);
                break;
            }
            if (b == null)
            {
                return;
            }
            createPrefab = b.createAnimPrefab;
            c.SetDynamicClickBomb(b);
            Creator.InstantiateAnimPrefab(createPrefab, c.DynamicObject.transform, c.DynamicObject.transform.position, SortingOrder.BombCreator + 1, false, null);
        }
Пример #3
0
        /// <summary>
        /// Return gridcells group with id matched  around gCell
        /// </summary>
        /// <param name="gCell"></param>
        /// <returns></returns>
        public MatchGroup GetMatchIdArea(GridCell gCell)
        {
            MatchGroup res = new MatchGroup();

            if (!gCell.Match || !gCell.IsMatchable)
            {
                return(res);
            }

            MatchGroup equalNeigh = new MatchGroup();
            MatchGroup neighTemp;
            int        id = gCell.Match.GetID();

            res.Add(gCell);

            equalNeigh.AddRange(gCell.Neighbors.GetMatchIdCells(id, true)); //equalNeigh.AddRange(gCell.EqualNeighBornCells());
            while (equalNeigh.Length > 0)
            {
                res.AddRange(equalNeigh.Cells);
                neighTemp = new MatchGroup();
                foreach (var item in equalNeigh.Cells)
                {
                    neighTemp.AddRange(item.Neighbors.GetMatchIdCells(id, true)); // neighTemp.AddRange(item.EqualNeighBornCells());
                }
                equalNeigh = neighTemp;
                equalNeigh.Remove(res.Cells);
            }
            return(res);
        }
Пример #4
0
        /// <summary>
        /// Return gridcells group with ids matched bubbles around free gridcell
        /// </summary>
        /// <param name="freeGCell"></param>
        /// <returns></returns>
        public MatchGroup GetIdArea(GridCell freeGCell, List <int> ids)
        {
            MatchGroup res = new MatchGroup();

            for (int i = 0; i < ids.Count; i++)
            {
                res.Merge(GetIdArea(freeGCell, ids[i]));
            }
            res.Remove(freeGCell);
            return(res);
        }
Пример #5
0
 /// <summary>
 /// Merge two groups
 /// </summary>
 /// <param name="mGroup"></param>
 public void Merge(MatchGroup mGroup)
 {
     if (mGroup == null || mGroup.Length == 0)
     {
         return;
     }
     for (int i = 0; i < mGroup.cells.Count; i++)
     {
         Add(mGroup.cells[i]);
     }
 }
Пример #6
0
 /// <summary>
 /// Return true if groups contain all equal cells
 /// </summary>
 /// <param name="mGroup"></param>
 /// <returns></returns>
 public bool IsEqual(MatchGroup mGroup)
 {
     if (Length != mGroup.Length)
     {
         return(false);
     }
     foreach (GridCell c in cells)
     {
         if (!mGroup.Contain(c))
         {
             return(false);
         }
     }
     return(true);
 }
Пример #7
0
 /// <summary>
 /// Return true if both groups has minimum one equal cell
 /// </summary>
 /// <param name="mGroup"></param>
 /// <returns></returns>
 public bool IsIntersectWithGroup(MatchGroup mGroup)
 {
     if (mGroup == null || mGroup.Length == 0)
     {
         return(false);
     }
     for (int i = 0; i < cells.Count; i++)
     {
         if (mGroup.Contain(cells[i]))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #8
0
        /// <summary>
        /// Return not empty gridcells from column
        /// </summary>
        /// <param name="gridCell"></param>
        /// <returns></returns>
        public MatchGroup GetColumnArea(GridCell gridCell)
        {
            MatchGroup res    = new MatchGroup();
            int        row    = gridCell.Row;
            int        column = gridCell.Column;

            for (int i = row; i >= 0; i -= 2)
            {
                GridCell gCell = this[i, column];

                if (!gCell.IsEmpty)
                {
                    res.Add(gCell);
                }
            }
            return(res);
        }
Пример #9
0
        public void Create(MatchGroup m, Action completeCallBack)
        {
            float         delay        = 0;
            ParallelTween collectTween = new ParallelTween();

            MSound.SoundPlayMakeBomb(0.05f, null);

            foreach (GridCell c in m.Cells) // move and collect
            {
                Creator.CreateSprite(c.Match.transform, glow, c.Match.transform.position, SortingOrder.BombCreator - 1);
                collectTween.Add((callBack) => { c.MoveMatchAndCollect(m.lastMatchedCell, delay, false, false, true, false, callBack); });
            }

            collectTween.Start(() =>
            {
                SetBomb(m);
                completeCallBack?.Invoke();
            });
        }