Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        ProfilLastResultListController.profileSceneOpened = true;
        Texture2D       txtAvatar = new Texture2D(1, 1);
        Sprite          newSpriteAvatar;
        Texture2D       txtDrapeau = new Texture2D(1, 1);
        Sprite          newSpriteDrapeau;
        WithdrawManager wm = new WithdrawManager();

        UnityThreading.ActionThread thread;
        Loading.SetActive(true);
        string token         = um.getCurrentSessionToken();
        string userId        = um.getCurrentUserId();
        string accountStatus = "";

        thread = UnityThreadHelper.CreateThread(() => {
            if (PlayerId == userId)
            {
                accountStatus = wm.accountVerificationStatus(token);
            }
            User player      = um.getUser(PlayerId, token);
            string Vectoires = player.victories_count.ToString();
            //Debug.Log("Vectoires " +Vectoires);
            string SerieVectoires = player.victories_streak.ToString();
            //Debug.Log("SerieVectoires " + SerieVectoires);
            UnityThreadHelper.Dispatcher.Dispatch(() => {
                Loading.SetActive(false);
                if (PlayerId != userId)
                {
                    changeAvatar.interactable = false;
                    avatar.sprite             = Avatar;
                }
                else
                {
                    avatar.sprite = UserManager.CurrentAvatarBytesString;
                    if (accountStatus == WithdrawManager.ACCOUNT_VERIFICATION_STATUS_PENDING)
                    {
                        pending.SetActive(true);
                    }
                    else if (accountStatus == WithdrawManager.ACCOUNT_VERIFICATION_STATUS_VERIFIED)
                    {
                        verified.SetActive(true);
                    }
                    else
                    {
                        unverified.SetActive(true);
                    }
                }
                //Set User Name
                username.text = player.username;
                //Set User pro label
                try{
                    if (player.money_credit > 0)
                    {
                        pro.gameObject.SetActive(true);
                    }
                    else
                    {
                        pro.gameObject.SetActive(false);
                    }
                }catch (FormatException ex) {
                    if (player.money_credit > 0)
                    {
                        pro.gameObject.SetActive(true);
                    }
                    else
                    {
                        pro.gameObject.SetActive(false);
                    }
                }
                //set User Drapeau
                Byte[] img1 = Convert.FromBase64String(um.GetFlagByte(player.country_code));
                txtDrapeau.LoadImage(img1);
                newSpriteDrapeau = Sprite.Create(txtDrapeau as Texture2D, new Rect(0f, 0f, txtDrapeau.width, txtDrapeau.height), Vector2.zero);
                drapeau.sprite   = newSpriteDrapeau;
                //set Games Won
                nbGameWon.text = Vectoires;
                //set nb Game Won In a Row
                nbGameWonInARow.text = SerieVectoires;
            });
        });
    }
    // Use this for initialization
    void Start()
    {
        balance = GameObject.Find("balance").GetComponent <Text> ();
        //balance.text = UserManager.CurrentMoney+CurrencyManager.CURRENT_CURRENCY;
        UnityThreading.ActionThread thread;
        string userId        = um.getCurrentUserId();
        string token         = um.getCurrentSessionToken();
        User   user          = null;
        string accountStatus = null;

        UnityThreadHelper.CreateThread(() => {
            //bonus = float.Parse (N ["argentBonus"].Value);
            user          = um.getUser(userId, token);
            accountStatus = withdrawManager.accountVerificationStatus(token);
            UnityThreadHelper.Dispatcher.Dispatch(() => {
                balance.text = user.money_credit.ToString("N2") + CurrencyManager.CURRENT_CURRENCY;
            });
        });
        WithdrawButton.onClick.AddListener(() => {
            Debug.Log("WithdrawButton.onClick");
            if (CountryController.checkCountry(UserManager.CurrentCountryCode) == true)
            {
                WithdrawMoney = float.Parse(EnterWithdrawal.text, CultureInfo.InvariantCulture);
                //if (/*!InformationAlreadyExist(user) || user.iban_uploaded == false ||*/ (user.id_proof_1_uploaded == false && user.passport_uploaded == false)) {
                if (accountStatus != WithdrawManager.ACCOUNT_VERIFICATION_STATUS_VERIFIED)
                {
                    EventsController nbs = new EventsController();
                    nbs.ShowPopupError("popupMissingInfo");
                }
                else
                {
                    try {
                        GameObject.Find("WithdrawalInfo").GetComponent <GameObject>();
                    } catch (NullReferenceException ex) {
                        Debug.Log("OpenUP");
                        SceneManager.LoadScene("WithdrawalInfo", LoadSceneMode.Additive);
                    }
                }
            }
            else
            {
                EventsController nbs = new EventsController();
                nbs.ShowPopupError("popupProhibitedLocationWithdraw");
            }
        });
        EnterWithdrawal.onValueChanged.AddListener(delegate {
            if (string.IsNullOrEmpty(EnterWithdrawal.text))
            {
                WithdrawButton.interactable = false;
                TextEuro.text = "";
            }
            else
            {
                TextEuro.text = CurrencyManager.CURRENT_CURRENCY;
                if ((float.Parse(EnterWithdrawal.text, CultureInfo.InvariantCulture) > 0) && (float.Parse(EnterWithdrawal.text, CultureInfo.InvariantCulture) <= (float.Parse(UserManager.CurrentMoney))))
                {
                    WithdrawButton.interactable = true;
                }
                else
                {
                    WithdrawButton.interactable = false;
                }
            }
        });
    }