public void Load() { //Load from Web API User user = new User(); PromoCodeWebService service = new PromoCodeWebService(); StartCoroutine(service.DoesUserExist(user.userName, DecideAddUser)); }
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"); } }
private void DecideAddUser(bool userExists) { PromoCodeWebService service = new PromoCodeWebService(); User user = new User(); if (!userExists) { StartCoroutine(service.AddUser(user, GetPromoCodesForUser)); } else { GetPromoCodesForUser(user); } }
private void GetPromoCodesForUser(User user) { PromoCodeWebService service = new PromoCodeWebService(); StartCoroutine(service.GetPromoCodesForUser(user.userName, SetupDictionary)); }