Esempio n. 1
0
        /// <summary>
        /// Show simple zoom sequence on main object
        /// </summary>
        /// <param name="completeCallBack"></param>
        internal void Zoom(Action completeCallBack)
        {
            if (zoomSequence != null)
            {
                zoomSequence.Break();
            }

            zoomSequence = new TweenSeq();
            for (int i = 0; i < 2; i++)
            {
                zoomSequence.Add((callBack) =>
                {
                    SimpleTween.Value(gameObject, 1.0f, 1.2f, 0.07f).SetOnUpdate((float val) =>
                    {
                        SetLocalScale(val);
                    }).AddCompleteCallBack(() =>
                    {
                        callBack();
                    });
                });
                zoomSequence.Add((callBack) =>
                {
                    SimpleTween.Value(gameObject, 1.2f, 1.0f, 0.09f).SetOnUpdate((float val) =>
                    {
                        SetLocalScale(val);
                    }).AddCompleteCallBack(() =>
                    {
                        callBack();
                    });
                });
            }

            zoomSequence.Add((callBack) => { completeCallBack?.Invoke(); callBack(); });
            zoomSequence.Start();
        }
Esempio n. 2
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);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Fetch player first name, id and photo
        /// </summary>
        public void GetPlayerPhoto(Action completeCallBack)
        {
            if (string.IsNullOrEmpty(playerID))
            {
                if (completeCallBack != null)
                {
                    completeCallBack();
                }
                return;
            }

            TweenSeq tS = new TweenSeq();

            for (int i = 0; i < getPlayerInfoTryCount; i++)
            {
                tS.Add((callBack) =>
                {
                    TryGetPlayerPhoto(callBack);
                });
            }

            tS.Add((callBack) =>
            {
                if (completeCallBack != null)
                {
                    completeCallBack();
                }
            });
            tS.Start();
        }
Esempio n. 4
0
        private void FastMoveTween(GameObject mObject, Action completeCallBack)
        {
            PhysStep = true;
            tS       = new TweenSeq();
            Vector3 scale     = transform.localScale;
            float   tweenTime = 0.07f;
            float   distK     = Vector3.Distance(mObject.transform.position, transform.position) / MatchBoard.MaxDragDistance;

            Vector2 dPos   = mObject.transform.position - transform.position;
            bool    isVert = (Mathf.Abs(dPos.y) > Mathf.Abs(dPos.x));

            //move
            tS.Add((callBack) =>
            {
                SimpleTween.Move(mObject, mObject.transform.position, transform.position, tweenTime * distK).AddCompleteCallBack(() =>
                {
                    mObject.transform.position = transform.position;
                    PhysStep = false;
                    completeCallBack?.Invoke();
                    StartCoroutine(EndFill(isVert));
                    callBack();
                });
            });
            tS.Start();
        }
Esempio n. 5
0
        /// <summary>
        /// Run sequence to load user profile, apprequest, friends profiles, invitable friends profiles
        /// </summary>
        private void LoadAllFBData()
        {
            fbState = FBState.LoadData;
            TweenSeq tS = new TweenSeq();

            tS.Add((callBack) =>
            {
                GetPlayerTextInfo(callBack);
            });

            tS.Add((callBack) =>
            {
                GetPlayerPhoto(callBack);
            });

            tS.Add((callBack) =>
            {
                fbState = FBState.Free;
                if (callBack != null)
                {
                    callBack();
                }
            });

            tS.Start();
        }
Esempio n. 6
0
        /// <summary>
        /// Fetch player first name, id and photo
        /// </summary>
        public void GetPlayerPhoto(Action completeCallBack)
        {
            if (string.IsNullOrEmpty(playerID))
            {
                completeCallBack?.Invoke();
                return;
            }

            TweenSeq tS = new TweenSeq();

            for (int i = 0; i < getPlayerInfoTryCount; i++)
            {
                tS.Add((callBack) =>
                {
                    TryGetPlayerPhoto(callBack);
                });
            }

            tS.Add((callBack) =>
            {
                LoadPhotoEvent?.Invoke(IsLogined, playerPhoto);
                completeCallBack?.Invoke();
                callBack();
            });
            tS.Start();
        }
Esempio n. 7
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();
        }
Esempio n. 8
0
        public override void ShootHit(Action completeCallBack)
        {
            if (IsDestroyable)
            {
                hits++;
                if (MOData.protectionStateImages.Length > 0)
                {
                    int i = Mathf.Min(hits - 1, MOData.protectionStateImages.Length - 1);
                    GetComponent <SpriteRenderer>().sprite = MOData.protectionStateImages[i];
                }

                if (MOData.hitAnimPrefab)
                {
                    Creator.InstantiateAnimPrefabAtPosition(MOData.hitAnimPrefab, ParentCell.transform, transform.position, SortingOrder.MainExplode, true, null);
                }

                if (Protection <= 0)
                {
                    hitDestroySeq = new TweenSeq();

                    SetToFront(true);

                    hitDestroySeq.Add((callBack) => // play preexplode animation
                    {
                        SimpleTween.Value(gameObject, 0, 1, 0.050f).AddCompleteCallBack(() =>
                        {
                            if (callBack != null)
                            {
                                callBack();
                            }
                        });
                    });

                    hitDestroySeq.Add((callBack) =>
                    {
                        SoundMasterController.Instance.SoundPlayClipAtPos(0, MOData.privateClip, transform.position, 1.0f, null);
                        callBack();
                    });

                    hitDestroySeq.Add((callBack) =>
                    {
                        if (completeCallBack != null)
                        {
                            completeCallBack();
                        }
                        Destroy(gameObject);
                        callBack();
                    });

                    hitDestroySeq.Start();
                }
            }
            else
            {
                if (completeCallBack != null)
                {
                    completeCallBack();
                }
            }
        }
Esempio n. 9
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();
        }
Esempio n. 10
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();
        }
Esempio n. 11
0
        /// <summary>
        /// If main object falldown fish swim to side
        /// </summary>
        /// <param name="completeCallBack"></param>
        /// <param name="showPrivateScore"></param>
        /// <param name="addPrivateScore"></param>
        /// <param name="privateScore"></param>
        public override void FallDownCollect(Action completeCallBack, bool showPrivateScore, bool addPrivateScore, int privateScore)
        {
            OverlayObject oO = GetComponent <OverlayObject>();

            if (oO && oO.OOData != null)
            {
                collectSequence = new TweenSeq();// Debug.Log("Fish collect " + ToString());
                float locScale = transform.localScale.x;
                oO.sRenderer.sprite = oO.OOData.GuiImage;

                collectSequence.Add((callBack) => // scale out
                {
                    SimpleTween.Value(gameObject, locScale, locScale * 1.2f, 0.20f).SetOnUpdate((float val) =>
                    {
                        transform.localScale = new Vector3(val, val, val);
                    }).AddCompleteCallBack(callBack);
                });

                collectSequence.Add((callBack) =>  //scale in
                {
                    SimpleTween.Value(gameObject, locScale * 1.2f, locScale, 0.20f).SetOnUpdate((float val) =>
                    {
                        transform.localScale = new Vector3(val, val, val);
                    }).AddCompleteCallBack(callBack);
                });

                collectSequence.Add((callBack) =>
                {
                    SoundMasterController.Instance.SoundPlayClipAtPos(0, oO.OOData.privateClip, null, transform.position, 1.0f);
                    GameObject aP = oO.OOData.hitAnimPrefab;
                    Transform rel = GetComponentInParent <GridCell>().transform;

                    SceneCurve path = (UnityEngine.Random.Range(0, 2) == 0) ? pathToLeft : pathToRight;
                    path.MoveAlongPath(gameObject, rel, path.Length / speed, 0, EaseAnim.EaseInOutSine, callBack);
                });

                collectSequence.Add((callBack) =>
                {
                    //   if (showPrivateScore) EffectsHolder.Instance.InstantiateScoreFlyerAtPosition(privateScore, transform.position, oO.OOData.privateFont);
                    //  if (addPrivateScore) BubblesPlayer.Instance.AddScore(privateScore);
                    if (completeCallBack != null)
                    {
                        completeCallBack();
                    }
                    DestroyImmediate(gameObject);
                    callBack();
                });

                collectSequence.Start();
            }
            else
            {
                if (completeCallBack != null)
                {
                    completeCallBack();
                }
            }
        }
        /// <summary>
        /// Instantiate stars objects with any animation
        /// </summary>
        /// <param name="starCount"></param>
        /// <param name="completeCallBack"></param>
        private void SetStars(int starCount, Action completeCallBack)
        {
            if (star1 && starCount < 1)
            {
                Destroy(fullStar_1);
            }
            if (star2 && starCount < 2)
            {
                Destroy(fullStar_2);
            }
            if (star3 && starCount < 3)
            {
                Destroy(fullStar_3);
            }

            TweenSeq ts = new TweenSeq();

            if (!fullStar_1 && starCount > 0)
            {
                ts.Add((callBack) =>
                {
                    fullStar_1 = InstantiateNewStar(starPrefab, star1.transform);
                    AnimateNewStar(fullStar_1, callBack);
                });
            }

            if (!fullStar_2 && starCount > 1)
            {
                ts.Add((callBack) =>
                {
                    fullStar_2 = InstantiateNewStar(starPrefab, star2.transform);
                    AnimateNewStar(fullStar_2, callBack);
                });
            }

            if (!fullStar_3 && starCount > 2)
            {
                ts.Add((callBack) =>
                {
                    fullStar_3 = InstantiateNewStar(starPrefab, star3.transform);
                    AnimateNewStar(fullStar_3, callBack);
                });
            }

            ts.Add((callBack) =>
            {
                if (completeCallBack != null)
                {
                    completeCallBack();
                }
                callBack();
            });

            ts.Start();
        }
Esempio n. 13
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();
        }
Esempio n. 14
0
        public override void Hit(GridCell gCell, Action completeCallBack)
        {
            // Debug.Log("hit: " + name);
            hits++;
            int protection = Protection;

            if (OData.protectionStateImages.Length > 0)
            {
                int i = Mathf.Min(hits - 1, OData.protectionStateImages.Length - 1);
                GetComponent <SpriteRenderer>().sprite = OData.protectionStateImages[i];
            }

            if (OData.hitAnimPrefab)
            {
                Creator.InstantiateAnimPrefab(OData.hitAnimPrefab, transform.parent, transform.position, SortingOrder.MainExplode, true, null);
            }

            MSound.PlayClip(0, OData.privateClip);

            if (protection == 0)
            {
                hitDestroySeq = new TweenSeq();

                SetToFront(true);

                hitDestroySeq.Add((callBack) => // play preexplode animation
                {
                    SimpleTween.Value(gameObject, 0, 1, 0.050f).AddCompleteCallBack(() =>
                    {
                        callBack();
                    });
                });

                hitDestroySeq.Add((callBack) =>
                {
                    TargetCollectEvent?.Invoke(GetID());
                    MSound.PlayClip(0, OData.privateClip, transform.position, null);
                    callBack();
                });

                hitDestroySeq.Add((callBack) =>
                {
                    completeCallBack?.Invoke();
                    Destroy(gameObject);
                    callBack();
                });

                hitDestroySeq.Start();
            }
            else
            {
                completeCallBack?.Invoke();
            }
        }
Esempio n. 15
0
 /// <summary>
 /// show explode effect and collect match
 /// </summary>
 /// <param name="completeCallBack"></param>
 /// <param name="bomb"></param>
 /// <param name="bombType"></param>
 internal void Explode(GridCell gCell, bool showPrefab, bool fly, bool hitProtection, bool sideHitProtection, float delay, Action completeCallBack)
 {
     explodeSequence  = new TweenSeq();
     transform.parent = null;
     if (delay > 0)
     {
         explodeSequence.Add((callBack) => {
             SimpleTween.Value(gameObject, 0, 1, delay).AddCompleteCallBack(callBack);
         });
     }
     explodeSequence.Add((callBack) => { Collect(gCell, 0, showPrefab, fly, hitProtection, sideHitProtection, callBack); });
     explodeSequence.Add((callBack) => { completeCallBack?.Invoke(); callBack(); });
     explodeSequence.Start();
 }
Esempio n. 16
0
        public override void ShootAreaCollect(Action completeCallBack, bool showPrivateScore, bool addPrivateScore, bool decProtection, int privateScore)
        {
            collectSequence = new TweenSeq();
            SetToFront(true);

            collectSequence.Add((callBack) => // play preexplode animation
            {
                SimpleTween.Value(gameObject, 0, 1, 0.050f).AddCompleteCallBack(() =>
                {
                    if (MOData.collectAnimPrefab)
                    {
                        GameObject gA           = Instantiate(MOData.collectAnimPrefab);
                        gA.transform.localScale = transform.lossyScale;
                        gA.transform.position   = transform.position;
                    }
                    if (callBack != null)
                    {
                        callBack();
                    }
                });
            });

            collectSequence.Add((callBack) =>
            {
                SoundMasterController.Instance.SoundPlayClipAtPos(0, MOData.privateClip, transform.position, 1.0f, null);
                SetToFront(true);
                GameObject aP = MOData.hitAnimPrefab;
                callBack();
            });

            collectSequence.Add((callBack) =>
            {
                if (showPrivateScore && WithScore && MOData.scoreFlyerPrefab)
                {
                    InstantiateScoreFlyerAtPosition(MOData.scoreFlyerPrefab, privateScore, transform.position);
                }
                if (addPrivateScore && WithScore)
                {
                    BubblesPlayer.Instance.AddScore(privateScore);
                }
                if (completeCallBack != null)
                {
                    completeCallBack();
                }
                Destroy(gameObject);
                callBack();
            });

            collectSequence.Start();
        }
        public void MoveBoard(int steps)
        {
            bool     up     = steps > 0;
            int      aSteps = Mathf.Abs(steps);
            TweenSeq tS     = new TweenSeq();

            for (int i = 0; i < aSteps; i++)
            {
                tS.Add((callBack) =>
                {
                    GameBoard.Instance.grid.MoveStep(up, 0.1f, callBack);
                });
            }
            tS.Start();
        }
Esempio n. 18
0
        public override void ShootAreaCollect(Action completeCallBack, bool showPrivateScore, bool addPrivateScore, bool decProtection, int privateScore)
        {
            ObjectBehavior oB = GetComponent <ObjectBehavior>();

            if (oB) // use private behavior
            {
                oB.ShootAreaCollect(completeCallBack, showPrivateScore, addPrivateScore, decProtection, privateScore);
                return;
            }

            //else
            Debug.Log("collect " + ToString());
            collectSequence = new TweenSeq();
            SetToFront(true);

            collectSequence.Add((callBack) => // play preexplode animation
            {
                SimpleTween.Value(gameObject, 0, 1, 0.050f).AddCompleteCallBack(() =>
                {
                    if (callBack != null)
                    {
                        callBack();
                    }
                });
            });

            collectSequence.Add((callBack) =>
            {
                SoundMasterController.Instance.SoundPlayClipAtPos(0, OOData.privateClip, transform.position, 1.0f, null);
                SetToFront(true);
                GameObject aP = OOData.hitAnimPrefab;

                // SimpleTween.Move(gameObject, transform.position, new Vector3(transform.position.x + 10, transform.position.y, transform.position.z),2).AddCompleteCallBack(callBack);
            });

            collectSequence.Add((callBack) =>
            {
                if (completeCallBack != null)
                {
                    completeCallBack();
                }
                DestroyImmediate(gameObject);
                callBack();
            });

            collectSequence.Start();
        }
Esempio n. 19
0
        /// <summary>
        /// Fetch player first name, last name and id, with try count = getPlayerInfoTryCount
        /// </summary>
        public void GetPlayerTextInfo(Action completeCallBack)
        {
            TweenSeq tS = new TweenSeq();

            for (int i = 0; i < getPlayerInfoTryCount; i++)
            {
                tS.Add((callBack) =>
                {
                    TryGetPlayerTextInfo(callBack);
                });
            }

            tS.Add((callBack) =>
            {
                LoadTextEvent?.Invoke(IsLogined, playerFirstName, playerLastName);
                completeCallBack?.Invoke();
            });
            tS.Start();
        }
Esempio n. 20
0
        public void Create(Vector3 endPosition, Action completeCallBack)
        {
            TweenSeq ts       = new TweenSeq();
            float    locScale = transform.localScale.x;
            float    dist     = Vector3.Magnitude(endPosition - transform.position);

            ts.Add((callBack) =>
            {
                SimpleTween.Value(gameObject, 0, locScale, 0.15f).
                SetOnUpdate((float val) => { transform.localScale = new Vector3(val, val, val); }).
                AddCompleteCallBack(() =>
                {
                    callBack();
                }).SetEase(EaseAnim.EaseLinear);
            });

            ts.Add((callBack) =>
            {
                SimpleTween.Move(gameObject, transform.position, endPosition, 0.02f * dist).AddCompleteCallBack(() =>
                {
                    callBack();
                }).SetEase(EaseAnim.EaseLinear);
            });

            ts.Add((callBack) =>
            {
                SimpleTween.Value(gameObject, locScale, 0, 0.15f).
                SetOnUpdate((float val) => { transform.localScale = new Vector3(val, val, val); }).
                AddCompleteCallBack(() =>
                {
                    callBack();
                }).SetEase(EaseAnim.EaseLinear);
            });

            ts.Add((callBack) =>
            {
                Destroy(gameObject);
                completeCallBack?.Invoke();
                callBack();
            });

            ts.Start();
        }
Esempio n. 21
0
        /// <summary>
        /// Run sequence to load user profile, apprequest, friends profiles, invitable friends profiles
        /// </summary>
        private void LoadAllFBData()
        {
            TweenSeq tS = new TweenSeq();

            tS.Add((callBack) =>
            {
                GetPlayerTextInfo(callBack);
            });

            tS.Add((callBack) =>
            {
                GetPlayerPhoto(callBack);
            });

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

            tS.Start();
        }
Esempio n. 22
0
        /// <summary>
        /// Fetch player first name, last name and id, with try count = getPlayerInfoTryCount
        /// </summary>
        public void GetPlayerTextInfo(Action completeCallBack)
        {
            TweenSeq tS = new TweenSeq();

            for (int i = 0; i < getPlayerInfoTryCount; i++)
            {
                tS.Add((callBack) =>
                {
                    TryGetPlayerTextInfo(callBack);
                });
            }

            tS.Add((callBack) =>
            {
                if (completeCallBack != null)
                {
                    completeCallBack();
                }
            });
            tS.Start();
        }
Esempio n. 23
0
        private void MoveTween(GameObject mObject, Action completeCallBack)
        {
            PhysStep = true;
            tS       = new TweenSeq();
            Vector3        scale      = transform.localScale;
            float          tweenTime  = 0.07f;
            float          distK      = Vector3.Distance(mObject.transform.position, transform.position) / MatchBoard.MaxDragDistance;
            AnimationCurve scaleCurve = MatchBoard.Instance.arcCurve;

            Vector2 dPos   = mObject.transform.position - transform.position;
            bool    isVert = (Mathf.Abs(dPos.y) > Mathf.Abs(dPos.x));

            //move
            tS.Add((callBack) =>
            {
                SimpleTween.Move(mObject.gameObject, mObject.gameObject.transform.position, transform.position, tweenTime * distK).AddCompleteCallBack(() =>
                {
                    mObject.transform.position = transform.position;
                    callBack();
                }).SetEase(EaseAnim.EaseInSine);
            });

            //curve deform
            tS.Add((callBack) =>
            {
                SimpleTween.Value(mObject, 0.0f, 1f, 0.1f).SetEase(EaseAnim.EaseInSine).SetOnUpdate((float val) =>
                {
                    float t_scale = 1.0f + scaleCurve.Evaluate(val) * 0.1f;
                    mObject.transform.localScale = (isVert) ? new Vector3(t_scale, 2.0f - t_scale, 1) : new Vector3(2.0f - t_scale, t_scale, 1);  //  mObject.SetLocalScaleX(t_scale); //  mObject.SetLocalScaleY(2.0f - t_scale);
                }).AddCompleteCallBack(() =>
                {
                    PhysStep = false;
                    completeCallBack?.Invoke();
                    callBack();
                });
            });

            tS.Start();
        }
Esempio n. 24
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();
        }
        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();
        }
Esempio n. 26
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();
        }
Esempio n. 27
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();
        }
Esempio n. 28
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();
        }
Esempio n. 29
0
        /// <summary>
        /// Collect match object, hit overlays, hit underlays
        /// </summary>
        /// <param name="completeCallBack"></param>
        internal void Collect(float delay, bool showPrefab, bool fly, Action completeCallBack)
        {
            transform.parent = null;
            GameObject animPrefab = OData.collectAnimPrefab;

            TweenSeq cSequence = new TweenSeq();

            if (delay > 0)
            {
                cSequence.Add((callBack) =>
                {
                    SimpleTween.Value(gameObject, 0, 1, delay).AddCompleteCallBack(callBack);
                });
            }

            cSequence.Add((callBack) =>
            {
                if (this)
                {
                    SetToFront(true);
                }
                MSound.PlayClip(0, OData.privateClip);
                callBack();
            });

            // sprite seq animation
            if (showPrefab)
            {
                cSequence.Add((callBack) =>
                {
                    Creator.InstantiateAnimPrefab(animPrefab, transform, transform.position, SortingOrder.MainToFront + 1, false,
                                                  () =>
                    {
                        callBack();
                    });
                });
            }

            //fly
            if (fly)
            {
                cSequence.Add((callBack) =>
                {
                    SimpleTween.Move(gameObject, transform.position, MatchBoard.Instance.FlyTarget, 0.4f).AddCompleteCallBack(() =>
                    {
                        //  callBack();
                    });
                    callBack(); // not wait
                });
                cSequence.Add((callBack) =>
                {
                    SimpleTween.Value(gameObject, 0, 1, 0.15f).AddCompleteCallBack(callBack);
                });
            }
            //finish
            cSequence.Add((callBack) =>
            {
                TargetCollectEvent?.Invoke(OData.ID);
                completeCallBack?.Invoke();
                Destroy(gameObject, (fly) ? 0.6f : 0);
                callBack();
            });

            cSequence.Start();
        }
Esempio n. 30
0
        /// <summary>
        /// Collect match object, hit overlays, hit underlays
        /// </summary>
        /// <param name="completeCallBack"></param>
        internal void Collect(GridCell gCell, float delay, bool showPrefab, bool fly, bool hitProtection, bool sideHitProtection, Action completeCallBack)
        {
            this.gCell       = gCell;
            transform.parent = null;

            GameObject animPrefab = OData.collectAnimPrefab;

            collectSequence = new TweenSeq();
            if (delay > 0)
            {
                collectSequence.Add((callBack) => {
                    SimpleTween.Value(gameObject, 0, 1, delay).AddCompleteCallBack(callBack);
                });
            }

            // play sound
            collectSequence.Add((callBack) =>
            {
                MSound.PlayClip(0, OData.privateClip);
                callBack();
            });

            // sprite seq animation
            if (showPrefab)
            {
                collectSequence.Add((callBack) =>
                {
                    if (this && !fly)
                    {
                        GetComponent <SpriteRenderer>().enabled = false;
                    }
                    GameObject aG = Creator.InstantiateAnimPrefab(animPrefab, transform, transform.position, SortingOrder.Main, false,
                                                                  () =>
                    {
                        if (this && fly)
                        {
                            SetToFront(true);
                        }
                        callBack();
                    });
                    aG.transform.parent = null; // unparent for play full animation
                });
            }

            // hit protection
            collectSequence.Add((callBack) =>
            {
                if (hitProtection)
                {
                    gCell.DirectHitUnderlay(null);
                    gCell.DirectHitOverlay(null);
                }
                if (sideHitProtection)
                {
                    gCell.Neighbors.Cells.ForEach((GridCell c) => { c.SideHit(null); });
                }
                callBack();
            });

            //fly
            if (fly)
            {
                collectSequence.Add((callBack) =>
                {
                    SimpleTween.Move(gameObject, transform.position, MatchBoard.Instance.FlyTarget, 0.4f).AddCompleteCallBack(() =>
                    {
                        //  callBack();
                    });
                    callBack(); // not wait
                });
                collectSequence.Add((callBack) => {
                    SimpleTween.Value(gameObject, 0, 1, 0.15f).AddCompleteCallBack(callBack);
                });
            }
            // finish
            collectSequence.Add((callBack) =>
            {
                // Debug.Log(ToString()+  " collected");
                ScoreCollectEvent?.Invoke();
                TargetCollectEvent?.Invoke(OData.ID);
                completeCallBack?.Invoke();
                Destroy(gameObject, (fly) ? 0.4f: 0);
            });

            collectSequence.Start();
        }