public void GetPlayerDataDeserialized <T>(string i_key, Callback <T> requestSuccessCallback) { StartRequest("Request player data " + i_key); GetUserDataRequest request = new GetUserDataRequest() { PlayFabId = PlayFabId, Keys = new List <string>() { i_key } }; PlayFabClientAPI.GetUserReadOnlyData(request, (result) => { RequestComplete("Player data request complete: " + i_key, LogTypes.Info); if ((result.Data == null) || (result.Data.Count == 0)) { MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Error, "No user data for " + i_key, PLAYFAB); } else { // should only call the callback ONCE because there is only one key foreach (var item in result.Data) { requestSuccessCallback(JsonConvert.DeserializeObject <T>(item.Value.Value)); } } }, (error) => { HandleError(error, BackendMessages.PLAYER_DATA_REQUEST_FAIL); }); }
private void SendStartingMessages() { foreach (string message in SendMessagesOnStart) { MyMessenger.Send(message); } }
private void OutputResultLogs(List <LogStatement> i_logs) { foreach (LogStatement log in i_logs) { MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Info, "Log type: " + log.Level + "\n" + log.Message, PLAYFAB); } }
public void IncrementMetric(string i_metric) { AddMetricIfMissing(i_metric); Metrics[i_metric]++; MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Info, "Incremented " + i_metric + " to " + Metrics[i_metric], "GameMetrics"); }
private void SendOutOfSyncAnaltyic(string i_reason) { Dictionary <string, object> eventData = new Dictionary <string, object>(); eventData.Add(LibraryAnalyticEvents.REASON, i_reason); MyMessenger.Send <string, IDictionary <string, object> >(LibraryAnalyticEvents.SEND_ANALYTIC_EVENT, LibraryAnalyticEvents.CLIENT_LOST_SYNC, eventData); }
private void QueueInfoPopup() { ViewModel model = new ViewModel(); model.SetProperty(InfoPopupProperties.MAIN_TEXT, System.Guid.NewGuid().ToString()); MyMessenger.Send <string, ViewModel>(InfoPopupEvents.QUEUE, "StandardInfoPopup", model); }
public static void Init(string i_langauge, IBasicBackend i_backend) { MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Info, "Initing string table for " + i_langauge, ""); string tableKey = "SimpleStringTable_" + i_langauge; i_backend.GetTitleData(tableKey, CreateTableFromJSON); }
public static Sprite GetSpriteFromResource(string i_key) { Sprite spriteFromResource = Resources.Load <Sprite>(i_key); if (spriteFromResource == null) { MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Warn, "Loaded null sprite from resources for key: " + i_key, ""); } return(spriteFromResource); }
/*public void GetAllTitleDataForClass( string i_className, Callback<string> requestSuccessCallback ) { * StartRequest( "Request all data for class " + i_className ); * * Dictionary<string, string> upgradeParams = new Dictionary<string, string>(); * upgradeParams.Add( "Class", i_className ); * * RunCloudScriptRequest request = new RunCloudScriptRequest() { * ActionId = "getAllDataForClass", * Params = new { data = upgradeParams } * }; * * PlayFabClientAPI.RunCloudScript( request, ( result ) => { * RequestComplete( "Cloud logs for all data request for " + i_className + "(" + result.ExecutionTime + "):" + result.ActionLog, LogTypes.Info ); * * if ( result.Results != null ) { * string res = result.Results.ToString(); * res = res.CleanStringForJsonDeserialization(); * * requestSuccessCallback( res ); * } * }, ( error ) => { HandleError( error, BackendMessages.TITLE_DATA_FAIL ); } ); * }*/ protected void HandleError(PlayFabError i_error, string i_messageType) { ClientOutOfSync = true; RequestComplete("Backend failure(" + i_messageType + "): " + i_error.ErrorMessage, LogTypes.Error); IBackendFailure failure = new BackendFailure(i_error.ErrorMessage); MyMessenger.Send <IBackendFailure>(BackendMessages.BACKEND_REQUEST_FAIL, failure); MyMessenger.Send <IBackendFailure>(i_messageType, failure); }
private void LogCloudCallParams(Dictionary <string, string> i_params) { if (i_params != null) { string paramsAsString = "Params: "; foreach (KeyValuePair <string, string> pair in i_params) { paramsAsString += "\n" + pair.Key + " : " + pair.Value; } MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Info, paramsAsString, PLAYFAB); } }
public virtual void CreatePopup(QueuedInfoPopupData i_popupData) { if (PopupPanel != null) { GameObject popupObject = InstantiatePopup(i_popupData); InitPopup(popupObject, i_popupData); } else { MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Error, "InfoPopupManager trying to show a popup, but the parent panel does not exist.", "InfoPopup"); } }
public override void UpdateView() { bool state = GetValue <bool>(); if (Interactable != null) { Interactable.interactable = state == TargetBoolValue;; } else { MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Error, "No interactable element for SetInteractableView: " + PropertyName, "UI"); } }
public override void UpdateView() { object propertyValue = GetValue <object>(); string label = propertyValue.ToString(); if (TextField != null) { TextField.text = label; } else { MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Error, "No text element for LabelView: " + PropertyName, "UI"); } }
public override void UpdateView() { bool propertyValue = GetValue <bool>(); if (Image != null) { bool show = propertyValue == ShowOnTarget; Image.enabled = show; } else { MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Error, "No image element for ShowImageFromBool: " + PropertyName, "UI"); } }
public string Get(string i_strKey) { string strResult = "???"; if (mStringTable.ContainsKey(i_strKey) == false) { MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Warn, "String table had no key for " + i_strKey, ""); } else { strResult = mStringTable[i_strKey]; } return(strResult); }
public void SetUpCloudServices(bool i_testing) { MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Info, "Starting cloud service setup call", PLAYFAB); GetCloudScriptUrlRequest request = new GetCloudScriptUrlRequest() { Testing = i_testing }; PlayFabClientAPI.GetCloudScriptUrl(request, (result) => { mCloudServicesSetUp = true; MyMessenger.Send(BackendMessages.CLOUD_SETUP_SUCCESS); }, (error) => { HandleError(error, BackendMessages.CLOUD_SETUP_FAIL); }); }
protected void SetText(string i_text) { if (TextFieldPro != null) { TextFieldPro.text = i_text; } else if (TextField != null) { TextField.text = i_text; } else { MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Error, "No text element for LabelView: " + PropertyName, "UI"); } }
private static void CreateConstantFromEntry(ConstantsEntry i_entry) { switch (i_entry.Type) { case STRING_KEY: mConstants[i_entry.ID] = i_entry.Value; break; case INT_KEY: mConstants[i_entry.ID] = int.Parse(i_entry.Value); break; case BOOL_KEY: mConstants[i_entry.ID] = bool.Parse(i_entry.Value); break; case FLOAT_KEY: mConstants[i_entry.ID] = float.Parse(i_entry.Value); break; case DOUBLE_KEY: mConstants[i_entry.ID] = double.Parse(i_entry.Value); break; case COLOR_KEY: mConstants[i_entry.ID] = ParseColor(i_entry.Value); break; case VECTOR3_KEY: mConstants[i_entry.ID] = ParseVector3(i_entry.Value); break; case STRINGLIST_KEY: mConstants[i_entry.ID] = ParseStringList(i_entry.Value); break; case INTLIST_KEY: mConstants[i_entry.ID] = ParseList <int>(i_entry.Value); break; default: MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Error, "Illegal constant type " + i_entry.Type + " for key " + i_entry.ID, ""); break; } }
public static Vector3 ParseVector3(string i_str) { Vector3 vector = new Vector3(0, 0, 0); String[] arrayVector3 = i_str.Split(","[0]); if (arrayVector3.Length == 3) { vector = new Vector3( float.Parse(arrayVector3[0]), float.Parse(arrayVector3[1]), float.Parse(arrayVector3[2])); } else { MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Fatal, "Illegal vector3 parsing for " + i_str + " -- reverting to 0,0,0", ""); } return(vector); }
private static Color ParseColor(string i_str) { Color color = Color.white; String[] arrayColor = i_str.Split(","[0]); if (arrayColor.Length == 4) { color = new Color( float.Parse(arrayColor[0]) / 255, // why unity's color picker is 0-255 but the code wants floats, I don't know... float.Parse(arrayColor[1]) / 255, float.Parse(arrayColor[2]) / 255, float.Parse(arrayColor[3]) / 255); } else { MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Fatal, "Illegal color parsing for " + i_str + " -- reverting to white", ""); } return(color); }
public static T GetConstant <T>(string strKey, T defaultVal) { if (mConstants.Count == 0) { MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Fatal, "Constants being accessed before init!", ""); } T data = defaultVal; if (mConstants.ContainsKey(strKey)) { data = (T)mConstants[strKey]; } else { MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Fatal, "No such constant for key " + strKey, ""); } return(data); }
public void Authenticate(string i_id) { MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Info, "Authentication attempt for title " + TITLE_ID, PLAYFAB); PlayFabSettings.TitleId = TITLE_ID; LoginWithCustomIDRequest request = new LoginWithCustomIDRequest() { TitleId = TITLE_ID, CreateAccount = true, CustomId = i_id }; PlayFabClientAPI.LoginWithCustomID(request, (result) => { PlayFabId = result.PlayFabId; IAuthenticationSuccess successResult = null; MyMessenger.Send <IAuthenticationSuccess>(BackendMessages.AUTH_SUCCESS, successResult); }, (error) => { HandleError(error, BackendMessages.AUTH_FAIL); }); }
public void GetVirtualCurrency(string i_key, Callback <int> requestSuccessCallback) { StartRequest("Requesting virtual currency: " + i_key); GetPlayerCombinedInfoRequest request = new GetPlayerCombinedInfoRequest(); PlayFabClientAPI.GetPlayerCombinedInfo(request, (result) => { RequestComplete("Request for virtual currency complete: " + i_key, LogTypes.Info); int currency = 0; if (result.InfoResultPayload.UserVirtualCurrency.ContainsKey(i_key)) { currency = result.InfoResultPayload.UserVirtualCurrency[i_key]; } else { MyMessenger.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Error, "No virtual currency for: " + i_key, PLAYFAB); } requestSuccessCallback(currency); }, (error) => { HandleError(error, BackendMessages.CURRENCY_REQUEST_FAIL); }); }
public void Dispose() { MyMessenger.RemoveListener <string, IDictionary <string, object> >(LibraryAnalyticEvents.SEND_ANALYTIC_EVENT, OnAnalyticEvent); }
public UnityAnalyticsManager(IUnityAnalytics i_unityAnalytics) { mAnalytics = i_unityAnalytics; MyMessenger.AddListener <string, IDictionary <string, object> >(LibraryAnalyticEvents.SEND_ANALYTIC_EVENT, OnAnalyticEvent); }
private void UnsubscribeFromMessages() { MyMessenger.RemoveListener(EndStepOnMessage, EndStep); }
private void EndStep() { MyMessenger.Send(Tutorial.END_STEP_MESSAGE); }
private void UnsubscribeFromMessages() { MyMessenger.RemoveListener(END_STEP_MESSAGE, OnEndStep); }
private void SubscribeToMessages() { MyMessenger.AddListener(END_STEP_MESSAGE, OnEndStep); }
private void FinishTutorial() { MyMessenger.Send(TUTORIAL_FINISHED, TutorialName); Destroy(gameObject); }