// called from Start() of a SubState public void OnEnterNewSubState(StateInfo in_stateInfo) { // next sub state is now current sub state if (in_stateInfo != null && in_stateInfo.State != null && in_stateInfo.StateId == m_sNextSubStateId) { GDebug.Log("Time Loading SubState -- " + m_sNextSubStateId + " --- " + (Time.realtimeSinceStartup - m_fOriginalRealTimeSinceStartupSubState)); m_bLoadingSubState = false; m_fOriginalRealTimeSinceStartupSubState = Time.realtimeSinceStartup; // current sub state is now the previous if (m_currentSubState != null) { m_sPreviousSubStateId = m_currentSubState.StateId; } else { m_sPreviousSubStateId = UNDEFINED_STATE; } m_currentSubState = in_stateInfo; m_gameSubStates.Insert(0, in_stateInfo); m_sNextSubStateId = UNDEFINED_STATE; if (OnSubStateChange != null) { OnSubStateChange(m_currentSubState); } } }
// called from the Start() of a State public void OnEnterNewState(StateInfo in_stateInfo) { // next state is now current state if (in_stateInfo != null && in_stateInfo.State != null && in_stateInfo.StateId == m_sNextStateId) { GDebug.Log("Time Loading -- " + in_stateInfo.StateId + " " + m_sNextStateId + " --- " + (Time.realtimeSinceStartup - m_fOriginalRealTimeSinceStartup)); m_bLoading = false; m_fOriginalRealTimeSinceStartup = Time.realtimeSinceStartup; // current state is now the previous m_sPreviousStateId = m_currentState != null ? m_currentState.StateId : UNDEFINED_STATE; m_currentState = in_stateInfo; m_sNextStateId = UNDEFINED_STATE; ResumeState(); } if (OnStateChange != null) { OnStateChange(m_currentState); } }
private void OnFindUserByUniversalIdFailure(int statusCode, int reasonCode, string in_stringData, object in_obj) { GDebug.Log(string.Format("OnFindUserByUniversalId Failed | {0} {1} {2}", statusCode, reasonCode, in_stringData)); GStateManager.Instance.EnableLoadingSpinner(false); switch (reasonCode) { case ReasonCodes.DATABASE_ERROR: HudHelper.DisplayMessageDialog("ERROR", "THE SEARCH OPERATION TIMED OUT, PLEASE TRY AGAIN.", "OK"); break; case ReasonCodes.MINIMUM_SEARCH_INPUT: HudHelper.DisplayMessageDialog("ERROR", "INVALID SEARCH CRITERIA. PLEASE ENTER A MINIMUM OF 3 CHARACTERS.", "OK"); break; } }
/// <summary> /// Initialized callback /// </summary> /// <param name="controller"></param> /// <param name="extensions"></param> public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { // Purchasing has succeeded initializing. Collect our Purchasing references. if (m_enableDebug) { GDebug.Log("OnInitialized: PASS"); } // Overall Purchasing system, configured with products for this application. m_StoreController = controller; // Store specific subsystem, for accessing device-specific store features. m_StoreExtensionProvider = extensions; #if (UNITY_IOS || UNITY_ANDROID) && !UNITY_EDITOR updateStoreProductInfo(); #endif CheckAllSubscriptions(); GEventManager.TriggerEvent(GEventManager.ON_IAP_PRODUCTS_UPDATED); }
private void handlePurchase(string storeProductId, SuccessCallback in_success = null, FailureCallback in_failure = null) { #if BUY_CURRENCY_ENABLED // dont process while purchasing if (IsPurchasing) { return; } m_successCallback = in_success; m_failureCallback = in_failure; // If Purchasing has been initialized ... if (IsInitialized()) { #if !STEAMWORKS_ENABLED // ... look up the Product reference with the general product identifier and the Purchasing // system's products collection. Product product = m_StoreController.products.WithID(storeProductId); // If the look up found a product for this device's store and that product is ready to be sold ... if (product != null && product.availableToPurchase) { if (m_enableDebug) { GDebug.Log(string.Format("Purchasing product asychronously: '{0}'", product.definition.id)); } // ... buy the product. Expect a response either through ProcessPurchase or OnPurchaseFailed // asynchronously. GStateManager.Instance.EnableLoadingSpinner(true); IsPurchasing = true; m_StoreController.InitiatePurchase(product); } // Otherwise ... else { // ... report the product look-up failure situation if (m_enableDebug) { GDebug.LogError("BuyProductIDBuyProductID: FAIL. Not purchasing product, either it's not found or it's not available for purchase."); } if (m_failureCallback != null) { m_failureCallback.Invoke(-1, -1, "{'reason':'BuyProductID: FAIL. Not purchasing product, either it's not found or it's not available for purchase.'}", null); } } #else // simulate a successful initiate purchase handleProcessPurchase(storeProductId, ""); #endif } // Otherwise ... else { // ... report the fact Purchasing has not succeeded initializing yet. Consider waiting longer or // retrying initiailization. if (m_enableDebug) { GDebug.LogError("BuyProductID FAIL. Not initialized."); } if (m_failureCallback != null) { m_failureCallback.Invoke(-1, -1, "{'reason':'BuyProductID FAIL. Not initialized.'}", null); } } #endif }
private void handleProcessPurchase(string in_storeId, string in_receipt = null) { GStateManager.Instance.EnableLoadingSpinner(false); IsPurchasing = false; IAPProduct product = GetIAPProductByStoreId(in_storeId); if (product != null) { if (m_enableDebug) { GDebug.Log(string.Format("PurchaseProcessingResult with id: {0}", product.StoreProductId)); } //TODO: ADD MORE PLATFORMS[SMRJ] #if UNITY_IOS Dictionary <string, object> jsonMessage = (Dictionary <string, object>)JsonReader.Deserialize(in_receipt);// args.purchasedProduct.receipt); // itunes Dictionary <string, object> receipt = new Dictionary <string, object>(); receipt["receipt"] = (string)jsonMessage["Payload"]; GCore.Wrapper.Client.AppStoreService.VerifyPurchase("itunes", JsonWriter.Serialize(receipt), m_successCallback, m_failureCallback); #elif UNITY_ANDROID Dictionary <string, object> jsonMessage = (Dictionary <string, object>)JsonReader.Deserialize(in_receipt);// args.purchasedProduct.receipt); // ANDROID Dictionary <string, object> payload = (Dictionary <string, object>)JsonReader.Deserialize((string)jsonMessage["Payload"]); Dictionary <string, object> json = (Dictionary <string, object>)JsonReader.Deserialize((string)payload["json"]); Dictionary <string, object> receipt = new Dictionary <string, object>(); receipt["productId"] = json["productId"]; receipt["orderId"] = json["orderId"]; receipt["token"] = json["purchaseToken"]; //receipt["developerPayload"] = json["developerPayload"]; GCore.Wrapper.Client.AppStoreService.VerifyPurchase("googlePlay", JsonWriter.Serialize(receipt), m_successCallback, m_failureCallback); #elif UNITY_WEBGL // TODO: need to confirm integration Dictionary <string, object> jsonMessage = (Dictionary <string, object>)JsonReader.Deserialize(in_receipt);//args.purchasedProduct.receipt); Dictionary <string, object> receipt = new Dictionary <string, object>(); receipt["signedRequest"] = (string)jsonMessage["Payload"]; GCore.Wrapper.Client.AppStoreService.VerifyPurchase("facebook", JsonWriter.Serialize(receipt), m_successCallback, m_failureCallback); #elif STEAMWORKS_ENABLED // STEAM Dictionary <string, object> purchaseData = new Dictionary <string, object>(); purchaseData[BrainCloudConsts.JSON_LANGUAGE] = "en"; // TODO get proper language purchaseData[BrainCloudConsts.JSON_ITEM_ID] = product.StoreProductId; // steam is a two step process, where you start a purchase, and then finalize it, but we keep these callbacks for later, // after processing the start purhcase succesfully GCore.Wrapper.Client.AppStoreService.StartPurchase("steam", JsonWriter.Serialize(purchaseData), onSteamStartPurchaseSuccess, m_failureCallback); #endif } else { if (m_enableDebug) { GDebug.LogError(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", in_storeId)); } if (m_failureCallback != null) { m_failureCallback.Invoke(-1, -1, "{'reason':'ProcessPurchase: FAIL. Unrecognized product' }", null); } } }
private void OnGetPresenceOfFriendsFailed(int statusCode, int reasonCode, string in_stringData, object in_obj) { GDebug.Log(string.Format("OnGetPresenceOfFriends Failed | {0} {1} {2}", statusCode, reasonCode, in_stringData)); }
//public Firebase.FirebaseApp FireBase { get; private set; } #endif private IEnumerator StartUpMgrs() { if (!m_bInitialized) { Physics.queriesHitTriggers = true; // Start up StateMgr yield return(YieldFactory.GetWaitForEndOfFrame()); GDebug.Log("StartupMgrs --- " + GStateManager.Instance.CurrentStateId); yield return(YieldFactory.GetWaitForEndOfFrame()); GEventManager.Instance.StartUp(); yield return(YieldFactory.GetWaitForEndOfFrame()); GConfigManager.Instance.StartUp(); yield return(YieldFactory.GetWaitForEndOfFrame()); GPlayerMgr.Instance.StartUp(); // Register our Global BC Error handler yield return(YieldFactory.GetWaitForEndOfFrame()); m_wrapper.Client.EnableNetworkErrorMessageCaching(true); m_wrapper.Client.RegisterNetworkErrorCallback(onNetworkError); m_wrapper.Client.RegisterGlobalErrorCallback(HandleBrainCloudFailError); yield return(YieldFactory.GetWaitForEndOfFrame()); GSoundMgr.Instance.StartUp(); yield return(YieldFactory.GetWaitForEndOfFrame()); GLevelManager.Instance.StartUp(); yield return(YieldFactory.GetWaitForEndOfFrame()); GFriendsManager.Instance.StartUp(); #if UNITY_ANDROID /* * Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => { * var dependencyStatus = task.Result; * if (dependencyStatus == Firebase.DependencyStatus.Available) * { * // Create and hold a reference to your FirebaseApp, i.e. * FireBase = Firebase.FirebaseApp.DefaultInstance; * // Set a flag here indicating that Firebase is ready to use by your * // application. * } * else * { * GDebug.LogError(System.String.Format( * "Could not resolve all Firebase dependencies: {0}", dependencyStatus)); * // Firebase Unity SDK is not safe to use here. * } * }); */ #elif STEAMWORKS_ENABLED GSteamAuthManager.Instance.StartUp(); GSteamAuthManager.Instance.SetupSteamManager(); yield return(YieldFactory.GetWaitForSeconds(0.15f)); #endif } yield return(YieldFactory.GetWaitForEndOfFrame()); m_bInitialized = true; }