IEnumerator __WaitForRefreshSeed(bool isRefresh, Action callback = null) { _refreshKeyLast = _refreshKeyCurrent != null ? _refreshKeyCurrent : _refreshKeyLast; _refreshKeyCurrent = null; txtTimer.text = "--:--"; AnimateItems(false); //While the API keeps returning a refresh-key that is still about to expire, keep calling it: while (_refreshKeyCurrent == null || _refreshKeyCurrent.GetRemainingSeconds() <= 0) { btnRefresh.interactable = false; yield return(new WaitForSeconds(0.5f)); CallAPI(isRefresh); while (!btnRefresh.interactable) { yield return(new WaitForEndOfFrame()); } } RandomizeItemsFromSeed(_refreshKeyCurrent.seed); PopulateItemList(_itemsToBuy, _refreshKeyCurrent.seed); AnimateItems(true); _isBusy = false; if (callback != null) { callback(); } }
void OnShopError(Exception obj) { btnRefresh.interactable = true; if (_refreshKeyCurrent == null) { _refreshKeyCurrent = _refreshKeyLast; } }
void OnShopSeedLoaded(ShopRefreshKey refreshKey, bool reset = false) { trace("SHOP", "current Refresh Key (Seed value): " + refreshKey.seed); trace("SHOP", "Shop Seed DateTime: " + refreshKey.dateExpires.ToUniversalTime() + " : NOW = " + DateTime.Now.ToUniversalTime()); trace("SHOP", refreshKey.GetRemainingSeconds()); trace("SHOP", "PURCHASED: " + JsonUtility.ToJson(refreshKey.purchased)); _refreshKeyCurrent = refreshKey; btnRefresh.interactable = true; }