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); });
        }
Exemple #2
0
 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);
     }
 }
Exemple #4
0
        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");
        }
Exemple #5
0
        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);
        }
Exemple #7
0
        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);
        }
Exemple #10
0
 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);
     }
 }
Exemple #11
0
 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");
            }
        }
Exemple #13
0
        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");
            }
        }
Exemple #14
0
        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");
            }
        }
Exemple #15
0
        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); });
        }
Exemple #17
0
 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");
     }
 }
Exemple #18
0
        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;
            }
        }
Exemple #19
0
        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);
        }
Exemple #20
0
        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);
        }
Exemple #21
0
        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);
        }
Exemple #22
0
        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); });
        }
Exemple #23
0
        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);
 }
Exemple #26
0
 private void UnsubscribeFromMessages()
 {
     MyMessenger.RemoveListener(EndStepOnMessage, EndStep);
 }
Exemple #27
0
 private void EndStep()
 {
     MyMessenger.Send(Tutorial.END_STEP_MESSAGE);
 }
Exemple #28
0
 private void UnsubscribeFromMessages()
 {
     MyMessenger.RemoveListener(END_STEP_MESSAGE, OnEndStep);
 }
Exemple #29
0
 private void SubscribeToMessages()
 {
     MyMessenger.AddListener(END_STEP_MESSAGE, OnEndStep);
 }
Exemple #30
0
 private void FinishTutorial()
 {
     MyMessenger.Send(TUTORIAL_FINISHED, TutorialName);
     Destroy(gameObject);
 }