예제 #1
0
 private static void OnRedeemCodeReturnFailed(string e)
 {
     new Message {
         title   = LocalizeUtils.Get("Redeem Failed"),
         content = LocalizeUtils.Get(e),
     }.Show();
     Handheld.StopActivityIndicator();
 }
예제 #2
0
 public void SetText(string text, Color color, int fontSize, TextAnchor alignment)
 {
     _contentText.text      = LocalizeUtils.Get(TermCategory.Tutorial, text);
     _contentText.color     = color;
     _contentText.alignment = alignment;
     _contentText.fontSize  = fontSize;
     if (string.IsNullOrEmpty(text)) //If string is empty hide the textbox.
     {
         _textRF.gameObject.SetActive(false);
     }
 }
예제 #3
0
    public static void Show()
    {
#if UNITY_IOS || UNITY_ANDROID || UNITY_WEBGL
        new Message {
            format  = MessageFormat.Input,
            title   = LocalizeUtils.Get("Redeem"),
            content = LocalizeUtils.Get("Code:"),
            inputPlaceholderString = LocalizeUtils.Get("Enter Your Redeem Code"),
            inputConfirmCallback   = OnRedeemCodeConfirm,
            inputValidationData    = new InputFieldValidationData(NUM_CHAR_REDEEM_CODE, InputField.CharacterValidation.Alphanumeric)
        }.Show();
#endif
    }
        private static void OnAutheticationFailed(string error)
        {
            PlayerPrefs.SetInt(PREF_PREVIOUS_LOGINED, 0);
            Debug.LogFormat("PlayGameCenterManager:OnAutheticationFailed({0})", error);
            isLastAuthenticationFailed = true;
#if UNITY_ANDROID
            if (_isForcingAuthentication)
            {
                new Message {
                    title   = LocalizeUtils.Get(TermCategory.Message, GlobalStrings.MSG_LOGIN_FAILED_TITLE),
                    content = LocalizeUtils.Get(TermCategory.Message, "Please install the latest Google Play Games and try again."),
                }.Show();
            }
            _isForcingAuthentication = false;
#endif
        }
예제 #5
0
 public void ToggleCharacter(bool isShown, string text = "", string animNameToPlay = "")
 {
     if (_characterGO != null)
     {
         _characterGO.SetActive(isShown);
         if (isShown)
         {
             _characterText.text = LocalizeUtils.Get(TermCategory.Tutorial, text);
             if (_characterAnim != null)
             {
                 if (_characterAnim.GetClip(animNameToPlay))
                 {
                     TimeManager.Start(AnimationUtils.Play(_characterAnim, animNameToPlay, false));
                 }
                 else
                 {
                     _characterAnim.Play();
                 }
             }
         }
     }
 }
예제 #6
0
 public void SetText(string text)
 {
     _contentText.text = LocalizeUtils.Get(TermCategory.Tutorial, text);
 }
예제 #7
0
    private static void OnRedeemCodeSucceed(Hashtable ht)
    {
        Handheld.StopActivityIndicator();

        ArrayList rewardsAl = ht["rewards"] as ArrayList;

        if (rewardsAl.Count <= 0)           // Find redeem code but no reward? somthing wrong in backend
        {
            new Message {
                title   = LocalizeUtils.Get("Redeem Failed"),
                content = LocalizeUtils.Get("No redeem code found."),
            }.Show();
            return;
        }

        if (ht.ContainsKey("reusable") && (ht["reusable"] as string) == "1")           // If code is reusable, use local PlayerPrefs to check if the code is used before
        {
            List <string> usedCodes = new List <string>(PlayerPrefsX.GetStringArray(PREFS_USED_CODES));
            if (usedCodes.Contains(_enteredCode))
            {
                new Message {
                    title   = LocalizeUtils.Get("Redeem Failed"),
                    content = LocalizeUtils.Get("Redeem code has already redeemed."),
                }.Show();
                return;
            }
            else
            {
                usedCodes.Add(_enteredCode);
                PlayerPrefsX.SetStringArray(PREFS_USED_CODES, usedCodes.ToArray());
            }
        }

        //List<Item> items = new List<Item>();

        foreach (var rewardObj in rewardsAl)
        {
            Hashtable rewardHt = rewardObj as Hashtable;
            DebugUtils.Log(rewardHt);
            ItemType type   = (ItemType)DataUtils.GetInt(rewardHt["type"] as string);
            int      amount = DataUtils.GetInt(rewardHt["amount"] as string);
            int      id     = DataUtils.GetInt(rewardHt["id"] as string);

            // TODO 201011: Backward compatiable NH only: convert money to coin
            if (id == 0)
            {
                id = 1;
            }

            SerializableItem item = new SerializableItem(id, type, amount);

            item.Obtain();
        }

        // Analytics
        var dict = new Dictionary <string, object> {
            { "code", _enteredCode },
        };

        UnityEngine.Analytics.AnalyticsEvent.Custom("redeem_code", dict);

        //new Reward(items).Claim(LocalizeUtils.Get("Redeem Succeed"));
    }