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(); }
/// <summary> /// Open panel /// </summary> /// <param name="panel"></param> public void OpenScrollPanel(Action completeCallBack) { RectTransform panel = GetComponent <RectTransform>(); transform.localScale = new Vector3(0, 1, 1); if (!panel) { return; } SetControlActivity(false); float startX = 0; float endX = 1f; SimpleTween.Cancel(gameObject, true); SimpleTween.Value(gameObject, startX, endX, 0.2f).SetEase(EaseAnim.EaseInCubic). SetOnUpdate((float val) => { transform.localScale = new Vector3(val, 1, 1); }).AddCompleteCallBack(() => { SetControlActivity(true); if (completeCallBack != null) { completeCallBack(); } }); }
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(); } } }
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(); }
public void UpdateLevelBkgMusik() { bool play = musicOn; AudioClip nClip = bkgMusic; if (nClip != aSbkg.clip) { aSbkg.Stop(); aSbkg.Play(); aSbkg.clip = nClip; } SimpleTween.Cancel(gameObject, true); if (play && aSbkg && !aSbkg.isPlaying) { aSbkg.volume = 0; aSbkg.Play(); SimpleTween.Value(gameObject, 0.0f, volume, 3.5f).SetOnUpdate((float val) => { aSbkg.volume = val; }). AddCompleteCallBack(() => { }); } else if (!play && aSbkg && aSbkg.isPlaying) { SimpleTween.Value(gameObject, volume, 0.0f, 2f).SetOnUpdate((float val) => { aSbkg.volume = val; }). AddCompleteCallBack(() => { aSbkg.Stop(); }); } }
private IEnumerator EndFill(bool isVert) { if (!PhysStep) { yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); } if (!PhysStep && DynamicObject) { AnimationCurve scaleCurve = MatchBoard.Instance.arcCurve; MSound.PlayClip(0.05f, fillSound); SimpleTween.Value(DynamicObject, 0.0f, 1f, 0.1f).SetEase(EaseAnim.EaseInSine).SetOnUpdate((float val) => { float t_scale = 1.0f + scaleCurve.Evaluate(val) * 0.1f; if (DynamicObject) { DynamicObject.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(); }); } }
internal void RefreshScoreStrip(int score, int averageScore) { // refresh score text if (ScoreCount) { int newCount = score; SimpleTween.Cancel(ScoreCount.gameObject, false); SimpleTween.Value(ScoreCount.gameObject, oldCount, newCount, 0.5f).SetOnUpdate((float val) => { oldCount = (int)val; ScoreCount.text = (MBoard.WinContr != null && MBoard.WinContr.ScoreTarget > 0) ? oldCount.ToString() + "/" + MBoard.WinContr.ScoreTarget : oldCount.ToString(); //ScoreCount.text = oldCount.ToString(); }); if (MatchBoard.GMode == GameMode.Play) { ScoreComplete?.SetActive(MBoard.WinContr.HasScoreTarget && (score >= MBoard.WinContr.ScoreTarget)); } } float amount = (averageScore > 0) ? (float)score / (float)(averageScore) : 0; if (ScoreStrip) { SimpleTween.Value(ScoreStrip.gameObject, ScoreStrip.fillAmount, amount, 0.3f).SetOnUpdate((float val) => { ScoreStrip.fillAmount = val; }).SetEase(EaseAnim.EaseOutCubic); } }
/// <summary> /// Show active footer booster with another color /// </summary> /// <param name="active"></param> private void ShowActive() { if (gameObject) { SimpleTween.Cancel(gameObject, true); } if (boosterImage) { Color c = boosterImage.color; boosterImage.color = new Color(1, 1, 1, 1); if (booster.IsActive) { SimpleTween.Value(gameObject, 1.0f, 0.5f, 0.5f).SetEase(EaseAnim.EaseLinear). SetOnUpdate((float val) => { if (booster.IsActive) { boosterImage.color = new Color(1, val, val, 1); } else { boosterImage.color = new Color(1, 1, 1, 1); SimpleTween.Cancel(gameObject, true); } }).SetCycled(); } } }
public void MoveLeft(float time, System.Action completeCallBack) { float currPosX = positions[position].x; float currPosY = positions[position].y; position--; if (position < 0) { position = positions.Length - 1; currPosX = positions[position].x; rT.anchoredPosition = positions[position]; position--; } float targetPosX = positions[position].x; GameObject gO = (rT) ? rT.gameObject : null; SimpleTween.Value(gO, currPosX, targetPosX, time).SetOnUpdate((pos) => { if (this != null && rT) { rT.anchoredPosition = new Vector2(pos, currPosY); } }).AddCompleteCallBack(completeCallBack); }
public void StartFly(string score, Vector3 wPos) { scoreText.text = score; Canvas c = GameObject.Find("CanvasMain").GetComponent <Canvas>(); rTransform.SetParent(c.transform); rTransform.anchoredPosition = Coordinats.WorldToCanvasCenterCenter(wPos, c); Vector2 pos = rTransform.anchoredPosition; float dist = Random.Range(300, 500); float time = Random.Range(1.2f, 2.2f); SimpleTween.Value(gameObject, 0f, dist, time).SetOnUpdate((float val) => { Vector2 npos = pos + new Vector2(0, val); if (this) { rTransform.anchoredPosition = npos; } }).SetEase(EaseAnim.EaseOutCubic). SetDelay(Random.Range(0.0f, 0.1f)). AddCompleteCallBack(() => { if (this) { Destroy(gameObject); } }); }
/// <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(); }
/// <summary> /// Close panel /// </summary> /// <param name="panel"></param> public void CloseScrollPanel(bool destroy, Action completeCallBack) { RectTransform panel = GetComponent <RectTransform>(); if (!panel) { return; } SetControlActivity(false); float startX = 1; float endX = 0f; SimpleTween.Cancel(gameObject, true); SimpleTween.Value(gameObject, startX, endX, 0.2f).SetEase(EaseAnim.EaseInCubic). SetOnUpdate((float val) => { transform.localScale = new Vector3(val, 1, 1); }).AddCompleteCallBack(() => { if (destroy && this) { Destroy(gameObject); } completeCallBack?.Invoke(); }); }
internal void RefreshScoreStrip() { // refresh score text if (ScoreCount) { int newCount = BubblesPlayer.Instance.LevelScore; SimpleTween.Cancel(ScoreCount.gameObject, false); SimpleTween.Value(ScoreCount.gameObject, oldCount, newCount, 0.5f).SetOnUpdate((float val) => { oldCount = (int)val; ScoreCount.text = oldCount.ToString(); }); } //Refresh score strip if (!ScoreStrip) { return; } SimpleTween.Cancel(ScoreStrip.gameObject, false); float sizeX = ScoreStrip.GetComponent <RectTransform>().sizeDelta.x; float amount = (BubblesPlayer.Instance.AverageScore > 0) ? (float)BubblesPlayer.Instance.LevelScore / (float)(BubblesPlayer.Instance.AverageScore) : 0; SimpleTween.Value(ScoreStrip.gameObject, ScoreStrip.fillAmount, amount, 0.3f).SetOnUpdate((float val) => { ScoreStrip.fillAmount = val; if (yellowLight) { yellowLight.anchoredPosition = new Vector2(sizeX * Mathf.Min(ScoreStrip.fillAmount, 0.93f), yellowLight.anchoredPosition.y); } }).SetEase(EaseAnim.EaseOutCubic); }
/// <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> /// Stop music audiosource /// </summary> public void StopMusic() { SimpleTween.Cancel(musicVolumeTween, true); if (musicSource && musicSource.isPlaying) { musicVolumeTween = SimpleTween.Value(gameObject, Volume * musicVolumeMult, 0.0f, 1f).SetOnUpdate((float val) => { musicSource.volume = val; }). AddCompleteCallBack(() => { musicSource.Stop(); musicSource.volume = 0; }).ID; } }
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(); }
/// <summary> /// If matched > = 4 cretate bomb from items /// </summary> /// <param name="bombCell"></param> /// <param name="completeCallBack"></param> internal void MoveToBomb(GridCell toCell, float delay, Action completeCallBack) { // Debug.Log("Move to bomb"); SetToFront(true); //scale SimpleTween.Value(gameObject, gameObject.transform.localScale, gameObject.transform.localScale * 1.05f, 0.1f).SetOnUpdate((val) => { gameObject.transform.localScale = val; }); // move SimpleTween.Move(gameObject, transform.position, toCell.transform.position, 0.25f).AddCompleteCallBack(completeCallBack).SetEase(EaseAnim.EaseInBack).SetDelay(delay); }
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(); } }
private void AlphaFadeIn(float tweenDelay, float tweenTime, EaseAnim ease, Action completeCallBack) { fObjectR.SetAlpha(0f); SimpleTween.Value(gameObject, 0f, 1.0f, tweenTime).SetEase(EaseAnim.EaseInCirc).SetOnUpdate((float val) => { fObjectR.SetAlphaK(val); }). SetDelay(tweenDelay).SetEase(ease). AddCompleteCallBack(() => { completeCallBack?.Invoke(); completeCallback_in?.Invoke(); }); }
private void SetScore(int score, int averScore) { if (ScoreCount) { int newCount = score; SimpleTween.Cancel(ScoreCount.gameObject, false); SimpleTween.Value(ScoreCount.gameObject, oldCount, newCount, 0.5f).SetOnUpdate((float val) => { oldCount = (int)val; ScoreCount.text = oldCount.ToString(); }); } }
private void AnimateNewStar(GameObject star, Action completeCallBack) { SimpleTween.Value(star, 0, 1, 0.5f).SetOnUpdate((val) => { if (star) { star.transform.localScale = new Vector3(val, val, val); } }).AddCompleteCallBack(() => { completeCallBack?.Invoke(); }).SetEase(EaseAnim.EaseOutBounce); }
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(); }
/// <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(); }
/// <summary> /// Play current music clip /// </summary> public void PlayCurrentMusic() { if (!musicSource || !currentMusic) { return; } SimpleTween.Cancel(musicVolumeTween, true); float volume = Volume * musicVolumeMult; if (MusicOn) { if ((currentMusic == musicSource.clip) && musicSource.isPlaying) // check volume { float vol = musicSource.volume; if (vol != volume) { musicVolumeTween = SimpleTween.Value(gameObject, vol, volume, 1f).SetOnUpdate((float val) => { musicSource.volume = val; }). AddCompleteCallBack(() => { musicSource.volume = volume; }).ID; } } if ((currentMusic != musicSource.clip) && musicSource.isPlaying) { musicSource.Stop(); musicSource.clip = currentMusic; musicSource.Play(); float vol = musicSource.volume; if (vol != volume) { musicVolumeTween = SimpleTween.Value(gameObject, vol, volume, 1f).SetOnUpdate((float val) => { musicSource.volume = val; }). AddCompleteCallBack(() => { musicSource.volume = volume; }).ID; } } if (!musicSource.isPlaying) { musicSource.clip = currentMusic; musicSource.volume = 0; musicSource.Play(); musicVolumeTween = SimpleTween.Value(gameObject, 0.0f, volume, 1f).SetOnUpdate((float val) => { musicSource.volume = val; }). AddCompleteCallBack(() => { musicSource.volume = volume; }).ID; } } else { StopMusic(); } }
public void PlayBkgMusik(bool play) { if (play && aSbkg && !aSbkg.isPlaying) { aSbkg.volume = 0; aSbkg.Play(); SimpleTween.Value(gameObject, 0.0f, 0.45f, 3.5f).SetOnUpdate((float val) => { aSbkg.volume = val; }). AddCompleteCallBack(() => { }); } else if (!play && aSbkg) { SimpleTween.Value(gameObject, 0.45f, 0.0f, 2f).SetOnUpdate((float val) => { aSbkg.volume = val; }). AddCompleteCallBack(() => { aSbkg.Stop(); }); } }
private void AlphaFadeOut(float tweenDelay, float tweenTime, EaseAnim ease, Action completeCallBack) { fObjectR.SetActive(true); SimpleTween.Value(gameObject, 1.0f, 0.0f, tweenTime).SetEase(EaseAnim.EaseInCirc).SetOnUpdate((float val) => { fObjectR.SetAlphaK(val); }). SetDelay(tweenDelay).SetEase(ease). AddCompleteCallBack(() => { fObjectR.SetActive(false); if (guiMask) { guiMask.gameObject.SetActive(false); } completeCallBack?.Invoke(); completeCallback_out?.Invoke(); }); }
private void SimpleMoveAlongPath(float delay, EaseAnim easeAnim, Action completeCallBack) { if (path == null || path.Count == 0) { // Debug.Log("move start return"); if (completeCallBack != null) { completeCallBack(); } return; } // Debug.Log("move start"); pathPoints = new Vector2[path.Count + 1]; pathPoints[0] = transform.localPosition; for (int i = 1; i < pathPoints.Length; i++) { pathPoints[i] = path[i - 1].gCell.transform.localPosition; } moving = true; PolyLine plPath = new PolyLine(pathPoints); float time = plPath.Length / speed; int segNumber = 0; tweenID = SimpleTween.Value(gameObject, 0, plPath.Length, time). SetOnUpdate((float d) => { if (this) { gameObject.transform.localPosition = plPath.GetPolyLinePosition(d, out segNumber); if (path != null && segNumber < path.Count) { anchored = path[segNumber].gCell; } } }).SetEase(easeAnim).SetDelay(delay). AddCompleteCallBack(() => { // Debug.Log("tween complete callback"); moving = false; if (completeCallBack != null) { completeCallBack(); } }).ID; }
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(); }
/// <summary> /// If matched > = 4 cretate bomb from items /// </summary> /// <param name="bombCell"></param> /// <param name="completeCallBack"></param> internal void MoveMatchToBomb(GridCell fromCell, GridCell toCell, float delay, bool hitProtection, Action completeCallBack) { // Debug.Log("Move to bomb"); if (hitProtection) { fromCell.DirectHitUnderlay(null); fromCell.DirectHitOverlay(null); fromCell.Neighbors.Cells.ForEach((GridCell c) => { c.SideHit(null); }); } SetToFront(true); //scale SimpleTween.Value(gameObject, gameObject.transform.localScale, gameObject.transform.localScale * 1.05f, 0.1f).SetOnUpdate((val) => { gameObject.transform.localScale = val; }); // move SimpleTween.Move(gameObject, transform.position, toCell.transform.position, 0.25f).AddCompleteCallBack(completeCallBack).SetEase(EaseAnim.EaseInBack).SetDelay(delay); }
public void MoveAlongPath(GameObject gObject, Transform relativeTo, float time, float delay, EaseAnim easeAnim, Action completeCallBack) { SimpleTween.Value(gObject, 0, curve.Length, time). SetOnUpdate((float d) => { if (gObject) { gObject.transform.position = relativeTo.TransformPoint(curve.GetPosition(d)); } }).SetEase(easeAnim).SetDelay(delay). AddCompleteCallBack(() => { if (completeCallBack != null) { completeCallBack(); } }); }