コード例 #1
0
ファイル: HighScoreManager.cs プロジェクト: LuanNg/PianoTiles
        public void RefreshMetric()
        {
            if (!isInit)
            {
                Initialize();
            }
            if (!isInit)
            {
                return;
            }

            listHighscore = ProfileHelper.Instance.ListHighScore;
            if (listHighscore == null)
            {
                Debug.LogWarning("Could not initialize high-score manager if player profile has not been initialized first");
                return;
            }

            oldNumCrown = totalCrown;
            oldNumStar  = totalStar;
            totalCrown  = totalStar = 0;
            //Debug.Log(string.Format("Refreshing metrics old crowns {0}, old stars {1}", oldNumCrown, oldNumStar));
            for (int i = 0; i < listHighscore.Count; i++)
            {
                totalStar  += Mathf.Clamp(listHighscore[i].highestStar, 0, 3);
                totalCrown += listHighscore[i].highestCrown;
            }
            //Debug.Log(string.Format("Refreshing metrics new crowns {0}, new stars {1}", totalCrown, totalStar));
            if ((oldNumStar != totalStar) || (oldNumCrown != totalCrown))
            {
                MessageBus.Annouce(MSG_USER_PLAY_RECORD_CHANGED);
            }
        }
コード例 #2
0
        /// <summary>
        /// wait for run effect life
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        private IEnumerator <float> IEOpenMainGame(Scenes scene, object data)
        {
            MessageBus.Annouce(new Message(MessageBusType.PlaySongAction));
            yield return(Timing.WaitForSeconds(0.3f));

            OnProgressChangeScene(scene, data);
        }
コード例 #3
0
    public void SendUserMessageButtonClick()
    {
        string status = inputComment.value;

        MessageBus.Annouce(new Message(MessageBusType.CompletedPostStatusShareFacebook, status));
        AnalyticsHelper.Instance.LogClickItem("Post screenshot");
        SceneManager.Instance.CloseScene();
    }
コード例 #4
0
ファイル: NativeAdsItem.cs プロジェクト: LuanNg/PianoTiles
 private void OnNativeAdLoadFailed(string error)
 {
     //Loom.Instance.QueueOnMainThread(() => {
     Debug.Log("NATIVE ADS: Load native ads failed with error: " + (++failCount).ToString() + error);
     //txtTitle.text = "Ads loaded fail";
     MessageBus.Annouce(new Message(MessageBusType.NativeAdItemFailedToLoad, gameObject));
     //reload ads after some delay if failed
     //StartCoroutine(ReloadAd());
     //});
 }
コード例 #5
0
 public void TouchInCheckboxAction()
 {
     onSelected = toggle.value;
     if (model != null)
     {
         model.isSelected = onSelected;
     }
     MessageBus.Annouce(new Message(MessageBusType.OnSelectedOrUnselectedInviteFriend, model));
     //  toggle.activeSprite.cachedGameObject.SetActive(onSelected);
 }
コード例 #6
0
    public void ClaimAchievement(AchievementModel achievement, Action <List <AchievementRewardModel> > onAchievementClaimed = null)
    {
        if (!achievement.isClaimed)
        {
            //print("Claiming achievement with hash: " + achievement.GetHashCode());
            ach.MarkAchievementAsClaimed(achievement.ID);
            if (onAchievementClaimed != null)
            {
                onAchievementClaimed(achievement.listReward);
                Mio.Utils.AnalyticsHelper.Instance.LogClaimedAchievement(achievement.title);
            }

            MessageBus.Annouce(msgAchievementDataChanged);
        }
    }
コード例 #7
0
    private void OnAchievementUnlocked(Achievement.Achievement achievement)
    {
        if (GameManager.Instance != null)
        {
            GameManager.Instance.SessionData.needAttentionAchievement = true;
        }

        Mio.Utils.AnalyticsHelper.Instance.LogUnlockAchievement(achievement.ID);
        Mio.Utils.AnalyticsHelper.Instance.LogClamiableAchievement(achievement.DisplayName);
        Debug.Log("OnAchievementUnlocked");
        if (achievement.Data.tag == "daily" && isCollect == true)
        {
            AchievementHelper.Instance.LogAchievement("finishQuest");
        }
        MessageBus.Annouce(msgAchievementDataChanged);
    }
コード例 #8
0
ファイル: NativeAdsItem.cs プロジェクト: LuanNg/PianoTiles
    private void OnNativeAdLoaded()
    {
        Debug.Log("NATIVE ADS: Ad Loaded " + (++loadCount).ToString());
        //Loom.Instance.QueueOnMainThread (() => {
        //Debug.LogWarning ("NATIVE ADS: Ad Loaded");
        if (nativeAd != null)
        {
            btnCall2Action.onClick.Clear();
            nativeAd.RegisterGameObjectForImpression(gameObject, new UIButton[] { btnCall2Action }, impressionCamera);
            //gameObject.SetActive(true);
            if (txtTitle != null)
            {
                txtTitle.text = nativeAd.Title;
            }
            if (txtSocialContext != null)
            {
                if (!string.IsNullOrEmpty(nativeAd.SocialContext))
                {
                    txtSocialContext.text = nativeAd.SocialContext;
                }
                else
                {
                    txtSocialContext.gameObject.SetActive(false);
                }
            }
            if (txtCall2Action != null)
            {
                txtCall2Action.text = nativeAd.CallToAction;
            }
            if (txtSubTitle != null)
            {
                txtSubTitle.text = nativeAd.Subtitle;
            }
            if (iconImage != null)
            {
                StartCoroutine(C_LoadIconImage());
            }
            isLoaded = true;

            MessageBus.Annouce(new Message(MessageBusType.NativeAdItemLoaded, gameObject));
        }
        //});
    }
コード例 #9
0
 void OnlineGameOver()
 {
     MessageBus.Annouce(new Message(MessageBusType.OnMeDieOnline));
     gameplay.currentState = TileMasterGamePlay.GameState.GameOver;
 }
コード例 #10
0
 public void ChooseLanguageClick()
 {
     Localization.language = language;
     MessageBus.Annouce(new Message(MessageBusType.LanguageChanged, Localization.language));
     //     ChooseLanguagePopUp.Insta
 }
コード例 #11
0
        private void DisplaySongResult()
        {
            MidiPlayer.Instance.ShouldPlay = true;
            animatorBestScoreEffect.gameObject.SetActive(false);

            score = Counter.GetQuantity(Counter.KeyScore);
            star  = Mathf.Clamp(Counter.GetQuantity(Counter.KeyStar), 0, 3);
            crown = Counter.GetQuantity(Counter.KeyStar) - 3;
            if (crown < 0)
            {
                crown = 0;
            }

            //return 1 live for user if they haven't score any point at all
            if (score <= 0)
            {
                ProfileHelper.Instance.CurrentLife += 1;
            }

            //set song title
            songInfo.SetTitle(GameManager.Instance.SessionData.currentLevel.songData.name);

            int animatingScore = 0;

            //update score with a little animation
            DOTween.To(() => animatingScore, x => animatingScore = x, score, 1f)
            .OnUpdate(() => {
                lbScore.text = animatingScore.ToString();
                //MidiPlayer.Instance.PlayPianoNote(SOUND_PIANO_FINISHED_SCORING);
            })
            .SetDelay(0.5f)
            //.OnComplete(() => { MidiPlayer.Instance.PlayPianoNote(SOUND_PIANO_FINISHED_SCORING); })
            .Play();

            if (crown > 0)
            {
                songInfo.SetNumCrowns(crown);
            }
            else
            {
                songInfo.SetNumStars(star);
            }

            string songID         = GameManager.Instance.SessionData.currentLevel.songData.storeID;
            bool   isNewBestScore = false;

            //update last play levels
            GameManager.Instance.StoreLastPlayLevel();

            //update highscore
            if (HighScoreManager.Instance.UpdateHighScore(songID, score))
            {
                isNewBestScore = true;
                //check and show newly unlocked songs
                Timing.RunCoroutine(C_ShowUnlockedSongs(2.5f));
                //only update crown and star if getting a new highscore
                if (crown > 0)
                {
                    if (HighScoreManager.Instance.UpdateHighScore(songID, crown, ScoreType.Crown))
                    {
                        //if this is the first time reach 3 crowns, also set achievement
                        if (crown == 3)
                        {
                            AchievementHelper.Instance.LogAchievement("song6Stars");
                        }
                    }
                    ;
                }
                if (star > 0)
                {
                    if (HighScoreManager.Instance.UpdateHighScore(songID, star, ScoreType.Star))
                    {
                        //if this is the first time reach 3 stars, also set achievement
                        if (star == 3)
                        {
                            AchievementHelper.Instance.LogAchievement("song3Stars");
                        }
                    }
                }
            }

            //MidiPlayer.Instance.ShouldPlay = false;
            AnalyticsHelper.Instance.LogLevelFinished(GameManager.Instance.SessionData.currentLevel.songData.name, score, star, crown);
            MessageBus.Annouce(saveUserDataMessage);

            ProfileHelper.Instance.PushUserData(true);

            if (!isNewBestScore)
            {
                lbHighScore.text = Localization.Get("maingame_highscore") + " " + HighScoreManager.Instance.GetHighScore(songID).ToString();
            }
            else
            {
                lbHighScore.text = "";
                if (score > 0)
                {
                    Timing.RunCoroutine(C_ShowNewBest(2f));
                }
            }

            //achievement logging
            if (crown == 3)
            {
                AchievementHelper.Instance.LogAchievement("turn6Stars");
            }
            if (star == 3)
            {
                AchievementHelper.Instance.LogAchievement("turn3Stars");
            }
            GameManager.Instance.SaveAchievementValue();
            MessageBus.Annouce(gameDataChangedMessage);

            float delaySceneAnimation = isNewBestScore ? 3f : 2f;

            Timing.RunCoroutine(C_ShowSceneAnimation(delaySceneAnimation));

            UnityAdsHelper.Instance.ShowInterstitialAds(false);
            AdmobAdsHelper.Instance.ShowInterstitialAds();
        }
コード例 #12
0
 public void SendCancel()
 {
     MessageBus.Annouce(new Message(MessageBusType.CancelPostStatusShareFacebook));
     SceneManager.Instance.CloseScene();
 }