void OnEnable() { DontDestroyOnLoad(this); #if UNITY_IPHONE && !UNITY_EDITOR SessionM.GetInstance().SetCallback(this); #endif }
private void OnMouseDown() { //The user has clicked on the toast, so we should let SessionM know they want to claim it. //SessionM will take care of the rest (opening the portal.) //However, we'll want to reset our Toast so the user doesn't click on it again. ResetToastPosition(); SessionM.GetInstance().NotifyClaimed(); }
//Helper Methods private void LerpToast() { float positionPercentage = 1f; switch (toastState) { case ToastState.Toasting: toastTimer += Time.deltaTime; positionPercentage = toastTimer / TOAST_ANIMATION_TIME; if (positionPercentage > 1f) { positionPercentage = 1f; toastState = ToastState.Displaying; toastTimer = 0f; } this.transform.position = Vector3.Lerp(offScreenPosition.position, onScreenPosition.position, positionPercentage); break; case ToastState.Displaying: toastTimer += Time.deltaTime; if (toastTimer > TOAST_DISPLAY_TIME) { toastState = ToastState.Untoasting; toastTimer = 0f; } break; case ToastState.Untoasting: toastTimer += Time.deltaTime; positionPercentage = toastTimer / TOAST_ANIMATION_TIME; if (positionPercentage > 1f) { positionPercentage = 1f; toastState = ToastState.Offscreen; toastTimer = 0f; //Our Native Achievement has come and gone without the user clicking on it //We need to notify SessionM that the achievment was dismissed. SessionM.GetInstance().NotifyDismissed(); } this.transform.position = Vector3.Lerp(onScreenPosition.position, offScreenPosition.position, positionPercentage); break; default: Debug.LogWarning("Invalid Toast State in LerpToast."); break; } }
private void UserChanged(IDictionary <string, object> userInfo) { UserData user = SessionM.GetInstance().GetUserData(); if (user == null) { return; } optOutLabel.text = "Opt Out: " + user.IsOptedOut().ToString(); isRegisteredLabel.text = "Is Registered: " + user.IsRegistered(); isLoggedInLabel.text = "Is Logged In: " + user.IsLoggedIn(); pointBalanceLabel.text = "Point Balance: " + user.GetUserPointBalance(); unclaimedAchCountLabel.text = "Unclaimed Achievement Count: " + user.GetUnclaimedAchievementCount(); unclaimedAchValueLable.text = "Unclaimed Achievement Value: " + user.GetUnclaimedAchievementValue(); }
//Exposed Methods public void ShowAchievementToast(string achievementTitle, int mPointValue, string achievementMessage) { //Exit this call if there is currently an active Toast //(This shouldn't occur because we have notified SessionM we are currently displaying an achievement.) if (toastState != ToastState.Offscreen) { return; } titleText.text = achievementTitle; mPointsText.text = "mPoints: " + mPointValue.ToString(); messageText.text = achievementMessage; toastState = ToastState.Toasting; toastTimer = 0f; //Notify SessionM We are about to display the achievment. SessionM.GetInstance().NotifyPresented(); }
private void UpdateBadge() { int badgeCount = SessionM.GetInstance().GetUnclaimedAchievementCount(); if (badgeVisible == false && badgeCount > 0) { ShowBadge(); } if (badgeVisible == true && badgeCount == 0) { HideBadge(); } if (badgeCount > 99) { badgeCount = 99; } badgeText.text = badgeCount.ToString(); }
void OnDisable() { #if UNITY_IPHONE && !UNITY_EDITOR SessionM.GetInstance().SetCallback(null); #endif }