private void OnGetPresenceOfFriendsSuccess(string in_stringData, object in_obj) { GStateManager.Instance.EnableLoadingSpinner(false); GDebug.Log(string.Format("OnGetPresenceOfFriends Success | {0}", in_stringData)); Friends.Clear(); Dictionary <string, object> jsonMessage = (Dictionary <string, object>)JsonReader.Deserialize(in_stringData); Dictionary <string, object> jsonData = (Dictionary <string, object>)jsonMessage[BrainCloudConsts.JSON_DATA]; if (jsonData.ContainsKey(BrainCloudConsts.JSON_PRESENCE)) { PlayerData pData = null; object[] friends = ((object[])jsonData[BrainCloudConsts.JSON_PRESENCE]); if (friends.Length > 0) { for (int it = 0; it < friends.Length; ++it) { pData = new PlayerData(); pData.ReadPresencePlayerData(friends[it]); Friends.Add(pData); } } } GEventManager.TriggerEvent(ON_FRIENDS_LIST_UPDATED); }
private void OnFindUserByUniversalIdSuccess(string in_jsonString, object in_obj) { GDebug.Log(string.Format("OnFindUserByUniversalIdSuccess Success | {0}", in_jsonString)); GStateManager.Instance.EnableLoadingSpinner(false); Dictionary <string, object> jsonMessage = (Dictionary <string, object>)JsonReader.Deserialize(in_jsonString); Dictionary <string, object> jsonData = (Dictionary <string, object>)jsonMessage[BrainCloudConsts.JSON_DATA]; Dictionary <string, object> jsonResponse = (Dictionary <string, object>)jsonData[BrainCloudConsts.JSON_RESPONSE]; if ((int)jsonResponse["status"] == 400 || (int)jsonResponse["status"] == 500) { OnFindUserByUniversalIdFailure((int)jsonResponse["status"], (int)jsonResponse["reason_code"], (string)jsonResponse["status_message"], null); return; } Dictionary <string, object> reelData = (Dictionary <string, object>)jsonResponse[BrainCloudConsts.JSON_DATA]; if (reelData.ContainsKey(BrainCloudConsts.JSON_MATCHES)) { SearchResults.Clear(); object[] friends = ((object[])reelData[BrainCloudConsts.JSON_MATCHES]); if (friends.Length > 0) { for (int it = 0; it < friends.Length; ++it) { PlayerData pData = new PlayerData(); pData.ReadFriendsPlayerData(friends[it]); if (!IsProfileIdInFriendsList(pData.ProfileId)) { SearchResults.Add(pData); } } } } }
// 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); } }
public void OnInitializeFailed(InitializationFailureReason error) { // Purchasing set-up has not succeeded. Check error for reason. Consider sharing this reason with the user. if (m_enableDebug) { GDebug.LogError("OnInitializeFailed InitializationFailureReason:" + error); } }
// dummy second param public uint PlaySoundIndex(int in_index, bool bReturn) { uint toReturn = 0; if (in_index < m_indexSounds.Length) { toReturn = PlaySound(m_indexSounds[in_index], false); } else { GDebug.LogWarning("Invalid PlaySoundIndex index!"); } return(toReturn); }
private IEnumerator SafeOnAnimationEvent(object in_name) { yield return(YieldFactory.GetWaitForEndOfFrame()); string name = (string)in_name; if (m_arEventListeners != null && m_arEventListeners.ContainsKey(name)) { m_arEventListeners[name](this); } else { GDebug.LogWarning("Animation event key not found : " + name, gameObject); } }
public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason) { GStateManager.Instance.EnableLoadingSpinner(false); IsPurchasing = false; // A product purchase attempt did not succeed. Check failureReason for more detail. Consider sharing // this reason with the user to guide their troubleshooting actions. if (m_enableDebug) { GDebug.LogError(string.Format("OnPurchaseFailed: FAIL. Product: '{0}', PurchaseFailureReason: {1}", product.definition.storeSpecificId, failureReason)); } if (m_failureCallback != null) { m_failureCallback.Invoke(-1, -1, "{'reason':'" + failureReason.ToString() + "' }", product); } }
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); }
public static char ValidateInput(string text, int charIndex, char addedChar) { try { string toString = ""; toString += addedChar; string[] parts = Regex.Split(toString, @"[^a-zA-Z \d]"); //Accepts only A-Z a-z 0-9 and spaces if (parts.Length > 0 && parts[0].Length > 0) { return(parts[0][0]); } else { return('\0'); } } catch (System.Exception ex) { GDebug.LogError(ex.ToString()); return('\0'); } }
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); } } }
public void LoadSoundConfig(string in_jsonConfig) { JsonReader reader = new JsonReader(in_jsonConfig); JsonData root = JsonMapper.ToObject(reader); JsonData jObject; AudioData newData = null; string keyValue = ""; string assetBundleName = ""; string fileName = ""; string[] fileNames = null; for (int i = 0; i < root.Count; ++i) { jObject = root[i]; newData = null; try { keyValue = (string)jObject[SOUND_KEY]; try { fileName = ((string)jObject[FILE_NAME_KEY]).Trim(); } catch (System.Exception) { fileName = ""; } try { assetBundleName = (string)jObject[ASSET_BUNDLE_KEY]; } catch (System.Exception) { assetBundleName = ""; } try { fileNames = ((string)jObject[FILE_NAMES_KEY]).Split(','); for (int index = 0; index < fileNames.Length; ++index) { fileNames[index] = fileNames[index].Trim(); } } catch (System.Exception) { fileNames = null; } newData = new AudioData(keyValue, assetBundleName, fileName, fileNames, (float)(double)jObject[VOLUME_KEY], (bool)jObject[LOOP_KEY] ); // set fade amount try { newData.FadeAmount = (float)(double)jObject[FADE_AMOUNT_KEY]; } catch (System.Exception) { } // set fade out time try { newData.FadeOutTime = (float)(double)jObject[FADE_OUT_TIME_KEY]; } catch (System.Exception) { } // set probability try { newData.Probability = (float)(double)jObject[PROBABILITY_KEY]; } catch (System.Exception) { } // set the audio type try { string tempType = (string)jObject[AUDIO_TYPE_KEY]; if (tempType == "effect") { newData.AudioType = AudioData.eAudioType.effect; } else if (tempType == "music") { newData.AudioType = AudioData.eAudioType.music; } else if (tempType == "voice") { newData.AudioType = AudioData.eAudioType.voice; } } catch (System.Exception) { } } catch (System.Exception) { } if (newData != null) { if (!m_audioLookupData.ContainsKey(keyValue)) { m_audioLookupData[keyValue] = newData; } else { GDebug.LogWarning("Attempted to add new AudioData " + keyValue + ", but it already exists. No action taken. Have you tried unloading a previous config file"); } } } }
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; }