/// <summary> /// Called when a purchase fails. /// </summary> public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason) { PurchaseInProgress = false; Loading.Instance.Hide(); stringBuilder.AppendFormat("Product {0} failed at {1}, reason: {2}\n", LastPurchaseProductId, UnbiasedTime.Instance.UTCNow().ToString(CultureInfo.InvariantCulture), failureReason); SaveLog(); MyDebug.Log(string.Format("OnPurchaseFailed: FAIL. Product: '{0}', PurchaseFailureReason: {1}", product.definition.storeSpecificId, failureReason)); Fabric.Crashlytics.Crashlytics.Log(string.Format("OnPurchaseFailed: FAIL. Product: '{0}', PurchaseFailureReason: {1}", product.definition.storeSpecificId, failureReason)); // A product purchase attempt did not succeed. Check failureReason for more detail. Consider sharing this reason with the user. switch (failureReason) { // for these cases we don't need to inform further case PurchaseFailureReason.UserCancelled: break; // for these we show an error default: DialogManager.Instance.ShowError(LocaliseText.Format("GeneralMessage.Error.GeneralError", failureReason)); break; } }
void CheckNotificationsPermission() { int CountMainMenuColdStart = PreferencesFactory.GetInt(Constants.KeyCountMainMenuColdStart); DateTime now = UnbiasedTime.Instance.Now(); // not in first launch if (CountMainMenuColdStart > 0 && !Allowed()) { // the date when we detected that notifications are denied if (!PreferencesFactory.HasKey(Constants.KeyNoNotificationPermissionDeniedDate)) { PreferencesFactory.SetString(Constants.KeyNoNotificationPermissionDeniedDate, now.ToString(CultureInfo.InvariantCulture)); return; } DateTime dateOfDenying = DateTime.Parse(PreferencesFactory.GetString(Constants.KeyNoNotificationPermissionDeniedDate, now.ToString(CultureInfo.InvariantCulture))); float minutes3days = 3 * 24 * 60; float minutes10days = 10 * 24 * 60; if (Debug.isDebugBuild) { minutes3days = 1f; // 30 sec minutes10days = 2f; // 1 min } // 3 days before show alert for first time if (now.Date < dateOfDenying.AddMinutes(minutes3days).Date) { return; } DateTime postponeDate = DateTime.Parse(PreferencesFactory.GetString(Constants.KeyNoNotificationPermissionDate, now.ToString(CultureInfo.InvariantCulture))); // 10 days to show alert again if user postpone it if (PreferencesFactory.HasKey(Constants.KeyNoNotificationPermissionDate) && now.Date < postponeDate.AddMinutes(minutes10days).Date) { return; } PreferencesFactory.DeleteKey(Constants.KeyNoNotificationPermissionDate); string text = LocaliseText.Get("Notifications.DeniedText"); Alert alert = new Alert("", text) .SetPositiveButton(LocaliseText.Get("Notifications.AllowText"), () => { iSDK.Utils.OpenSettings(); }) .SetNeutralButton(LocaliseText.Get("Notifications.IgnoreText"), () => { PreferencesFactory.SetString(Constants.KeyNoNotificationPermissionDate, now.ToString(CultureInfo.InvariantCulture)); }) .AddOptions(new AlertIOSOptions() { PreferableButton = Alert.ButtonType.Positive }); alert.Show(); } }
// Packs void SetPackData(Pack pack, GameObject newObject) { if (pack.IsUnlocked) { CanvasGroup canvasGroup = GameObjectHelper.GetChildComponentOnNamedGameObject <CanvasGroup>(newObject, "PlayButton", true); canvasGroup.alpha = 1f; } Text text = GameObjectHelper.GetChildComponentOnNamedGameObject <Text>(newObject, "Name", true); text.text = LocaliseText.Get(pack.JsonData.GetString("name")); GameObject iconObject = GameObjectHelper.GetChildNamedGameObject(newObject, "Icon", true); if (pack.Progress > 0.9f) { iconObject.SetActive(true); } int points = LevelController.Instance.PointsForPack(pack); if (points > 0) { GameObject pointsObject = GameObjectHelper.GetChildNamedGameObject(newObject, "Points", true); pointsObject.SetActive(true); Text pointsNumber = GameObjectHelper.GetChildComponentOnNamedGameObject <Text>(pointsObject, "PointsNumber", true); pointsNumber.text = points.ToString(); } }
string RandomNotificationText() { string[] texts; #if UNITY_ANDROID if (iSDK.Utils.AndroidSDKVersion() < 23) { texts = new string[3] { LocaliseText.Get("Notifications.NotPlayingRecentlyNoEmoji"), LocaliseText.Get("Notifications.HighIQNoEmoji"), LocaliseText.Get("Notifications.MultiplayerNoEmoji") }; } else { texts = new string[3] { LocaliseText.Get("Notifications.NotPlayingRecently"), LocaliseText.Get("Notifications.HighIQ"), LocaliseText.Get("Notifications.Multiplayer") }; } #else texts = new string[3] { LocaliseText.Get("Notifications.NotPlayingRecently"), LocaliseText.Get("Notifications.HighIQ"), LocaliseText.Get("Notifications.Multiplayer") }; #endif int index = UnityEngine.Random.Range(0, texts.Length); return(texts[index]); }
public void Logout() { DialogManager.Instance.Show(prefabName: "ConfirmDialog", title: LocaliseText.Get("Text.Logout"), text: LocaliseText.Get("Text.Sure"), doneCallback: LogoutCallback); }
private void ShowInfoDialogWithText(string message, string buttonTitle) { DialogManager.Instance.Show(prefabName: "GeneralMessageOkButton", title: LocaliseText.Get("Text.Info"), text: message, dialogButtons: DialogInstance.DialogButtonsType.Ok); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var dataProperty = property.FindPropertyRelative("_data"); var isLocalisedProperty = property.FindPropertyRelative("_isLocalised"); label = EditorGUI.BeginProperty(position, label, property); var contentPosition = EditorGUI.PrefixLabel(position, label); var rowPosition = new Rect(contentPosition) { height = EditorGUIUtility.singleLineHeight }; var dataPosition = new Rect(rowPosition); dataPosition.xMax -= 20; EditorGUI.PropertyField(dataPosition, dataProperty, GUIContent.none); dataPosition.x = contentPosition.xMax - 16; dataPosition.xMax = contentPosition.xMax; isLocalisedProperty.boolValue = EditorGUI.Toggle(dataPosition, new GUIContent("", "Lets you toggle whether this is a fixed or localised test"), isLocalisedProperty.boolValue, GuiStyles.LocalisationToggleStyle); if (isLocalisedProperty.boolValue) { rowPosition.y += EditorGUIUtility.singleLineHeight + 2; var localisedText = LocaliseText.Exists(dataProperty.stringValue) ? LocaliseText.Get(dataProperty.stringValue) : "<Key not found in localisation file>"; EditorGUI.LabelField(rowPosition, localisedText); } //EditorGUI.indentLevel += 1; EditorGUI.EndProperty(); }
/// <summary> /// Should be called if we assume they like the game and when not invoked as a direct result of their /// actions (e.g. use after 20 plays). Gives rate, later and remind options. /// </summary> public void GameFeedbackAssumeTheyLikeOptional() { // open the text based upon the platform var text2Key = ""; switch (Application.platform) { case RuntimePlatform.Android: text2Key = "GameFeedback.AssumeLikeOptionalAndroid"; break; case RuntimePlatform.IPhonePlayer: text2Key = "GameFeedback.AssumeLikeOptionaliOS"; break; } DialogManager.Instance.Show("GameFeedbackDialog", titleKey: "GameFeedback.RateTitle", text2: LocaliseText.Format(text2Key, GameManager.Instance.GameName), doneCallback: RateCallback, dialogButtons: DialogInstance.DialogButtonsType.Custom); //#if UNITY_EDITOR // Application.OpenURL(GameManager.Instance.PlayWebUrl); //#elif UNITY_ANDROID // AndroidRateUsPopUp rate = AndroidRateUsPopUp.Create(DialogTitle, String.Format(LocaliseText.Get("GameFeedback.AssumeLikeOptionalAndroid"), GameManager.Instance.GameName), GameManager.Instance.PlayMarketUrl); // rate.ActionComplete += OnAndroidRatePopUpClose; //#elif UNITY_IPHONE // IOSRateUsPopUp rate = IOSRateUsPopUp.Create(DialogTitle, String.Format(LocaliseText.Get("GameFeedback.AssumeLikeOptionaliOS"), GameManager.Instance.GameName)); // rate.OnComplete += OnIOSRatePopUpClose; //#else //#endif }
/// <summary> /// Free prize dialog that giges the user coins. We default to the standard General Message window, adding any additional /// content as setup in the FreePrizeManager configuration. /// </summary> public void ShowFreePrizeDialog() { var dialogInstance = DialogManager.Instance.Create(null, null, ContentPrefab, null, runtimeAnimatorController: ContentAnimatorController); string text = LocaliseText.Format("FreePrize.Text1", CurrentPrizeAmount); dialogInstance.Show(title: LocaliseText.Get("FreePrize.Title"), text: text, text2Key: "FreePrize.Text2", doneCallback: ShowFreePrizeDone, dialogButtons: ContentShowsButtons ? DialogInstance.DialogButtonsType.Custom : DialogInstance.DialogButtonsType.Ok); }
IEnumerator AvatarUploading(string uploadUrl, Texture2D tex, Action <Texture2D> action) { byte[] bytes = tex.EncodeToJPG(); // Create a Web Form, this will be our POST method's data var form = new WWWForm(); form.AddBinaryData("file", bytes, "avatar.jpg", "image/jpeg"); WWW w = new WWW(uploadUrl, form); yield return(w); Loading.Instance.Hide(); if (w.error != null && w.error != "") { DialogManager.Instance.ShowError(LocaliseText.Get("Profile.AvatarNotUploaded")); } else { DialogManager.Instance.ShowInfo(LocaliseText.Get("Profile.AvatarUploaded")); if (action != null) { action(tex); } } }
void AnimateScoreText(int _points) { Text _scoreText = GameObjectHelper.GetChildComponentOnNamedGameObject <Text>(_multiplayer ? multiplayerView : pointsView, "ScoreResult", true); if (!_scoreText) { return; } int points = 0; DOTween.To(() => points, x => points = x, _points, 1.25f).SetEase(Ease.Linear).OnUpdate(() => { if (!_scoreText) { return; } string distanceText; if (points == 1 || points == -1) { distanceText = LocaliseText.Format("LevelCompleted.ScoreOne", points.ToString()); } else { distanceText = LocaliseText.Format("LevelCompleted.Score", points.ToString()); } _scoreText.text = distanceText; }); }
public void ChangeUser(string userName) { if (string.IsNullOrEmpty(userName)) { DialogManager.Instance.ShowError(LocaliseText.Get("Account.UsernameEmptyError")); return; } if (!IsUsernameValid(userName)) { DialogManager.Instance.ShowError(LocaliseText.Get("Account.UsernameNotValid")); return; } new ChangeUserDetailsRequest() .SetDisplayName(userName) .Send((response) => { if (response.HasErrors) { ParseServerResponse(response.Errors); return; } PreferencesFactory.SetString(Constants.ProfileUsername, userName); }); }
public void CopyLink() { #if UNITY_IOS UniClipboard.SetText(Constants.ShareURLLink(Constants.ShareCodes.CopyLink)); #endif #if UNITY_ANDROID UniClipboard.SetText(Constants.ShareURLLink(Constants.ShareCodes.CopyLink)); #endif if (!Debug.isDebugBuild) { Flurry.Flurry.Instance.LogEvent("Share_CopyLink"); Fabric.Answers.Answers.LogInvite("CopyLink"); Fabric.Answers.Answers.LogShare("CopyLink", contentId: "Invite"); } DialogManager.Instance.Show(prefabName: "GeneralMessageOkButton", title: LocaliseText.Get("Invite.CopyLinkTitle"), text: LocaliseText.Get("Invite.CopyLinkText"), dialogButtons: DialogInstance.DialogButtonsType.Ok, doneCallback: (DialogInstance dialog) => { #if UNITY_EDITOR InviteBonusCoins(); #endif }); }
string RandomNotificationText() { string[] texts; #if UNITY_ANDROID if (iSDK.Utils.AndroidSDKVersion() < 23) { texts = new string[2] { LocaliseText.Get("FreePrize.PushNotificationGuessWhatNoEmoji"), LocaliseText.Get("FreePrize.PushNotificationDailyBonusNoEmoji") }; } else { texts = new string[2] { LocaliseText.Get("FreePrize.PushNotificationGuessWhat"), LocaliseText.Get("FreePrize.PushNotificationDailyBonus") }; } #else texts = new string[2] { LocaliseText.Get("FreePrize.PushNotificationGuessWhat"), LocaliseText.Get("FreePrize.PushNotificationDailyBonus") }; #endif int index = UnityEngine.Random.Range(0, texts.Length); return(texts[index]); }
public void Refresh() { foreach (Rank rank in ((CustomGameManager)CustomGameManager.Instance).Ranks.Items) { rank.LoadData(); GameObject newObject = Instantiate(Prefab); newObject.transform.SetParent(transform, false); newObject.GetComponent <Button>().onClick.AddListener(() => { LevelsListController.Instance.OpenRankButton(rank); }); if (rank.IsUnlocked) { CanvasGroup canvasGroup = GameObjectHelper.GetChildComponentOnNamedGameObject <CanvasGroup> (newObject, "PlayButton", true); canvasGroup.alpha = 1f; } Text text = GameObjectHelper.GetChildComponentOnNamedGameObject <Text> (newObject, "Name", true); text.text = LocaliseText.Get(rank.JsonData.GetString("name")); buttons.Add(newObject); } }
public void SendJoinChallengeRequest(string challengeInstanceId) { new JoinChallengeRequest() .SetChallengeInstanceId(challengeInstanceId) .Send((response) => { if (!response.HasErrors) { if (response.Joined != null && (bool)!response.Joined) { if (_onChallengeDetected != null) { _onChallengeDetected.OnErrorReceived(LocaliseText.Get("Challenge.NotAvailable")); } RefreshChallengesList(); } } else { if (_onChallengeDetected != null) { _onChallengeDetected.OnErrorReceived(LocaliseText.Get("Challenge.NotAvailable")); } RefreshChallengesList(); } }); }
public void RewardShare() { #if UNITY_EDITOR RewardsShareHelper.RewardShareCoins(); _rewardShareButton.SetActive(false); return; #endif FacebookRequests.Instance.FeedShare(Constants.ShareURLLink(Constants.ShareCodes.FacebookFeed), LocaliseText.Get("GameName"), string.Format("{0} #{1}", Constants.ShareURLLink(Constants.ShareCodes.FacebookFeed), Constants.HashTagSocials), (FacebookShareLinkMessage.ResultType result) => { if (result == FacebookShareLinkMessage.ResultType.OK) { RewardsShareHelper.RewardShareCoins(); _rewardShareButton.SetActive(false); } if (!Debug.isDebugBuild) { Flurry.Flurry.Instance.LogEvent("Share_Facebook_Feed"); Fabric.Answers.Answers.LogLevelStart("Share_Facebook_Feed"); } }); }
public void Restore() { DialogManager.Instance.Show(prefabName: "ConfirmDialog", title: LocaliseText.Get("Button.Restore"), text: LocaliseText.Get("Market.RestoreDescription"), doneCallback: RestoreCallback, dialogButtons: DialogInstance.DialogButtonsType.OkCancel); }
public void OnPreLocalise(LocaliseText reference) { if (reference.PreLocaliseValue == null) { return; } reference.PreLocaliseValue = reference.PreLocaliseValue.Replace('H', 'X'); }
private void GetLocalisationString() { // if localisation key specified then get and cache string. if (!string.IsNullOrEmpty(LocalisationKey)) { _localisationString = LocaliseText.Get(LocalisationKey); } }
// Use this for initialization void Start() { if (!string.IsNullOrEmpty(LocalisationKey)) { _localisationString = LocaliseText.Get(LocalisationKey); } UpdateDisplay(); }
void Awake() { var player = GameManager.Instance.Player; if (player == null) return; var textComponent = GetComponent<Text>(); var text = LocaliseText.Exists(Key) ? LocaliseText.Get(Key) : Key; textComponent.text = string.Format(text, player.Number, player.Name, player.Description); }
bool LocalisationHandler(BaseMessage message) { for (int i = 0; i < CustomPaymentManager.Coins.Length; i++) { CustomPaymentManager.Coins[i].Description = LocaliseText.Get(CustomPaymentManager.Coins[i].LanguageKey); } return(true); }
public void ShowShareScreen() { Text nameText = GameObjectHelper.GetChildComponentOnNamedGameObject <Text> (DialogInstance.gameObject, "LevelName", true); nameText.text = LocaliseText.Get("LevelCompleted.TellYourFriends"); multiplayerView.SetActive(false); pointsView.SetActive(false); shareView.SetActive(true); }
public void FacebookLogout() { DialogManager.Instance.Show(prefabName: "GameQuitMessage", title: LocaliseText.Get("Text.Logout"), text: LocaliseText.Get("Text.Sure"), doneCallback: FacebookLogoutCallback, dialogButtons: DialogInstance.DialogButtonsType.OkCancel); GameSparksManager.Instance.SyncProgress(); }
public void ForgotPassAction(GameObject GO, Action callback) { var mainTransform = GO.transform; var email = mainTransform.Find("EmailField").GetComponent <InputField> (); var emailString = email.text; if (string.IsNullOrEmpty(emailString)) { ShowInfoDialogWithText(LocaliseText.Get("Account.EmailEmptyError"), "CLOSE"); return; } if (!IsMailValid(emailString)) { ShowInfoDialogWithText(LocaliseText.Get("Account.EmailNotValidError"), "CLOSE"); return; } if (!Reachability.Instance.IsReachable()) { ShowInfoDialogWithText(LocaliseText.Get("Account.NoConnection"), "CLOSE"); return; } if (!GS.Available) { GS.Reconnect(); } GSRequestData d = new GSRequestData(); d.Add("email", emailString); d.Add("action", "passwordRecoveryRequest"); Loading.Instance.Show(); new AuthenticationRequest() .SetUserName("") .SetPassword("") .SetScriptData(d) .Send(((response) => { Loading.Instance.Hide(); if (response.HasErrors) { ShowInfoDialogWithText(LocaliseText.Get("Account.ForgotPassEmailSuccess"), "CLOSE"); if (callback != null) { callback(); } } })); }
public static void SetRewardText(GameObject parent) { Text text = GameObjectHelper.GetChildComponentOnNamedGameObject <Text>(parent, "Text", true); if (text == null) { return; } text.text = string.Format("+ {0}", LocaliseText.Format("Text.NumberCoins", Constants.AskFriendsCoins)); }
public void NativeInvite(Texture2D tex) { #if UNITY_IOS IOSSocialManager.OnMediaSharePostResult += HandleOnShareCallback; IOSSocialManager.Instance.ShareMedia(string.Format("{0} #{1}", Constants.ShareURLLink(Constants.ShareCodes.Native), Constants.HashTagSocials), tex); #endif #if UNITY_ANDROID AndroidSocialGate.OnShareIntentCallback += HandleOnShareIntentCallback; AndroidSocialGate.StartShareIntent(LocaliseText.Get("GameName"), string.Format("{0} #{1}", Constants.ShareURLLink(Constants.ShareCodes.Native), Constants.HashTagSocials), tex); #endif }
public virtual void BuyProductId(string productId) { if (PurchaseInProgress == true) { DialogManager.Instance.ShowInfo("Purchase processing..."); return; } stringBuilder.Length = 0; PurchaseInProgress = true; LastPurchaseProductId = productId; // // If the stores throw an unexpected exception, use try..catch to protect my logic here. try { // If Purchasing has been initialized ... if (IsInitialized()) { // ... look up the Product reference with the general product identifier and the Purchasing system's products collection. Product product = _controller.products.WithID(productId); // If the look up found a product for this device's store and that product is ready to be sold ... if (product != null && product.availableToPurchase) { Loading.Instance.Show(); stringBuilder.AppendFormat("Buy product {0} at {1}, coins {2}, points {3}\n", productId, UnbiasedTime.Instance.UTCNow().ToString(CultureInfo.InvariantCulture), GameManager.Instance.Player.Coins, GameManager.Instance.Player.Score); MyDebug.Log(string.Format("Purchasing product asychronously: '{0}'", product.definition.id));// ... buy the product. Expect a response either through ProcessPurchase or OnPurchaseFailed asynchronously. _controller.InitiatePurchase(product); } // Otherwise ... else { // ... report the product look-up failure situation DialogManager.Instance.ShowError(textKey: "Billing.NotAvailable"); } } // Otherwise ... else { // ... report the fact Purchasing has not succeeded initializing yet. Consider waiting longer or retrying initiailization. DialogManager.Instance.ShowError(textKey: "Billing.NotInitialised"); } } // Complete the unexpected exception handling ... catch (Exception e) { // ... by reporting any unexpected exception for later diagnosis. DialogManager.Instance.ShowError(LocaliseText.Format("GeneralMessage.Error.GeneralError", e.ToString())); } }
void Awake() { Assert.IsNotNull(GenericGameItemManager.Instance.GenericGameItems, "GenericGameItems are not setup when referenced from ShowGenericGameItemInfo"); var genericGameItem = GenericGameItemManager.Instance.GenericGameItems.Selected; if (genericGameItem != null) { var textComponent = GetComponent<Text>(); var text = LocaliseText.Exists(Key) ? LocaliseText.Get(Key) : Key; textComponent.text = string.Format(text, genericGameItem.Number, genericGameItem.Name, genericGameItem.Description); } }