/// <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); }
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); }
/// <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); }
/// <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); }
/// <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]); } }
/// <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); }
/// <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); }
/// <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); }
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(); }); }