Пример #1
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();

            if (delay > 0)
            {
                anim.Add((callBack) =>
                {
                    SimpleTween.Value(gameObject, 0, 1, delay).AddCompleteCallBack(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, 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 * 1.50f;
            });

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

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

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

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

            anim.Start();
        }
Пример #2
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();
        }
Пример #3
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();
        }
Пример #4
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();
        }
Пример #5
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();
        }