示例#1
0
        public static bool ExceededMaxTimesToShow(ServerResponseData response)
        {
            var timesMessageWasShownKey = GetTimesMessageWasShownKey(response.MessageName);

            EditorPrefsHelper.InitIfUndefined(timesMessageWasShownKey, 0);

            int timesMessageWasShown = GetTimesMessageWasShown(response.MessageName);

            return(timesMessageWasShown >= response.TimesToShow);
        }
示例#2
0
        public static bool HasEnoughTimePassed(ServerResponseData response)
        {
            string messageDateKey = GetMessageDateKey(response.MessageName);

            string currentDate = System.DateTime.Now.Ticks.ToString();

            bool newKey = !EditorPrefs.HasKey(messageDateKey);

            EditorPrefsHelper.InitIfUndefined(messageDateKey, currentDate);

            long   lastTimeMessageShownTicks     = long.Parse(EditorPrefs.GetString(messageDateKey));
            double minutesPassedSinceLastMessage = System.TimeSpan.FromTicks(System.DateTime.Now.Ticks - lastTimeMessageShownTicks).TotalMinutes;

            var timesMessageWasShown = GetTimesMessageWasShown(response.MessageName);

            var interval = response.IntervalInMinutes * (Mathf.Exp(timesMessageWasShown) - 1);

                        #if DEBUG_INFO_MESSAGE
            Debug.Log("timesMessageWasShown: " + timesMessageWasShown + "; interval: " +
                      minutesPassedSinceLastMessage + "/" + interval);
                        #endif

            return(newKey || minutesPassedSinceLastMessage >= interval);
        }
示例#3
0
 public static void IncreaseTimesShown(string messageName)
 {
     EditorPrefsHelper.IncreaseValue(GetTimesMessageWasShownKey(messageName), 1);
 }