void OnBuyManaCallback() { if (_userData.Mana < Settings.MaxMana) { // Play sound SoundManager.Instance.PlaySound(SoundID.Coin); // Decrease coin NotificationManager.CoinChanged(_userData.Coin - Settings.CoinToBuyFullMana); float duration = (Settings.MaxMana - _userData.Mana) / 20.0f; var action = LerpIntAction.Create(_userData.Mana, Settings.MaxMana, duration, (mana) => { NotificationManager.ManaChanged(mana); }); _runManaAction = gameObject.Play(action, () => { _runManaAction = null; }); } else { //Log.Debug("Full Mana!"); } }
protected override void OnShowFinished(Action callback) { // Play firework if (fireworkPrefab != null) { int total = fireworkPositions.Length; int[] positions = total.RandomIndices(); int count = total > minFirework?UnityEngine.Random.Range(minFirework, total) : total; float delay = 0.0f; for (int i = 0; i < count; i++) { GameObject firework = Instantiate(fireworkPrefab); firework.transform.position = fireworkPositions[positions[i]].transform.position; if (delay > 0) { ParticleSystem ps = firework.GetComponent <ParticleSystem>(); ps.Pause(); firework.Play(SequenceAction.Create(DelayAction.Create(delay), CallFuncAction.Create(() => { SoundManager.Instance.PlaySound(SoundID.BigFirework, SoundType.New); ps.Play(); }))); } else { SoundManager.Instance.PlaySound(SoundID.BigFirework, SoundType.New); } delay += 0.3f; } if (UserData.Instance.Map == 99 && !UserData.Instance.PlayedCutscene4) { ShowEndgameStory(); } } int level = UserData.Instance.Map; // Check if win new map if (!UserData.Instance.IsWinned(level)) { UserData.Instance.SetWinned(level); // Add bonus coins int coins = Settings.GetBonusCoins(level); NotificationManager.CoinChanged(UserData.Instance.Coin + coins); if (bonus != null) { // Show bonus bonus.Show(); bonus.SetAlpha(1.0f, true); if (coinText != null) { // Play sound SoundManager.Instance.PlaySound(SoundID.Coin, SoundType.Loop); var action = LerpIntAction.Create(1, coins, 0.5f, (coin) => { coinText.text = coin.ToString(); }); gameObject.Play(action, () => { // Stop sound SoundManager.Instance.StopSound(SoundID.Coin); }); } } } // Show touch and overlay SetShowTouchAndOverlay(true); Invoke("CheckShowAds", 1.2f); Invoke("OnReady", 2f); if (callback != null) { callback(); } }