public virtual CellsGroup GetArea(GridCell hitGridCell) { Debug.Log("base get shoot area"); CellsGroup cG = new CellsGroup(); return(cG); }
public virtual CellsGroup GetShootArea(GridCell hitGridCell, GridCell freeGridCell, BubbleGrid grid) { Debug.Log("base get shoot area"); CellsGroup cG = new CellsGroup(); return(cG); }
public override CellsGroup GetArea(GridCell gCell) { CellsGroup cG = new CellsGroup(); // Debug.Log(gCell); if (!gCell) { return(cG); } switch (OData.bombType) { case BombDir.Vertical: cG.AddRange(gCell.GColumn.cells); //cG.AddRange(gCell.GColumn.GetDynamicArea()); break; case BombDir.Horizontal: cG.AddRange(gCell.GRow.cells); // cG.AddRange(gCell.GRow.GetDynamicArea()); break; case BombDir.Radial: List <GridCell> areaRad = MBoard.grid.GetAroundArea(gCell, 1).Cells; cG.Add(gCell); foreach (var item in areaRad) { cG.Add(item); // if (item.IsMatchable) } break; case BombDir.Color: cG.AddRange(MGrid.GetAllByID(OData.matchID).SortByDistanceTo(gCell)); break; } return(cG); }
public override CellsGroup GetArea(GridCell gCell) { CellsGroup cG = new CellsGroup(); cG.AddRange(gCell.GColumn.cells); return(cG); }
public void ApplyToTarget(GridCell hitGCell, GridCell freeGCell, CellsGroup group) { if (debug) { Debug.Log("apply"); } }
public CellsGroup GetWave(GridCell gCell, int radius) { radius = Mathf.Max(0, radius); CellsGroup res = new CellsGroup(); int row1 = gCell.Row - radius; int row2 = gCell.Row + radius; int col1 = gCell.Column - radius; int col2 = gCell.Column + radius; Row <GridCell> topRow = GetRow(row1); Row <GridCell> botRow = GetRow(row2); Column <GridCell> leftCol = GetColumn(col1); Column <GridCell> rightCol = GetColumn(col2); if (topRow != null) { for (int i = col1; i <= col2; i++) { if (ok(row1, i)) { res.Add(topRow[i]); } } } if (rightCol != null) { for (int i = row1; i <= row2; i++) { if (ok(i, col2)) { res.Add(rightCol[i]); } } } if (botRow != null) { for (int i = col2; i >= col1; i--) { if (ok(row2, i)) { res.Add(botRow[i]); } } } if (leftCol != null) { for (int i = row2; i >= row1; i--) { if (ok(i, col1)) { res.Add(leftCol[i]); } } } return(res); }
public override CellsGroup GetArea(GridCell gCell) { CellsGroup cG = new CellsGroup(); if (!gCell) { return(cG); } cG.AddRange(MGrid.GetAllByID(OData.matchID).SortByDistanceTo(gCell)); return(cG); }
public CellsGroup GetAroundArea(GridCell gCell, int radius) { radius = Mathf.Max(0, radius); CellsGroup res = new CellsGroup(); if (radius > 0) { for (int i = 1; i <= radius; i++) { res.AddRange(GetWave(gCell, i).Cells); } } return(res); }
public override CellsGroup GetArea(GridCell gCell) { CellsGroup cG = new CellsGroup(); List <GridCell> area = MBoard.grid.GetAroundArea(gCell, radius).Cells; cG.Add(gCell); foreach (var item in area) { // if(item.IsMatchable) cG.Add(item); } return(cG); }
public override CellsGroup GetArea(GridCell hitGridCell) { CellsGroup cG = new CellsGroup(); List <GridCell> area = new NeighBors(hitGridCell, true).Cells; cG.Add(hitGridCell); foreach (var item in area) { if (hitGridCell.IsMatchObjectEquals(item) && item.IsMatchable) { cG.Add(item); } } return(cG); }
public override CellsGroup GetArea(GridCell hitGridCell) { CellsGroup cG = new CellsGroup(); List <GridCell> area = MBoard.grid.GetAllByID(hitGridCell.Match.GetID()); cG.Add(hitGridCell); foreach (var item in area) { if (hitGridCell.IsMatchObjectEquals(item) && item.IsMatchable) { cG.Add(item); } } return(cG); }
public override CellsGroup GetArea(GridCell hitGridCell) { CellsGroup cG = new CellsGroup(); GridCell [] area = hitGridCell.GRow.cells; foreach (var item in area) { if (item.IsMatchable) { cG.Add(item); } } area = hitGridCell.GColumn.cells; foreach (var item in area) { if (item.IsMatchable) { cG.Add(item); } } return(cG); }
/// <summary> /// Return all closed not intersected areas /// </summary> /// <returns></returns> public List <GridCell> GetDetacheCells() { CellsGroup main = new CellsGroup(); // main group from 0 row CellsGroup neigh = new CellsGroup(); CellsGroup neighTemp; main.AddRange(Rows[serviceRowsCount].GetNotEmptyCells()); // start at service rows NeighBors nCells; for (int i = 0; i < main.Length; i++) { nCells = new NeighBors(main.cells[i]); neigh.AddRange(nCells.NotEmptyCells);// neigh.AddRange(main.cells[i].NotEmptyNeighBornCells()); } while (neigh.Length > 0) // find and add to group not empty neighborns { main.AddRange(neigh.cells); neighTemp = new CellsGroup(); foreach (var item in neigh.cells) { nCells = new NeighBors(item); neighTemp.AddRange(nCells.NotEmptyCells); } neigh = neighTemp; neigh.Remove(main.cells); } CellsGroup all = new CellsGroup(); all.AddRange(GetNotEmptyCells()); all.Remove(main.cells); // Debug.Log("detouched: " + all.ToString()); return(all.cells); }
public virtual void ApplyBooster(GridCell hitGridCell, GridCell freeGridCell, CellsGroup group) { Debug.Log("base apply booster"); }
internal override void PlayExplodeAnimation(GridCell gCell, float delay, Action completeCallBack) { if (!gCell || explodePrefab == null || OData == null) { completeCallBack?.Invoke(); } Debug.Log(name + ": play explode animation"); TweenSeq anim = new TweenSeq(); pT = new ParallelTween(); anim.Add((callBack) => // delay { delayAction(gameObject, delay, callBack); }); anim.Add((callBack) => // scale out { SimpleTween.Value(gameObject, 1, 1.5f, 0.2f).SetOnUpdate((float val) => { transform.localScale = gCell.transform.lossyScale * val; }).AddCompleteCallBack(callBack); }); anim.Add((callBack) => // scale in explode prefab { SimpleTween.Value(gameObject, 1.5f, 1.0f, 0.15f).SetOnUpdate((float val) => { transform.localScale = gCell.transform.lossyScale * val; }).AddCompleteCallBack(callBack); GameObject g = Instantiate(explodePrefab); g.transform.position = transform.position; g.transform.localScale = transform.localScale * .50f; }); anim.Add((callBack) => // explode wave { MBoard.ExplodeWave(0, transform.position, 5, null); callBack(); }); anim.Add((callBack) => // sound { MSound.PlayClip(0, explodeClip); callBack(); }); eArea = GetArea(gCell); // trails ParallelTween pT1 = new ParallelTween(); float incDelay = 0f; foreach (var item in eArea.Cells) { incDelay += 0.0f; float t = incDelay; pT1.Add((cB) => { delayAction(item.gameObject, t, () => // delay tween { Vector2 relativePos = (item.transform.position - gCell.transform.position).normalized; Quaternion rotation = Quaternion.FromToRotation(new Vector2(-1, 0), relativePos); // Debug.Log("Dir: " +(item.transform.position - gCell.transform.position) + " : " + rotation.eulerAngles ); GameObject cb = Instantiate(OData.additAnimPrefab, transform.position, rotation); cb.transform.localScale = transform.lossyScale * 1.0f; SimpleTween.Move(cb, cb.transform.position, item.transform.position, 0.2f).AddCompleteCallBack(cB).SetEase(EaseAnim.EaseOutSine); }); }); } anim.Add((callBack) => { pT1.Start(callBack); }); anim.Add((callBack) => // create bombs { foreach (var item in eArea.Cells) { BombDir bd = BombDir.Radial; DynamicClickBombObject r = DynamicClickBombObject.Create(item, GOSet.GetDynamicClickBombObject(bd, 0), false, false, MBoard.TargetCollectEventHandler); r.transform.parent = null; r.SetToFront(true); pT.Add((cB) => { ExplodeBomb(r, item, 0.5f, cB); }); } callBack(); }); anim.Add((callBack) => // delay { delayAction(gameObject, 0, callBack); }); anim.Add((callBack) => { completeCallBack?.Invoke(); callBack(); }); anim.Start(); }
public void ApplyShootBubbleToGrid(GridCell hitGridCell, GridCell freeGridCell, CellsGroup shootGridCellsArea) { if (debug) { Debug.Log("apply shoot bubble"); } if (MData != null) // regular object shoot bubble, set new mainobject and destroy shootbubble { if (shootGridCellsArea.Length < 2) { BubbleGrid.Instance.SetMainObject(freeGridCell, MData); } DestroyImmediate(gameObject); } else // possible booster { BoosterFunc bF = GetComponent <BoosterFunc>(); if (bF) { bF.ApplyBooster(hitGridCell, freeGridCell, shootGridCellsArea); } } if (hitGridCell) { hitGridCell.ShootHit(null); } }
public virtual CellsGroup GetArea(GridCell gCell) { CellsGroup cG = new CellsGroup(); return(cG); }
public override void ApplyToGrid(GridCell gCell, BoosterObjectData bData, Action completeCallBack) { if (!gCell.IsMatchable) { Booster.ActiveBooster.DeActivateBooster(); completeCallBack?.Invoke(); return; } Booster b = Booster.ActiveBooster; b.AddCount(-1); ParallelTween par0 = new ParallelTween(); ParallelTween par1 = new ParallelTween(); TweenSeq bTS = new TweenSeq(); CellsGroup area = GetArea(gCell); float dist = Vector3.Distance(transform.position, gCell.transform.position); List <GameObject> dupBoost = new List <GameObject>(); dupBoost.Add(b.SceneObject); //move activeBooster bTS.Add((callBack) => { SetToFront(true); SimpleTween.Move(gameObject, transform.position, gCell.transform.position, dist / speed).AddCompleteCallBack(() => { MSound.PlayClip(0, bData.privateClip); callBack(); }).SetEase(EaseAnim.EaseInSine); }); // duplicate and move foreach (var c in area.Cells) { if (c != gCell) { par0.Add((callBack) => { GameObject boost = Instantiate(b.SceneObject); dupBoost.Add(boost); SimpleTween.Move(boost.gameObject, gCell.transform.position, c.transform.position, Vector3.Distance(c.transform.position, gCell.transform.position) / speed).AddCompleteCallBack(() => { ValuesTween(boost.gameObject, new float[] { 1, 1.3f, 1 }, 0.3f, (val) => { boost.transform.localScale = gCell.transform.lossyScale * val; }, callBack); }).SetEase(EaseAnim.EaseInSine); }); } } //apply effect for each cell parallel float delay = 0.0f; foreach (var c in area.Cells) { delay += 0.05f; float d = delay; par1.Add((callBack) => { delayAction(gameObject, d, () => { Creator.InstantiateAnimPrefab(bData.animPrefab, c.transform, c.transform.position, SortingOrder.BoosterToFront + 2, true, callBack); } ); }); } // disable boosters foreach (var db in dupBoost) { delay += 0.05f; float d = delay; par1.Add((callBack) => { delayAction(gameObject, d, () => { db.SetActive(false); } ); callBack(); }); } // collect match objects delay = 0.05f; foreach (var c in area.Cells) { delay += 0.05f; float d = delay; par1.Add((callBack) => { c.CollectMatch(d, true, false, true, true, callBack); }); } bTS.Add((callback) => { par0.Start(() => { callback(); }); }); bTS.Add((callback) => { par1.Start(() => { callback(); }); }); bTS.Add((callback) => { // destroy boosters foreach (var db in dupBoost) { Destroy(db); } Booster.ActiveBooster.DeActivateBooster(); completeCallBack?.Invoke(); callback(); }); bTS.Start(); }
internal override void PlayExplodeAnimation(GridCell gCell, float delay, Action completeCallBack) { if (!gCell || OData == null) { completeCallBack?.Invoke(); } Row <GridCell> r = gCell.GRow; Column <GridCell> c = gCell.GColumn; // Debug.Log(gCell); TweenSeq anim = new TweenSeq(); GameObject g = null; anim.Add((callBack) => { delayAction(gameObject, delay, callBack); }); anim.Add((callBack) => // explode wave { MBoard.ExplodeWave(0, transform.position, 5, null); callBack(); }); anim.Add((callBack) => //sound { MSound.PlayClip(0, OData.privateClip); callBack(); }); if (OData.bombType == BombDir.Horizontal || OData.bombType == BombDir.Vertical) { anim.Add((callBack) => { g = Instantiate(OData.explodeAnimPrefab); g.transform.position = transform.position; g.transform.localScale = transform.localScale * 1.2f; callBack(); }); } else if (OData.bombType == BombDir.Radial) { anim.Add((callBack) => { g = Instantiate(OData.explodeAnimPrefab); g.transform.position = transform.position; g.transform.localScale = transform.localScale * 1.0f; callBack(); }); } else if (OData.bombType == BombDir.Color) { anim.Add((callBack) => // scale out { SetToFront(true); SimpleTween.Value(gameObject, 1, 1.5f, 0.15f).SetOnUpdate((float val) => { transform.localScale = gCell.transform.lossyScale * val; }).AddCompleteCallBack(callBack); }); anim.Add((callBack) => // scale in { SimpleTween.Value(gameObject, 1.5f, 1.0f, 0.15f).SetOnUpdate((float val) => { transform.localScale = gCell.transform.lossyScale * val; }).AddCompleteCallBack(callBack); g = Instantiate(OData.explodeAnimPrefab); g.transform.position = transform.position; g.transform.localScale = transform.localScale * 1.0f; }); CellsGroup eArea = GetArea(gCell); ParallelTween pT = new ParallelTween(); float incDelay = 0f; foreach (var item in eArea.Cells) { incDelay += 0.05f; float t = incDelay; pT.Add((cB) => { delayAction(item.gameObject, t, () => // delay tween { Vector2 relativePos = (item.transform.position - gCell.transform.position).normalized; Quaternion rotation = Quaternion.FromToRotation(new Vector2(-1, 0), relativePos); // Debug.Log("Dir: " +(item.transform.position - gCell.transform.position) + " : " + rotation.eulerAngles ); GameObject cb = Instantiate(OData.additAnimPrefab, transform.position, rotation); cb.transform.localScale = transform.lossyScale * 1.0f; SimpleTween.Move(cb, cb.transform.position, item.transform.position, 0.2f).AddCompleteCallBack(cB).SetEase(EaseAnim.EaseOutSine); }); }); } anim.Add((callBack) => { pT.Start(callBack); }); } anim.Add((callBack) => { // Debug.Log("anim complete"); TargetCollectEvent?.Invoke(GetID()); completeCallBack?.Invoke(); callBack(); }); anim.Start(); }
public override void ApplyToGrid(GridCell gCell, BoosterObjectData bData, Action completeCallBack) { if (!gCell.IsMatchable) { Booster.ActiveBooster.DeActivateBooster(); completeCallBack?.Invoke(); return; } Booster b = Booster.ActiveBooster; b.AddCount(-1); ParallelTween par0 = new ParallelTween(); TweenSeq bTS = new TweenSeq(); CellsGroup area = GetArea(gCell); //move activeBooster float dist = Vector3.Distance(transform.position, gCell.transform.position); bTS.Add((callBack) => { SetToFront(true); SimpleTween.Move(gameObject, transform.position, gCell.transform.position, dist / speed).AddCompleteCallBack(() => { ValuesTween(gameObject, new float[] { 1, 1.3f, 1 }, 0.3f, (val) => { transform.localScale = gCell.transform.lossyScale * val; }, callBack); MSound.PlayClip(0, bData.privateClip); }).SetEase(EaseAnim.EaseInSine); }); bTS.Add((callBack) => // explode wave { MBoard.ExplodeWave(0, transform.position, 5, null); callBack(); }); bTS.Add((callBack) => { GameObject g = Instantiate(explodePrefab); g.transform.position = transform.position; g.transform.localScale = transform.localScale * 1.0f; callBack(); }); bTS.Add((callBack) => { Destroy(b.SceneObject, 0.1f); callBack(); }); //apply effect for each cell parallel float delay = 0.0f; foreach (var c in area.Cells) { if (!c.IsDisabled && !c.Blocked) { float d = delay; float distance = Vector2.Distance(c.transform.position, gCell.transform.position); d = distance / 15f + delay; par0.Add((callBack) => { delayAction(gameObject, d, () => { Creator.InstantiateAnimPrefab(bData.animPrefab, c.transform, c.transform.position, SortingOrder.BoosterToFront + 2, true, null); callBack(); } ); }); } } delay = 0.15f; foreach (GridCell mc in area.Cells) //parallel explode all cells { float t = 0; float distance = Vector2.Distance(mc.transform.position, gCell.transform.position); t = distance / 15f; par0.Add((callBack) => { GridCell.ExplodeCell(mc, t, false, false, true, callBack); }); } bTS.Add((callback) => { par0.Start(() => { callback(); }); }); bTS.Add((callback) => { Booster.ActiveBooster.DeActivateBooster(); completeCallBack?.Invoke(); callback(); }); bTS.Start(); }
private void Shooting() { // BubblesShooter.Instance.ShowSwapPath(); if (TouchManager.IsTouched && BubblesShooter.Instance.TouchInRange()) { BubblesShooter.Instance.ShowShootLine(); } else if (TouchManager.IsTouched && !BubblesShooter.Instance.TouchInRange()) { BubblesShooter.Instance.HideShootLine(); BubblesShooter.Instance.CleanTargets(); } else if (!TouchManager.IsTouched) { BubblesShooter.Instance.HideShootLine(); //Debug.Log("Can Shoot " + BubblesShooter.CanShoot); if (BubblesShooter.CanShoot) // shoot { GoToDTMode(); // diasable touch mainSeq = new TweenSeq(); mainSeq.Add((callBack) => // move bubble to free target, hit target, and check result { BubblesShooter.Instance.Shoot(callBack); }); mainSeq.Add((callBack) => // collect all bubbles in shootarea { BubblesShooter.Instance.ShootCollect(callBack); }); mainSeq.Add((callBack) => // collect all fall down objects { BubblesShooter.Instance.CleanTargets(); detCells = new CellsGroup(); detCells.AddRange(grid.GetDetacheCells()); detCells.FallDownCollect(BubblesShooter.Instance.BubbleScore, null); WController.CheckResult(false, false);// check shoot result grid.AddEmptyRow(); callBack(); }); if (WController.GameLevelType == LevelType.AnchorLevel) // update anchor path { mainSeq.Add((callBack) => { if (anchor && anchor.gameObject.activeSelf) { anchor.UpdatePath(); } WController.CheckResult(false, false);// check shoot result callBack(); }); } mainSeq.Add((callBack) => { grid.MoveToVisible(() => { if (WController.GameResult == GameResult.Win) { detCells = new CellsGroup(); detCells.AddRange(grid.GetNotEmptyCells()); detCells.FallDownCollect(BubblesShooter.Instance.BubbleScore, null); } WController.CheckResult(false, false);// check shoot result after falldown GoToShootMode(); callBack(); }); }); mainSeq.Start(); } } }
public override void ApplyToGrid(GridCell gCell, BoosterObjectData bData, Action completeCallBack) { if (!gCell.IsMatchable) { Booster.ActiveBooster.DeActivateBooster(); completeCallBack?.Invoke(); return; } Booster b = Booster.ActiveBooster; b.AddCount(-1); ParallelTween par0 = new ParallelTween(); TweenSeq bTS = new TweenSeq(); CellsGroup area = GetArea(gCell); // ScoreCollectHandler?.Invoke(area); //move activeBooster float dist = Vector3.Distance(transform.position, gCell.transform.position); bTS.Add((callBack) => { SimpleTween.Move(gameObject, transform.position, gCell.transform.position, dist / speed).AddCompleteCallBack(() => { MSound.PlayClip(0, bData.privateClip); Destroy(b.SceneObject, 0.25f); callBack(); }).SetEase(EaseAnim.EaseInSine); }); //apply effect for each cell parallel float delay = 0.0f; foreach (var c in area.Cells) { delay += 0.15f; float d = delay; par0.Add((callBack) => { delayAction(gameObject, d, () => { Creator.InstantiateAnimPrefab(bData.animPrefab, c.transform, c.transform.position, SortingOrder.Booster + 1, true, callBack); } ); }); } delay = 0.15f; foreach (var c in area.Cells) { delay += 0.15f; float d = delay; par0.Add((callBack) => { c.CollectMatch(d, true, false, true, true, callBack); }); } bTS.Add((callback) => { par0.Start(() => { callback(); }); }); bTS.Add((callback) => { Booster.ActiveBooster.DeActivateBooster(); completeCallBack?.Invoke(); callback(); }); bTS.Start(); }
public override void ApplyBooster(GridCell hitGridCell, GridCell freeGridCell, CellsGroup group) { DestroyImmediate(gameObject); }
public override void ApplyBooster(GridCell hitGridCell, GridCell freeGridCell, CellsGroup group) { if (group.Length < 2) { BubbleGrid.Instance.SetMainObject(freeGridCell, mainID); } DestroyImmediate(gameObject); }