Ejemplo n.º 1
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();
                }
            }
        }
Ejemplo n.º 2
0
 internal void SetOverlay(OverlayObjectData mObjectData)
 {
     if (mObjectData == null)
     {
         return;
     }
     if (!Overlay)
     {
         Overlay = OverlayObject.Create(this, mObjectData);
     }
     else
     {
         Overlay.SetData(mObjectData);
     }
 }
Ejemplo n.º 3
0
 internal void SetOverlay(OverlayObjectData oData)
 {
     if (oData == null || IsDisabled || Blocked)
     {
         return;
     }
     if (Overlay)
     {
         GameObject old = Overlay.gameObject;
         Destroy(old);
     }
     if (StaticBlocker)
     {
         GameObject old = StaticBlocker.gameObject;
         DestroyImmediate(old);
     }
     Overlay = OverlayObject.Create(this, oData, MBoard.TargetCollectEventHandler);
     Overlay.SetToFront(false);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Create new OverlayObject for gridcell
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="oData"></param>
        /// <param name="addCollider"></param>
        /// <param name="radius"></param>
        /// <param name="isTrigger"></param>
        /// <returns></returns>
        public static OverlayObject Create(GridCell parent, OverlayObjectData oData, Action <int> TargetCollectEvent)
        {
            if (!parent || oData == null)
            {
                return(null);
            }
            GameObject     gO         = null;
            SpriteRenderer sR         = null;
            OverlayObject  gridObject = null;

            sR = Creator.CreateSprite(parent.transform, oData.ObjectImage, parent.transform.position);
            gO = sR.gameObject;

            gridObject = gO.GetOrAddComponent <OverlayObject>();
#if UNITY_EDITOR
            gO.name = "overlay " + parent.ToString();
#endif
            gridObject.SetData(oData);
            gridObject.SRenderer          = sR;
            gridObject.TargetCollectEvent = TargetCollectEvent;
            return(gridObject);
        }