Пример #1
0
        public static void ExplodeArea(IEnumerable <GridCell> area, float delay, bool sequenced, bool showPrefab, bool fly, bool hitProtection, Action completeCallBack)
        {
            ParallelTween pt   = new ParallelTween();
            TweenSeq      expl = new TweenSeq();
            GameObject    temp = new GameObject();

            if (delay > 0)
            {
                expl.Add((callBack) => {
                    SimpleTween.Value(temp, 0, 1, delay).AddCompleteCallBack(callBack);
                });
            }
            float incDelay = 0;

            foreach (GridCell mc in area) //parallel explode all cells
            {
                if (sequenced)
                {
                    incDelay += 0.05f;
                }
                float t = incDelay;
                pt.Add((callBack) => { GridCell.ExplodeCell(mc, t, showPrefab, fly, hitProtection, callBack); });
            }

            expl.Add((callBack) => { pt.Start(callBack); });
            expl.Add((callBack) =>
            {
                Destroy(temp);
                completeCallBack?.Invoke(); callBack();
            });

            expl.Start();
        }
Пример #2
0
        public override void ExplodeArea(GridCell gCell, float delay, bool sequenced, bool showPrefab, bool fly, bool hitProtection, Action completeCallBack)
        {
            Destroy(gameObject);
            ParallelTween pt   = new ParallelTween();
            TweenSeq      expl = new TweenSeq();

            if (delay > 0)
            {
                expl.Add((callBack) =>
                {
                    SimpleTween.Value(gameObject, 0, 1, delay).AddCompleteCallBack(callBack);
                });
            }
            foreach (GridCell mc in GetArea(gCell).Cells) //parallel explode all cells
            {
                float t = 0;
                if (sequenced)
                {
                    float distance = Vector2.Distance(mc.transform.position, gCell.transform.position);
                    t = distance / 15f;
                }
                pt.Add((callBack) => { GridCell.ExplodeCell(mc, t, showPrefab, fly, hitProtection, callBack); });
            }

            expl.Add((callBack) => { pt.Start(callBack); });
            expl.Add((callBack) =>
            {
                completeCallBack?.Invoke(); callBack();
            });

            expl.Start();
        }
Пример #3
0
        public override void ExplodeArea(GridCell gCell, float delay, bool sequenced, bool showPrefab, bool fly, bool hitProtection, Action completeCallBack)
        {
            Destroy(gameObject);
            ParallelTween pt   = new ParallelTween();
            TweenSeq      expl = new TweenSeq();

            expl.Add((callBack) => { delayAction(gCell.gameObject, delay, callBack); });

            foreach (GridCell mc in GetArea(gCell).Cells) //parallel explode all cells
            {
                float t = 0;
                if (sequenced)
                {
                    float distance = Vector2.Distance(mc.transform.position, gCell.transform.position);
                    t = distance / 15f;
                }
                pt.Add((callBack) =>
                {
                    //  Debug.Log("explode " + mc + " ;time: " + Time.time);
                    GridCell.ExplodeCell(mc, t, showPrefab, fly, hitProtection, callBack);
                });
            }

            expl.Add((callBack) => { pt.Start(callBack); });
            expl.Add((callBack) =>
            {
                completeCallBack?.Invoke(); callBack();
            });

            expl.Start();
        }
Пример #4
0
 /// <summary>
 /// async collect matched objects in a group
 /// </summary>
 /// <param name="completeCallBack"></param>
 internal void ShootCollect(int privateScore, bool sequenced, Action completeCallBack)
 {
     if (sequenced)
     {
         TweenSeq collectTween = new TweenSeq();
         foreach (GridCell c in cells)
         {
             collectTween.Add((callBack) => { c.CollectShootAreaObject(callBack, true, false, true, privateScore); });
         }
         collectTween.Add((callBack) => { if (completeCallBack != null)
                                          {
                                              completeCallBack();
                                          }
                                          callBack(); });
         collectTween.Start();
     }
     else
     {
         ParallelTween collectTween = new ParallelTween();
         foreach (GridCell c in cells)
         {
             collectTween.Add((callBack) => { c.CollectShootAreaObject(callBack, true, false, true, privateScore); });
         }
         collectTween.Start(completeCallBack);
     }
 }
Пример #5
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();
            });
        }
Пример #6
0
 /// <summary>
 /// async collect falled down objects in a group
 /// </summary>
 /// <param name="completeCallBack"></param>
 internal void FallDownCollect(int privateScore, Action completeCallBack)
 {
     if (cells.Count > 0)
     {
         ParallelTween collectTween = new ParallelTween();
         foreach (GridCell c in cells)
         {
             collectTween.Add((callBack) =>
             {
                 c.CollectFalledDown(callBack, true, true, privateScore);
             });
         }
         collectTween.Start(completeCallBack);
     }
     else
     {
         completeCallBack?.Invoke();
     }
 }
Пример #7
0
        void MoveLeft(float time, System.Action completeCallBack)
        {
            if (moving)
            {
                return;
            }
            moving = true;
            current++;
            SetNavi();
            ParallelTween pT = new ParallelTween();

            for (int i = 0; i < length; i++)
            {
                int ii = i;
                pT.Add((callBack) => { slides[ii].MoveLeft(time, callBack); });
            }
            pT.Start(() => { moving = false; if (completeCallBack != null)
                             {
                                 completeCallBack();
                             }
                     });
        }
Пример #8
0
        private DynamicClickBombObjectData sourceColorBombData; // need only for color bomb

        public void CombineAndExplode(GridCell gCell, DynamicClickBombObject bomb, Action completeCallBack)
        {
            if (!gCell || !bomb)
            {
                completeCallBack?.Invoke();
                return;
            }

            NeighBors   nG  = gCell.Neighbors;
            BombDir     bd1 = bomb.GetBombDir();
            BombCombine bC  = BombCombine.None;
            List <DynamicClickBombObject> nBs = GetNeighBombs(gCell);

            if (bomb.GetBombDir() == BombDir.Color)
            {
                sourceColorBombData = bomb.OData;
            }

            foreach (var item in nBs) // search color bomb
            {
                BombDir bd2 = item.GetBombDir();
                if (bd2 == BombDir.Color)
                {
                    if (sourceColorBombData == null)
                    {
                        sourceColorBombData = item.OData;
                    }
                    bC = GetCombineType(bd1, bd2);
                    break;
                }
            }

            if (bC == BombCombine.None) // search radial bomb
            {
                foreach (var item in nBs)
                {
                    BombDir bd2 = item.GetBombDir();
                    if (bd2 == BombDir.Radial)
                    {
                        bC = GetCombineType(bd1, bd2);
                        break;
                    }
                }
            }

            if (bC == BombCombine.None) // search hor or vert bomb
            {
                foreach (var item in nBs)
                {
                    BombDir bd2 = item.GetBombDir();
                    if (bd2 == BombDir.Horizontal || bd2 == BombDir.Vertical)
                    {
                        bC = GetCombineType(bd1, bd2);
                        break;
                    }
                }
            }

            switch (bC)
            {
            case BombCombine.ColorBombAndColorBomb:         // clean full board
                collectTween = new ParallelTween();
                nBs.Add(bomb);
                foreach (var item in nBs)
                {
                    item.transform.parent = null;
                    item.SetToFront(true);
                    Creator.CreateSprite(item.transform, glow, item.transform.position, SortingOrder.BombCreator - 1);
                    collectTween.Add((callBack) =>
                    {
                        item.MoveToBomb(gCell, 0, () => { Destroy(item.gameObject); callBack(); });
                    });
                }
                collectTween.Start(() =>
                {
                    MSound.SoundPlayMakeBomb(0.05f, null);
                    CombinedColorBombAndColorBomb bigBomb = Instantiate(colorBombAndColorBombPrefab);
                    bigBomb.transform.localScale          = gCell.transform.lossyScale;
                    bigBomb.transform.position            = gCell.transform.position;
                    bigBomb.ApplyToGrid(gCell, 0.2f, completeCallBack);
                });

                break;

            case BombCombine.BombAndBomb:                   // big bomb explode
                collectTween = new ParallelTween();
                nBs.Add(bomb);
                foreach (var item in nBs)
                {
                    item.transform.parent = null;
                    item.SetToFront(true);
                    Creator.CreateSprite(item.transform, glow, item.transform.position, SortingOrder.BombCreator - 1);
                    collectTween.Add((callBack) =>
                    {
                        item.MoveToBomb(gCell, 0, () => { Destroy(item.gameObject); callBack(); });
                    });
                }
                collectTween.Start(() =>
                {
                    MSound.SoundPlayMakeBomb(0.05f, null);
                    CombinedBombAndBomb bigBomb  = Instantiate(bombAndBombPrefab);
                    bigBomb.transform.localScale = gCell.transform.lossyScale;
                    bigBomb.transform.position   = gCell.transform.position;
                    bigBomb.ApplyToGrid(gCell, 0.2f, completeCallBack);
                });
                break;

            case BombCombine.RocketAndRocket:               // 2 rows or 2 columns
                collectTween = new ParallelTween();
                nBs.Add(bomb);
                foreach (var item in nBs)
                {
                    item.transform.parent = null;
                    item.SetToFront(true);
                    Creator.CreateSprite(item.transform, glow, item.transform.position, SortingOrder.BombCreator - 1);
                    collectTween.Add((callBack) =>
                    {
                        item.MoveToBomb(gCell, 0, () => { Destroy(item.gameObject, 0.2f); callBack(); });
                    });
                }
                collectTween.Start(() =>
                {
                    MSound.SoundPlayMakeBomb(0.05f, null);
                    CombinedRocketAndRocket bigBomb = Instantiate(rocketAndRocketPrefab);
                    bigBomb.transform.localScale    = gCell.transform.lossyScale;
                    bigBomb.transform.position      = gCell.transform.position;
                    bigBomb.ApplyToGrid(gCell, 0.2f, completeCallBack);
                });
                break;

            case BombCombine.ColorBombAndBomb:              // replace color match with bomb
                collectTween = new ParallelTween();
                nBs.Add(bomb);

                foreach (var item in nBs)
                {
                    item.transform.parent = null;
                    item.SetToFront(true);
                    Creator.CreateSprite(item.transform, glow, item.transform.position, SortingOrder.BombCreator - 1);
                    collectTween.Add((callBack) =>
                    {
                        item.MoveToBomb(gCell, 0, () => { Destroy(item.gameObject); callBack(); });
                    });
                }
                collectTween.Start(() =>
                {
                    MSound.SoundPlayMakeBomb(0.05f, null);
                    CombinedColorBombAndBomb colorBombAndBomb = Instantiate(colorBombAndBombPrefab);
                    colorBombAndBomb.transform.localScale     = gCell.transform.lossyScale;
                    colorBombAndBomb.transform.position       = gCell.transform.position;
                    colorBombAndBomb.OData = sourceColorBombData;
                    colorBombAndBomb.ApplyToGrid(gCell, 0.2f, completeCallBack);
                    colorBombAndBomb.GetComponent <SpriteRenderer>().sprite = sourceColorBombData.ObjectImage;
                });

                break;

            case BombCombine.BombAndRocket:                 // 3 rows and 3 columns
                collectTween = new ParallelTween();
                nBs.Add(bomb);
                foreach (var item in nBs)
                {
                    item.transform.parent = null;
                    item.SetToFront(true);
                    Creator.CreateSprite(item.transform, glow, item.transform.position, SortingOrder.BombCreator - 1);
                    collectTween.Add((callBack) =>
                    {
                        item.MoveToBomb(gCell, 0, () => { Destroy(item.gameObject); callBack(); });
                    });
                }
                collectTween.Start(() =>
                {
                    MSound.SoundPlayMakeBomb(0.05f, null);
                    CombinedBombAndRocket bombAndRocket = Instantiate(bombAndRocketPrefab);
                    bombAndRocket.transform.localScale  = gCell.transform.lossyScale;
                    bombAndRocket.transform.position    = gCell.transform.position;
                    bombAndRocket.ApplyToGrid(gCell, 0.2f, completeCallBack);
                });
                break;

            case BombCombine.ColorBombAndRocket:            // replace color bomb with rockets
                collectTween = new ParallelTween();
                nBs.Add(bomb);

                foreach (var item in nBs)
                {
                    item.transform.parent = null;
                    item.SetToFront(true);
                    Creator.CreateSprite(item.transform, glow, item.transform.position, SortingOrder.BombCreator - 1);
                    collectTween.Add((callBack) =>
                    {
                        item.MoveToBomb(gCell, 0, () => { Destroy(item.gameObject); callBack(); });
                    });
                }
                collectTween.Start(() =>
                {
                    MSound.SoundPlayMakeBomb(0.05f, null);
                    CombinedColorBombAndRocket colorBombAndRocket = Instantiate(colorBombAndRocketPrefab);
                    colorBombAndRocket.transform.localScale       = gCell.transform.lossyScale;
                    colorBombAndRocket.transform.position         = gCell.transform.position;
                    colorBombAndRocket.OData = sourceColorBombData;
                    colorBombAndRocket.ApplyToGrid(gCell, 0.2f, completeCallBack);
                    colorBombAndRocket.GetComponent <SpriteRenderer>().sprite = sourceColorBombData.ObjectImage;
                });
                break;

            case BombCombine.None:                          // simple explode
                gCell.ExplodeBomb(0.0f, true, true, bd1 == BombDir.Color, false, () =>
                {
                    completeCallBack?.Invoke();
                });
                break;

            default:
                completeCallBack?.Invoke();
                break;
            }
        }
Пример #9
0
        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();
        }
Пример #10
0
        internal override void PlayExplodeAnimation(GridCell gCell, float delay, Action completeCallBack)
        {
            if (!gCell || explodePrefab == null)
            {
                completeCallBack?.Invoke();
            }
            //  Debug.Log(name + "play explode animation");
            TweenSeq anim = new TweenSeq();

            pT      = new ParallelTween();
            rockets = new List <DynamicClickBombObject>();

            anim.Add((callBack) => // delay
            {
                delayAction(gameObject, delay, callBack);
            });

            anim.Add((callBack) =>
            {
                SimpleTween.Value(gameObject, 1, 1.5f, 0.2f).SetOnUpdate((float val) => { transform.localScale = gCell.transform.lossyScale * val; }).AddCompleteCallBack(callBack);
            });

            anim.Add((callBack) => // scale in and 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) => // create rockets
            {
                DynamicClickBombObject r1 = DynamicClickBombObject.Create(gCell, GOSet.GetDynamicClickBombObject(BombDir.Horizontal, 0), false, false, MBoard.TargetCollectEventHandler);
                r1.transform.parent       = null;
                r1.SetToFront(true);
                pT.Add((cB) =>
                {
                    ExplodeRocket(r1, gCell, 0, cB);
                });
                rockets.Add(r1);
                DynamicClickBombObject r2 = DynamicClickBombObject.Create(gCell, GOSet.GetDynamicClickBombObject(BombDir.Vertical, 0), false, false, MBoard.TargetCollectEventHandler);
                r2.transform.parent       = null;
                r2.SetToFront(true);
                pT.Add((cB) =>
                {
                    ExplodeRocket(r2, gCell, 0, cB);
                });
                rockets.Add(r2);

                callBack();
            });

            anim.Add((callBack) => // explode wave
            {
                MBoard.ExplodeWave(0, transform.position, 5, null);
                callBack();
            });

            anim.Add((callBack) =>
            {
                MSound.PlayClip(0, explodeClip);
                callBack();
            });


            anim.Add((callBack) => // delay
            {
                delayAction(gameObject, 0, callBack);
            });

            anim.Add((callBack) =>
            {
                completeCallBack?.Invoke();
                callBack();
            });

            anim.Start();
        }
Пример #11
0
        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();
        }
Пример #12
0
        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();
        }
Пример #13
0
        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();
        }
Пример #14
0
        public override void ApplyToGrid(GridCell gCell, BoosterObjectData bData, Action completeCallBack)
        {
            if (!gCell.Overlay)
            {
                if (!gCell.Match && !gCell.StaticBlocker && !gCell.DynamicBlocker)
                {
                    Booster.ActiveBooster.DeActivateBooster();
                    completeCallBack?.Invoke();
                    return;
                }
            }

            Booster b = Booster.ActiveBooster;

            b.AddCount(-1);

            ParallelTween par0 = new ParallelTween();
            TweenSeq      bTS  = new TweenSeq();

            //move activeBooster
            Vector3 pos      = transform.position;
            float   dist     = Vector3.Distance(transform.position, gCell.transform.position);
            Vector3 rotPivot = Vector3.zero;
            float   rotRad   = 6f;

            bTS.Add((callBack) =>
            {
                SetToFront(true);
                SimpleTween.Move(b.SceneObject, b.SceneObject.transform.position, gCell.transform.position, dist / speed).AddCompleteCallBack(() =>
                {
                    rotPivot = transform.position - new Vector3(0, rotRad, 0);
                    callBack();
                }).SetEase(EaseAnim.EaseInSine);
            });


            // back move
            bTS.Add((callBack) =>
            {
                SimpleTween.Value(gameObject, Mathf.Deg2Rad * 90f, Mathf.Deg2Rad * 180f, 0.25f).SetEase(EaseAnim.EaseInCubic). //
                SetOnUpdate((float val) => { transform.position = new Vector3(rotRad * Mathf.Cos(val), rotRad * Mathf.Sin(val), 0) + rotPivot; }).
                AddCompleteCallBack(() => { callBack(); });
            });
            //forward move
            bTS.Add((callBack) =>
            {
                SimpleTween.Value(gameObject, Mathf.Deg2Rad * 180f, Mathf.Deg2Rad * 100f, 0.2f).SetEase(EaseAnim.EaseOutBounce).
                SetOnUpdate((float val) =>
                {
                    transform.position = new Vector3(rotRad * Mathf.Cos(val), rotRad * Mathf.Sin(val), 0) + rotPivot;
                }).
                AddCompleteCallBack(() =>
                {
                    MSound.PlayClip(0, bData.privateClip);
                    Destroy(gameObject, 0.25f);
                    Creator.InstantiateAnimPrefab(bData.animPrefab, gCell.transform, gCell.transform.position, SortingOrder.BoosterToFront + 2, true, callBack);
                });
            });

            //  if (gCell.IsMatchable)
            {
                bTS.Add((callBack) =>
                {
                    GridCell.ExplodeCell(gCell, 0, true, false, true, callBack);
                    // gCell.CollectMatch(0, true, false, true, true, callBack);
                });
            }


            bTS.Add((callback) =>
            {
                Booster.ActiveBooster.DeActivateBooster();
                completeCallBack?.Invoke();
                callback();
            });

            bTS.Start();
        }
Пример #15
0
        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();
        }