Esempio n. 1
0
    public void Load()
    {
        //Load from Web API
        User user = new User();
        PromoCodeWebService service = new PromoCodeWebService();

        StartCoroutine(service.DoesUserExist(user.userName, DecideAddUser));
    }
Esempio n. 2
0
    public void UsePromoCode(string code)
    {
        code = code.ToUpper();
        PromoCode promoCode;
        User      user = new User();

        promoCodeDictionary.TryGetValue(code, out promoCode);

        if (promoCode != null)
        {
            if (!promoCode.hasBeenUsed)
            {
                bool promoCodeHasBeenUsed = false;

                if (promoCode.currencyType == "Coin")
                {
                    PromoCodeWebService service = new PromoCodeWebService();
                    StartCoroutine
                    (
                        service.UserUsePromoCode(user.userName, code, () =>
                    {
                        promoCodeHasBeenUsed = true;
                        GameController.gameController.coins += promoCode.currencyGiven;
                        GameController.gameController.Save();
                        Load();

                        if (promoCodeHasBeenUsed)
                        {
                            DialogSpawner.dialogSpawner.SpawnErrorDialog("The " + promoCode.description + " promo code has been used!");
                        }
                    })
                    );
                }
                else if (promoCode.currencyType == "Star") // Add as many of these as you want
                {
                    //No star yet, but who knows?!
                }
                else
                {
                    //Maybe throw an error here later?
                }
            }
            else
            {
                DialogSpawner.dialogSpawner.SpawnErrorDialog("That promo code has already been used.");
            }
        }
        else
        {
            DialogSpawner.dialogSpawner.SpawnErrorDialog("That is not a valid promo code");
        }
    }
Esempio n. 3
0
    private void DecideAddUser(bool userExists)
    {
        PromoCodeWebService service = new PromoCodeWebService();
        User user = new User();

        if (!userExists)
        {
            StartCoroutine(service.AddUser(user, GetPromoCodesForUser));
        }
        else
        {
            GetPromoCodesForUser(user);
        }
    }
Esempio n. 4
0
    private void GetPromoCodesForUser(User user)
    {
        PromoCodeWebService service = new PromoCodeWebService();

        StartCoroutine(service.GetPromoCodesForUser(user.userName, SetupDictionary));
    }