| 
									
										
										
										
											2025-08-31 12:29:24 +00:00
										 |  |  | using System; | 
					
						
							|  |  |  | using System.Collections; | 
					
						
							|  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  | using UnityEngine; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-01 10:32:50 +00:00
										 |  |  | namespace WZ | 
					
						
							| 
									
										
										
										
											2025-08-31 12:29:24 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     public class AdPlayCountManager | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-09-04 09:19:05 +00:00
										 |  |  |         public const string PLAY_COUNT_SUFFIX = "_PLAY_COUNT"; | 
					
						
							|  |  |  |         public const string CLICK_COUNT_SUFFIX = "_CLICK_COUNT"; | 
					
						
							|  |  |  |         public const string CLOSE_COUNT_SUFFIX = "_CLOSE_COUNT"; | 
					
						
							|  |  |  |         public const string STARTLOAD_COUNT_SUFFIX = "_STARTLOAD_COUNT"; | 
					
						
							|  |  |  |         public const string LOADED_COUNT_SUFFIX = "_LOADED_COUNT"; | 
					
						
							|  |  |  |         public const string LOADFAIL_COUNT_SUFFIX = "_LOADFAIL_COUNT"; | 
					
						
							|  |  |  |         public const string SHOWFAIL_COUNT_SUFFIX = "_SHOWFAIL_COUNT"; | 
					
						
							|  |  |  |         public const string ADPOSITION_COUNT_SUFFIX = "_ADPOSITION_COUNT"; | 
					
						
							| 
									
										
										
										
											2025-08-31 12:29:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-01 05:44:32 +00:00
										 |  |  |         #region  关键事件数据 | 
					
						
							| 
									
										
										
										
											2025-08-31 14:18:31 +00:00
										 |  |  |         public static int GetKeyEventPlayCount(string key) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             try | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 return PlayerPrefsUtils.GetPlayerPrefsInt(key, 0); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             catch (Exception ex) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 return 0; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static void SetKeyEventPlayCount(string key, int count) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             try | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 PlayerPrefsUtils.SavePlayerPrefsInt(key, count); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             catch (Exception ex) | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-09-01 05:44:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-31 14:18:31 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static void IncrementKeyEventPlayCount(string key) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             int currentCount = GetKeyEventPlayCount(key); | 
					
						
							|  |  |  |             SetKeyEventPlayCount(key, currentCount + 1); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-09-01 05:44:32 +00:00
										 |  |  |         #endregion | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         #region  关键事件加载次数 | 
					
						
							|  |  |  |         public static int GetKeyEventFPUCount(string key) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             try | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 return PlayerPrefsUtils.GetPlayerPrefsInt(key, 0); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             catch (Exception ex) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 return 0; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static void SetKeyEventFPUCount(string key, int count) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             try | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 PlayerPrefsUtils.SavePlayerPrefsInt(key, count); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             catch (Exception ex) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static void IncrementKeyEventFPUCount(string key) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             int currentCount = GetKeyEventFPUCount(key); | 
					
						
							|  |  |  |             SetKeyEventFPUCount(key, currentCount + 1); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         #endregion | 
					
						
							| 
									
										
										
										
											2025-08-31 14:18:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-01 05:44:32 +00:00
										 |  |  |         #region  关键事件总revenue | 
					
						
							|  |  |  |         public static float GetKeyEventTotalRevenue(string key) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             try | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 return PlayerPrefsUtils.GetPlayerPrefsFloat(key, 0); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             catch (Exception ex) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 return 0; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static void SetKeyEventTotalRevenue(string key, float count) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             try | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 PlayerPrefsUtils.SavePlayerPrefsFloat(key, count); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             catch (Exception ex) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static void IncrementKeyEventTotalRevenue(string key, float revenue) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             float currentCount = GetKeyEventTotalRevenue(key); | 
					
						
							|  |  |  |             SetKeyEventTotalRevenue(key, currentCount + revenue); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static void ResetKeyEventTotalRevenue(string key) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             SetKeyEventTotalRevenue(key, 0); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         #endregion | 
					
						
							| 
									
										
										
										
											2025-08-31 14:18:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-04 09:19:05 +00:00
										 |  |  |         #region  广告播放次数 | 
					
						
							|  |  |  |         public static int GetAdsActionCount(AdsType adsType, string suffix) | 
					
						
							| 
									
										
										
										
											2025-08-31 12:29:24 +00:00
										 |  |  |         { | 
					
						
							|  |  |  |             try | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-09-04 09:19:05 +00:00
										 |  |  |                 string key = GetPlayCountKey(adsType,suffix); | 
					
						
							| 
									
										
										
										
											2025-08-31 12:29:24 +00:00
										 |  |  |                 return PlayerPrefsUtils.GetPlayerPrefsInt(key, 0); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             catch (Exception ex) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 LoggerUtils.Error($"获取广告播放次数失败: {ex.Message}"); | 
					
						
							|  |  |  |                 return 0; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-04 09:19:05 +00:00
										 |  |  |         public static void SetAdsActionCount(AdsType adsType, int count, string suffix) | 
					
						
							| 
									
										
										
										
											2025-08-31 12:29:24 +00:00
										 |  |  |         { | 
					
						
							|  |  |  |             try | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-09-04 09:19:05 +00:00
										 |  |  |                 string key = GetPlayCountKey(adsType,suffix); | 
					
						
							| 
									
										
										
										
											2025-08-31 12:29:24 +00:00
										 |  |  |                 PlayerPrefsUtils.SavePlayerPrefsInt(key, count); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             catch (Exception ex) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 LoggerUtils.Error($"设置广告播放次数失败: {ex.Message}"); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-04 09:19:05 +00:00
										 |  |  |         public static void IncrementAdsActionCount(AdsType adsType,string suffix) | 
					
						
							| 
									
										
										
										
											2025-08-31 12:29:24 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-09-04 09:19:05 +00:00
										 |  |  |             int currentCount = GetAdsActionCount(adsType,suffix); | 
					
						
							|  |  |  |             SetAdsActionCount(adsType, currentCount + 1,suffix); | 
					
						
							| 
									
										
										
										
											2025-08-31 12:29:24 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-09-04 09:19:05 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         private static string GetPlayCountKey(AdsType adsType,string suffix) | 
					
						
							| 
									
										
										
										
											2025-08-31 12:29:24 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-09-04 09:19:05 +00:00
										 |  |  |             return $"{adsType}{suffix}"; | 
					
						
							| 
									
										
										
										
											2025-08-31 12:29:24 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-09-04 09:19:05 +00:00
										 |  |  |         #endregion | 
					
						
							| 
									
										
										
										
											2025-08-31 12:29:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |