diff --git a/Assets/BingoBrain/Model/Config/Game/CashModel.cs b/Assets/BingoBrain/Model/Config/Game/CashModel.cs index 13ff32d..9952b2b 100644 --- a/Assets/BingoBrain/Model/Config/Game/CashModel.cs +++ b/Assets/BingoBrain/Model/Config/Game/CashModel.cs @@ -51,7 +51,7 @@ namespace BingoBrain public int Active_Limit_times; public int PayIncrease; public float ADIncrease; - public int Reset_time; + public int Reset_time; } public class CardRedeemNewModel : BingoBrainConfigModel @@ -93,6 +93,10 @@ namespace BingoBrain public int wvType; public int wvthrough; public int isMagic; + public int[] darkWVRefreshtime; + public int darkWVDailyrefreshtimes; + public int WVClickAddTime; + public int WVOffset; } public class exBrPoolModel : BingoBrainConfigModel { diff --git a/Assets/BingoBrain/ModuleUI/SaveData.cs b/Assets/BingoBrain/ModuleUI/SaveData.cs index cf75b11..eff3040 100644 --- a/Assets/BingoBrain/ModuleUI/SaveData.cs +++ b/Assets/BingoBrain/ModuleUI/SaveData.cs @@ -170,7 +170,7 @@ namespace BingoBrain // public int this_time_cardtype; public int look_ad_numbers; // public int look_ad_time; - public int[] dark_Dayref; + public List dark_Dayref; // public int[] _goldtime; // public MaxPayClass max_pay_object; diff --git a/Assets/BingoSun/Scripts/WebviewManager.cs b/Assets/BingoSun/Scripts/WebviewManager.cs index b3611ce..9494a87 100644 --- a/Assets/BingoSun/Scripts/WebviewManager.cs +++ b/Assets/BingoSun/Scripts/WebviewManager.cs @@ -97,7 +97,7 @@ namespace DontConfuse } public void SetDarkThough(bool though) { - if(!GameHelper.IsGiftSwitch()) return; + if (!GameHelper.IsGiftSwitch()) return; // if (though) // { // if (UI.Instance.IsExistUI(UIConst.LevelSuccessUI) || UI.Instance.IsExistUI(UIConst.MakeupConfirmUI) || @@ -207,7 +207,6 @@ namespace DontConfuse var newDays = newDate.Day; - if (times == "Dailyrefreshtimes") { var last_time = PlayerPrefs.GetInt("Dayreftimes", 0); @@ -226,21 +225,49 @@ namespace DontConfuse string darkWVRefreshtime_str = ""; string darkWVDailyrefreshtimes_str = ""; - for (int i = 0; i < ConfigSystem.GetConfig().darkWVRefreshtime.Length; i++) + // for (int i = 0; i < ConfigSystem.GetConfig().darkWVRefreshtime.Length; i++) + // { + // if (i != 0) darkWVRefreshtime_str += "|"; + // darkWVRefreshtime_str += ConfigSystem.GetConfig().darkWVRefreshtime[i].ToString(); + // } + // for (int i = 0; i < ConfigSystem.GetConfig().darkWVRefreshtime2.Length; i++) + // { + // darkWVRefreshtime_str += "|"; + // darkWVRefreshtime_str += ConfigSystem.GetConfig().darkWVRefreshtime2[i].ToString(); + // } + + int dark_type = -1; + for (int i = 0; i < ConfigSystem.dark_weblist.Count; i++) { - if (i != 0) darkWVRefreshtime_str += "|"; - darkWVRefreshtime_str += ConfigSystem.GetConfig().darkWVRefreshtime[i].ToString(); + if (dark_type != ConfigSystem.dark_weblist[i].wvType) + { + if (i != 0) darkWVRefreshtime_str += "|"; + darkWVRefreshtime_str += ConfigSystem.dark_weblist[i].darkWVRefreshtime[0]; + darkWVRefreshtime_str += "|"; + darkWVRefreshtime_str += ConfigSystem.dark_weblist[i].darkWVRefreshtime[1]; + dark_type = ConfigSystem.dark_weblist[i].wvType; + } } - for (int i = 0; i < ConfigSystem.GetConfig().darkWVRefreshtime2.Length; i++) + + + // for (int i = 0; i < ConfigSystem.GetConfig().darkWVDailyrefreshtimes.Length; i++) + // { + // if (i != 0) darkWVDailyrefreshtimes_str += "|"; + // darkWVDailyrefreshtimes_str += ConfigSystem.GetConfig().darkWVDailyrefreshtimes[i].ToString(); + // } + + dark_type = -1; + for (int i = 0; i < ConfigSystem.dark_weblist.Count; i++) { - darkWVRefreshtime_str += "|"; - darkWVRefreshtime_str += ConfigSystem.GetConfig().darkWVRefreshtime2[i].ToString(); - } - for (int i = 0; i < ConfigSystem.GetConfig().darkWVDailyrefreshtimes.Length; i++) - { - if (i != 0) darkWVDailyrefreshtimes_str += "|"; - darkWVDailyrefreshtimes_str += ConfigSystem.GetConfig().darkWVDailyrefreshtimes[i].ToString(); + if (dark_type != ConfigSystem.dark_weblist[i].wvType) + { + if (i != 0) darkWVDailyrefreshtimes_str += "|"; + darkWVDailyrefreshtimes_str += ConfigSystem.dark_weblist[i].darkWVDailyrefreshtimes; + dark_type = ConfigSystem.dark_weblist[i].wvType; + } } + + WebviewManager.Instance.addH5Field(ConfigSystem.GetConfig().flyCtRate, ConfigSystem.GetConfig().otherH5switch, ConfigSystem.GetConfig().H5Refreshtime, ConfigSystem.GetConfig().Dailyrefreshtimes, ConfigSystem.GetConfig().darkThoughProbability, darkWVRefreshtime_str, darkWVDailyrefreshtimes_str, "", "", GameHelper.IsGiftSwitch(), "", ""); @@ -275,20 +302,43 @@ namespace DontConfuse string darkWVRefreshtime_str = ""; string darkWVDailyrefreshtimes_str = ""; - for (int i = 0; i < ConfigSystem.GetConfig().darkWVRefreshtime.Length; i++) + // for (int i = 0; i < ConfigSystem.GetConfig().darkWVRefreshtime.Length; i++) + // { + // if (i != 0) darkWVRefreshtime_str += "|"; + // darkWVRefreshtime_str += ConfigSystem.GetConfig().darkWVRefreshtime[i].ToString(); + // } + // for (int i = 0; i < ConfigSystem.GetConfig().darkWVRefreshtime2.Length; i++) + // { + // darkWVRefreshtime_str += "|"; + // darkWVRefreshtime_str += ConfigSystem.GetConfig().darkWVRefreshtime2[i].ToString(); + // } + int dark_type = -1; + for (int i = 0; i < ConfigSystem.dark_weblist.Count; i++) { - if (i != 0) darkWVRefreshtime_str += "|"; - darkWVRefreshtime_str += ConfigSystem.GetConfig().darkWVRefreshtime[i].ToString(); + if (dark_type != ConfigSystem.dark_weblist[i].wvType) + { + if (i != 0) darkWVRefreshtime_str += "|"; + darkWVRefreshtime_str += ConfigSystem.dark_weblist[i].darkWVRefreshtime[0]; + darkWVRefreshtime_str += "|"; + darkWVRefreshtime_str += ConfigSystem.dark_weblist[i].darkWVRefreshtime[1]; + dark_type = ConfigSystem.dark_weblist[i].wvType; + } } - for (int i = 0; i < ConfigSystem.GetConfig().darkWVRefreshtime2.Length; i++) + // for (int i = 0; i < ConfigSystem.GetConfig().darkWVDailyrefreshtimes.Length; i++) + // { + // if (i != 0) darkWVDailyrefreshtimes_str += "|"; + // darkWVDailyrefreshtimes_str += ConfigSystem.GetConfig().darkWVDailyrefreshtimes[i].ToString(); + // } + + dark_type = -1; + for (int i = 0; i < ConfigSystem.dark_weblist.Count; i++) { - darkWVRefreshtime_str += "|"; - darkWVRefreshtime_str += ConfigSystem.GetConfig().darkWVRefreshtime2[i].ToString(); - } - for (int i = 0; i < ConfigSystem.GetConfig().darkWVDailyrefreshtimes.Length; i++) - { - if (i != 0) darkWVDailyrefreshtimes_str += "|"; - darkWVDailyrefreshtimes_str += ConfigSystem.GetConfig().darkWVDailyrefreshtimes[i].ToString(); + if (dark_type != ConfigSystem.dark_weblist[i].wvType) + { + if (i != 0) darkWVDailyrefreshtimes_str += "|"; + darkWVDailyrefreshtimes_str += ConfigSystem.dark_weblist[i].darkWVDailyrefreshtimes; + dark_type = ConfigSystem.dark_weblist[i].wvType; + } } WebviewManager.Instance.addH5Field(ConfigSystem.GetConfig().flyCtRate, ConfigSystem.GetConfig().otherH5switch, ConfigSystem.GetConfig().H5Refreshtime, ConfigSystem.GetConfig().Dailyrefreshtimes, ConfigSystem.GetConfig().darkThoughProbability, darkWVRefreshtime_str, @@ -588,39 +638,59 @@ namespace DontConfuse if (SaveData.GetSaveobject().dark_Dayref == null) { - SaveData.GetSaveobject().dark_Dayref = new int[2]; + SaveData.GetSaveobject().dark_Dayref = new List() { 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0,0}; } if (dark_last_time == dark_newDays) { // dark_Dailyrefresh_reamain = ConfigSystem.GetConfig().darkWVDailyrefreshtimes[Int32.Parse(webview_index) - 1] - // PlayerPrefs.GetInt("dark_Dayref", 0); - for (int i = 0; i < ConfigSystem.GetConfig().darkWVDailyrefreshtimes.Length; i++) + // for (int i = 0; i < ConfigSystem.GetConfig().darkWVDailyrefreshtimes.Length; i++) + // { + + // if (i != 0) darkWVDailyrefreshtimes_str += "|"; + // darkWVDailyrefreshtimes_str += ConfigSystem.GetConfig().darkWVDailyrefreshtimes[i] - SaveData.GetSaveobject().dark_Dayref[i]; + + // } + int dark_type_ = -1; + for (int i = 0; i < ConfigSystem.dark_weblist.Count; i++) { - - if (i != 0) darkWVDailyrefreshtimes_str += "|"; - darkWVDailyrefreshtimes_str += ConfigSystem.GetConfig().darkWVDailyrefreshtimes[i] - SaveData.GetSaveobject().dark_Dayref[i]; - + if (dark_type_ != ConfigSystem.dark_weblist[i].wvType) + { + dark_type_ = ConfigSystem.dark_weblist[i].wvType; + if (i != 0) darkWVDailyrefreshtimes_str += "|"; + Debug.Log(dark_type_); + darkWVDailyrefreshtimes_str += ConfigSystem.dark_weblist[i].darkWVDailyrefreshtimes - SaveData.GetSaveobject().dark_Dayref[dark_type_ - 1]; + } } } else { // PlayerPrefs.SetInt("dark_Dayref", 0); - for (int i = 0; i < SaveData.GetSaveobject().dark_Dayref.Length; i++) + for (int i = 0; i < SaveData.GetSaveobject().dark_Dayref.Count; i++) { SaveData.GetSaveobject().dark_Dayref[i] = 0; } SaveData.saveDataFunc(); // dark_Dailyrefresh_reamain = ConfigSystem.GetConfig().darkWVDailyrefreshtimes[Int32.Parse(webview_index)]; - for (int i = 0; i < ConfigSystem.GetConfig().darkWVDailyrefreshtimes.Length; i++) + // for (int i = 0; i < ConfigSystem.GetConfig().darkWVDailyrefreshtimes.Length; i++) + // { + + // if (i != 0) darkWVDailyrefreshtimes_str += "|"; + // darkWVDailyrefreshtimes_str += ConfigSystem.GetConfig().darkWVDailyrefreshtimes[i]; + + // } + int dark_type_ = -1; + for (int i = 0; i < ConfigSystem.dark_weblist.Count; i++) { - - if (i != 0) darkWVDailyrefreshtimes_str += "|"; - darkWVDailyrefreshtimes_str += ConfigSystem.GetConfig().darkWVDailyrefreshtimes[i]; - + if (dark_type_ != ConfigSystem.dark_weblist[i].wvType) + { + dark_type_ = ConfigSystem.dark_weblist[i].wvType; + if (i != 0) darkWVDailyrefreshtimes_str += "|"; + darkWVDailyrefreshtimes_str += ConfigSystem.dark_weblist[i].darkWVDailyrefreshtimes; + } } - PlayerPrefs.SetInt("dark_refreshDay", dark_newDays); } @@ -672,29 +742,50 @@ namespace DontConfuse dark_str += "|"; } - dark_str += ConfigSystem.dark_weblist[i].webLink + "#" + ConfigSystem.dark_weblist[i].probability + "#" + can_refresh_numbners + "#" + ConfigSystem.dark_weblist[i].darkWebTimesCT + "#" + ConfigSystem.dark_weblist[i].wvType + "#" + ConfigSystem.dark_weblist[i].darkWebTimesCT2; + dark_str += ConfigSystem.dark_weblist[i].webLink + "#" + ConfigSystem.dark_weblist[i].probability + "#" + can_refresh_numbners + "#" + ConfigSystem.dark_weblist[i].darkWebTimesCT + "#" + ConfigSystem.dark_weblist[i].wvType + "#" + ConfigSystem.dark_weblist[i].WVOffset ; } string darkWVRefreshtime_str = ""; - for (int i = 0; i < ConfigSystem.GetConfig().darkWVRefreshtime.Length; i++) + // for (int i = 0; i < ConfigSystem.GetConfig().darkWVRefreshtime.Length; i++) + // { + // if (i != 0) darkWVRefreshtime_str += "|"; + // darkWVRefreshtime_str += ConfigSystem.GetConfig().darkWVRefreshtime[i].ToString(); + // } + // for (int i = 0; i < ConfigSystem.GetConfig().darkWVRefreshtime2.Length; i++) + // { + // darkWVRefreshtime_str += "|"; + // darkWVRefreshtime_str += ConfigSystem.GetConfig().darkWVRefreshtime2[i].ToString(); + // } + int dark_type = -1; + string add_time = ""; + for (int i = 0; i < ConfigSystem.dark_weblist.Count; i++) { - if (i != 0) darkWVRefreshtime_str += "|"; - darkWVRefreshtime_str += ConfigSystem.GetConfig().darkWVRefreshtime[i].ToString(); + if (dark_type != ConfigSystem.dark_weblist[i].wvType) + { + if (i != 0) + { + darkWVRefreshtime_str += "|"; + add_time += "|"; + } + darkWVRefreshtime_str += ConfigSystem.dark_weblist[i].darkWVRefreshtime[0]; + darkWVRefreshtime_str += "|"; + darkWVRefreshtime_str += ConfigSystem.dark_weblist[i].darkWVRefreshtime[1]; + dark_type = ConfigSystem.dark_weblist[i].wvType; + add_time += ConfigSystem.dark_weblist[i].WVClickAddTime; + } } - for (int i = 0; i < ConfigSystem.GetConfig().darkWVRefreshtime2.Length; i++) - { - darkWVRefreshtime_str += "|"; - darkWVRefreshtime_str += ConfigSystem.GetConfig().darkWVRefreshtime2[i].ToString(); - } - Debug.Log("--------------------------------"); - string add_time = ConfigSystem.GetConfig().WVClickAddTime[0] + "|" + ConfigSystem.GetConfig().WVClickAddTime[1]; + // add_time+= ConfigSystem.GetConfig().WVClickAddTime[0] + "|" + ConfigSystem.GetConfig().WVClickAddTime[1]; Debug.Log(add_time); + Debug.Log(darkWVRefreshtime_str); + Debug.Log(darkWVDailyrefreshtimes_str); + Debug.Log(dark_str); + Debug.Log(ConfigSystem.web_through_str); WebviewManager.Instance.addH5Field(ConfigSystem.GetConfig().flyCtRate, ConfigSystem.GetConfig().otherH5switch, ConfigSystem.GetConfig().H5Refreshtime, Dailyrefresh_reamain, ConfigSystem.GetConfig().darkThoughProbability , darkWVRefreshtime_str, darkWVDailyrefreshtimes_str, dark_str, light_str, GameHelper.IsGiftSwitch(), ConfigSystem.web_through_str, add_time); diff --git a/Assets/Plugins/iOS/H5View.m b/Assets/Plugins/iOS/H5View.m index 5cc5789..a1bf5fa 100644 --- a/Assets/Plugins/iOS/H5View.m +++ b/Assets/Plugins/iOS/H5View.m @@ -13,8 +13,10 @@ #import @implementation H5View{ - WKWebView * webview; - WKWebView * webview_1; + // WKWebView * webview; + // WKWebView * webview_1; + NSMutableArray *webviews; + CircularProgressBar* bar; //奖励按钮进度条 UIView * flyBtn; //飞行奖励按钮节点,也可以用UIButton但要屏蔽事件 UIImageView* flyBg; //飞行奖励闪光背景 @@ -34,7 +36,7 @@ BOOL is_first_btn; //是否是第一次生成网页按钮 int flyCtRate;//飞行按钮穿透概率 float stopTouchTime; - + int otherH5switch; //是否自动刷h5界面 int H5Refreshtime; //h5刷新默认间隔时间 int Dailyrefreshtimes; //每天h5剩余刷新次数 @@ -43,8 +45,10 @@ BOOL dark_though; NSMutableArray * dark_though_rate; - float Dark_stopRefeshTime; - float Dark_stopRefeshTime_1; + // float Dark_stopRefeshTime; + // float Dark_stopRefeshTime_1; + NSMutableArray *Dark_stopRefeshTimes; + NSMutableArray *dark_H5Refreshtime; //h5刷新默认间隔时间 NSMutableArray *dark_Dailyrefreshtimes; //每天h5剩余刷新次数 NSMutableArray *dark_url_array; @@ -60,16 +64,16 @@ BOOL isShowFlyBtn; BOOL isShowRewardBtn; - BOOL isMultiView; + int isMultiView; float top_; float height_; BOOL is_gift; - int offset_y; - int offset_y1; - -// UITapGestureRecognizer *tapGesture; -// UITapGestureRecognizer *tapGesture_1; + // int offset_y; + // int offset_y1; + NSMutableArray *offset_y; + // UITapGestureRecognizer *tapGesture; + // UITapGestureRecognizer *tapGesture_1; BOOL in_game; NSMutableArray *web_through_array; @@ -82,14 +86,16 @@ BOOL webview_1_IsCLickAd; - float web_1_through_time; - float web_2_through_time; + // float web_1_through_time; + // float web_2_through_time; + NSMutableArray *web_through_times; + // int dark_webview1_random_refresh_time; + // int dark_webview2_random_refresh_time; + NSMutableArray *dark_webview_random_refresh_times; - int dark_webview1_random_refresh_time; - int dark_webview2_random_refresh_time; - - float web_1_disable_time; - float web_2_disable_time; + // float web_1_disable_time; + // float web_2_disable_time; + NSMutableArray *web_disable_times; } @@ -98,163 +104,187 @@ +(id) shared{ static H5View *view = nil; static dispatch_once_t onceToken; - + dispatch_once(&onceToken, ^{view = [[self alloc] init];}); - + return view; } //初始化页面 -(void)initView{ if (inited)return; - - + + [self initFlyBtn]; [self setHidden:YES]; //默认为隐藏状态 [self hideView]; canCheckTouch = true; inited = true; - Dark_stopRefeshTime=0; - Dark_stopRefeshTime_1=0; + // Dark_stopRefeshTime=0; + // Dark_stopRefeshTime_1=0; dark_though_rate= [NSMutableArray array]; -// NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.1 -// target:self -// selector:@selector(timerAction:) -// userInfo:nil -// repeats:YES]; + dark_webview_random_refresh_times = [NSMutableArray array]; + web_through_times= [NSMutableArray array]; + web_disable_times= [NSMutableArray array]; + Dark_stopRefeshTimes= [NSMutableArray array]; + webviews= [NSMutableArray array]; + offset_y=[NSMutableArray array]; + // NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.1 + // target:self + // selector:@selector(timerAction:) + // userInfo:nil + // repeats:YES]; NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(timerAction:) userInfo:nil repeats:YES]; - + // 将 timer 添加到 NSRunLoopCommonModes 模式 [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; - + CustomView *custom = [[CustomView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)]; custom.backgroundColor = [UIColor clearColor]; custom.userInteractionEnabled=YES; - - [self.window.rootViewController.view addSubview:custom]; - -// UnityFramework *unityFramework = [UnityFramework getInstance]; -// UnityAppController *appController = [unityFramework appController]; -// -// // 获取 Unity 根节点视图 -// UIView *unityRootView = [appController rootView]; -// unityRootView.alpha=0.2; + [self.window.rootViewController.view addSubview:custom]; + + + UnityFramework *unityFramework = [UnityFramework getInstance]; + UnityAppController *appController = [unityFramework appController]; + + // 获取 Unity 根节点视图 + UIView *unityRootView = [appController rootView]; + unityRootView.alpha=0.2; } -(void)initWebview:(int)type{ - NSLog(@"kkkkkkkkkkkkkkkkkkkkkk%d",type); - if(type==2&&!isMultiView) return; - if (webview != nil) { - // 移除WebView的委托 - if(type==1){ - webview.navigationDelegate = nil; - - // 停止加载和清理缓存 - [webview stopLoading]; - [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]]; - [NSURLCache.sharedURLCache removeAllCachedResponses]; - - // 从视图层次结构中移除WebView - [webview removeFromSuperview]; - webview = nil; - } - - } - if (webview_1 != nil) { - // 移除WebView的委托 - if(type==2){ - webview_1.navigationDelegate = nil; - - // 停止加载和清理缓存 - [webview_1 stopLoading]; - [webview_1 loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]]; - [NSURLCache.sharedURLCache removeAllCachedResponses]; - - // 从视图层次结构中移除WebView - [webview_1 removeFromSuperview]; - webview_1 = nil; - } - +// NSLog(@"kkkkkkkkkkkkkkkkkkkkkk%d",type); + // if(type==2&&!isMultiView) return; + // if (webview != nil) { // 移除WebView的委托 + // if(type==1){ + // webview.navigationDelegate = nil; + // + // // 停止加载和清理缓存 + // [webview stopLoading]; + // [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]]; + // [NSURLCache.sharedURLCache removeAllCachedResponses]; + // + // // 从视图层次结构中移除WebView + // [webview removeFromSuperview]; + // webview = nil; + // } + // + // } + + if( webviews[type]!=nil){ + webviews[type].navigationDelegate = nil; + + // 停止加载和清理缓存 + [webviews[type] stopLoading]; + [webviews[type] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]]; + [NSURLCache.sharedURLCache removeAllCachedResponses]; + + // 从视图层次结构中移除WebView + [webviews[type] removeFromSuperview]; + webviews[type] = [NSNull null]; + //webviews[type] = nil; } + + // [webviews removeObjectAtIndex:type]; + + + // if (webview_1 != nil) { + // // 移除WebView的委托 + // if(type==2){ + // webview_1.navigationDelegate = nil; + // + // // 停止加载和清理缓存 + // [webview_1 stopLoading]; + // [webview_1 loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]]; + // [NSURLCache.sharedURLCache removeAllCachedResponses]; + // + // // 从视图层次结构中移除WebView + // [webview_1 removeFromSuperview]; + // webview_1 = nil; + // } + // + // } WKWebViewConfiguration *webViewConfiguration = [[WKWebViewConfiguration alloc] init]; - + if(is_transparent){ webViewConfiguration.allowsInlineMediaPlayback = YES; webViewConfiguration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAll; - NSString *css = @"body { -webkit-user-select: none;user-select: none; }"; - NSString *jsCSS = [NSString stringWithFormat:@"var style = document.createElement('style'); style.innerHTML = '%@'; document.head.appendChild(style);", css]; -// NSString *js = -// @"(function() { " -// "var elements = document.querySelectorAll('input, textarea, select'); " -// "elements.forEach(function(element) { " -// "element.disabled = true; " -// "}); " -// "})();" -// " document.addEventListener('touchstart', function(event) {" -// " const target = event.target;" -// " if (target.matches('.ad-class') || target.closest('.ad-class')) {" // 替换 '.ad-class' 为广告元素的实际类名 -// " setTimeout(function() {" -// " const touchCancelEvent = new TouchEvent('touchcancel', {" -// " bubbles: true," -// " cancelable: true," -// " touches: []," -// " targetTouches: []," -// " changedTouches: event.changedTouches," -// " shiftKey: event.shiftKey" -// " });" -// " target.dispatchEvent(touchCancelEvent);" -// " }, 1000);" -// " event.preventDefault();" // 禁用默认触摸事件 -// " }" -// "}, { passive: false });"; + NSString *css = @"body { -webkit-user-select: none; user-select: none; }"; + NSString *jsCSS = [NSString stringWithFormat: + @"var style = document.createElement('style'); " + "style.innerHTML = '%@'; " + "document.head.appendChild(style);", css]; + NSString *js = @"(function() { " - // 禁用所有表单元素 - "var elements = document.querySelectorAll('input, textarea, select'); " - "elements.forEach(function(element) { " - " element.disabled = true; " - "}); " + // 禁用所有表单元素 + "var elements = document.querySelectorAll('input, textarea, select'); " + "elements.forEach(function(element) { " + " element.disabled = true; " + " element.setAttribute('readonly', 'true'); " + "}); " - // 禁用所有音频和视频 - "document.querySelectorAll('audio, video').forEach(function(el) { " - " el.muted = true; " - " el.pause(); " - "}); " + // 拦截 focus,强制失焦,防止输入法弹出 + "document.addEventListener('focusin', function(event) { " + " if (event.target.tagName === 'INPUT' || event.target.tagName === 'TEXTAREA' || event.target.tagName === 'SELECT') { " + " event.target.blur(); " + " } " + "}); " + + // 禁用所有音频和视频 + "document.querySelectorAll('audio, video').forEach(function(el) { " + " el.muted = true; " + " el.pause(); " + "}); " + + // 处理触摸事件,阻止广告类元素的触摸 + "document.addEventListener('touchstart', function(event) { " + " const target = event.target; " + " if (target.matches('.ad-class') || target.closest('.ad-class')) { " + " setTimeout(function() { " + " const touchCancelEvent = new TouchEvent('touchcancel', { " + " bubbles: true, " + " cancelable: true, " + " touches: [], " + " targetTouches: [], " + " changedTouches: event.changedTouches, " + " shiftKey: event.shiftKey " + " }); " + " target.dispatchEvent(touchCancelEvent); " + " }, 1000); " + " event.preventDefault(); " + " } " + "}, { passive: false }); " + + // 监控 DOM 变化,禁用新插入的输入框 + "new MutationObserver(function(mutations) { " + " mutations.forEach(function(mutation) { " + " mutation.addedNodes.forEach(function(node) { " + " if (node.tagName === 'INPUT' || node.tagName === 'TEXTAREA' || node.tagName === 'SELECT') { " + " node.disabled = true; " + " node.setAttribute('readonly', 'true'); " + " node.blur(); " + " } " + " }); " + " }); " + "}).observe(document.body, { childList: true, subtree: true }); " - // 处理触摸事件,阻止广告类元素的触摸 - "document.addEventListener('touchstart', function(event) {" - " const target = event.target;" - " if (target.matches('.ad-class') || target.closest('.ad-class')) {" // 替换 '.ad-class' 为广告元素的实际类名 - " setTimeout(function() {" - " const touchCancelEvent = new TouchEvent('touchcancel', {" - " bubbles: true," - " cancelable: true," - " touches: []," - " targetTouches: []," - " changedTouches: event.changedTouches," - " shiftKey: event.shiftKey" - " });" - " target.dispatchEvent(touchCancelEvent);" - " }, 1000);" - " event.preventDefault();" // 禁用默认触摸事件 - " }" - "}, { passive: false });" "})();"; NSString *combinedJS = [NSString stringWithFormat:@"%@ %@", jsCSS, js]; + + + + - - - - - WKUserScript *userScript = [[WKUserScript alloc] initWithSource:combinedJS injectionTime:WKUserScriptInjectionTimeAtDocumentEnd @@ -263,38 +293,51 @@ [webViewConfiguration.userContentController addUserScript:userScript]; } - - - if(type==1) { - webview = [[WKWebView alloc] initWithFrame:self.frame configuration:webViewConfiguration]; - [self addSubview:webview]; - webview.allowsLinkPreview = NO; - [self insertSubview:webview atIndex:0]; - // webview .alpha=0.5; + + + // if(type==1) { + // webview = [[WKWebView alloc] initWithFrame:self.frame configuration:webViewConfiguration]; + // [self addSubview:webview]; + // webview.allowsLinkPreview = NO; + // [self insertSubview:webview atIndex:0]; + // // webview .alpha=0.5; + // } + + webviews[type] = [[WKWebView alloc] initWithFrame:self.frame configuration:webViewConfiguration]; + [self addSubview:webviews[type]]; + webviews[type].allowsLinkPreview = NO; + [self insertSubview:webviews[type] atIndex:0]; + webviews[type] .alpha=0.5; + + // if(type==2){ + // webview_1 = [[WKWebView alloc] initWithFrame:self.frame configuration:webViewConfiguration]; + // [self addSubview:webview_1]; + // webview_1.allowsLinkPreview = NO; + // [self insertSubview:webview_1 atIndex:0]; + // } + + for (NSInteger i = 0; i < webviews.count; i++) { + webviews[i].navigationDelegate=self; + webviews[i].UIDelegate = self; } - if(type==2){ - webview_1 = [[WKWebView alloc] initWithFrame:self.frame configuration:webViewConfiguration]; - [self addSubview:webview_1]; - webview_1.allowsLinkPreview = NO; - [self insertSubview:webview_1 atIndex:0]; - } - webview.navigationDelegate=self; - webview_1.navigationDelegate=self; -// webview.tag = 1; -// webview_1.tag = 2; - webview.UIDelegate=self; - webview_1.UIDelegate=self; + + // webviews[type].navigationDelegate=self; + // webview_1.navigationDelegate=self; + // webview.tag = 1; + // webview_1.tag = 2; + // webviews[type].UIDelegate=self; + // webview_1.UIDelegate=self; // 将WebView添加到当前视图的最后面 - // [self insertSubview:webview atIndex:0]; + // [self insertSubview:webview atIndex:0]; // 将WebView添加到当前视图的最后面 //[self insertSubview:webview_1 atIndex:1]; - - + + // if (webview.superview == nil) // [self ChangeViewRect:!is_transparent]; - // [self showWebview:@"https://baidu.com"]; - + // [self showWebview:@"https://baidu.com"]; + } //- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message { @@ -319,27 +362,27 @@ //当前view的显/隐 -(void)showView:(BOOL)show{ - + if (!show){ [self hideView]; }else{ //[self setHidden:NO]; - - // NSLog(@"xianshimingchuantouuuuuuuuuuuuuu1----%d", inH5ui); + + // NSLog(@"xianshimingchuantouuuuuuuuuuuuuu1----%d", inH5ui); if(!inH5ui) return; - // NSLog(@"xianshimingchuantouuuuuuuuuuuuuu2----%d", show); + // NSLog(@"xianshimingchuantouuuuuuuuuuuuuu2----%d", show); if(is_transparent){ - webview.hidden=YES; + webviews[0].hidden=YES; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@""] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0]; - [webview loadRequest:request]; + [webviews[0] loadRequest:request]; [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(delayShowH5) object:nil]; [self performSelector:@selector(delayShowH5) withObject:nil afterDelay:1.5]; } - - + + [self.superview bringSubviewToFront:self]; - + is_transparent=NO; if (isShowRewardBtn) { [rewardBtn setHidden:NO]; @@ -352,47 +395,65 @@ [self startFlyAnim]; //每一次显示时强行执行飞行按钮的动画 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { self .alpha=1; - } + } } } //隐藏view -(void)hideView{ [self stopUpdate]; - + if(!is_transparent){ - webview.hidden=YES; - webview_1.hidden=YES; + + // webview.hidden=YES; + // webview_1.hidden=YES; + + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@""] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0]; - [webview loadRequest:request]; - [webview_1 loadRequest:request]; + // [webview loadRequest:request]; + // [webview_1 loadRequest:request]; + for (NSInteger i = 0; i < webviews.count; i++) { + webviews[i].hidden = YES; + [ webviews[i] loadRequest:request]; + } [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(delayShowH5) object:nil]; [self performSelector:@selector(delayShowH5) withObject:nil afterDelay:0.5]; } is_transparent=YES; - + [self.superview sendSubviewToBack:self]; - + self.userInteractionEnabled=TRUE; [flyBtn setHidden:YES]; [rewardBtn setHidden:YES]; - Dark_stopRefeshTime=0; - Dark_stopRefeshTime_1=0; - [self showDarkWebview:1]; - [self showDarkWebview:2]; + // Dark_stopRefeshTime=0; + // Dark_stopRefeshTime_1=0; + for (NSInteger i = 0; i < Dark_stopRefeshTimes.count; i++) { + Dark_stopRefeshTimes[i]=@(0); + } + + + for (NSInteger i = 0; i < webviews.count; i++) { + [self showDarkWebview:i]; + } + // [self showDarkWebview:1]; + // [self showDarkWebview:2]; + [self ChangeViewRect:false]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { self .alpha=0; - } - + } } -(void)delayShowH5{ - webview.hidden=NO; - webview_1.hidden=NO; + // webview.hidden=NO; + // webview_1.hidden=NO; + for (NSInteger i = 0; i < webviews.count; i++) { + webviews[i].hidden=NO; + } } -(void)setInH5View:(BOOL)flag{ - // NSLog(@"aaaaaaaaaaaaaaaaaa%d",flag); + // NSLog(@"aaaaaaaaaaaaaaaaaa%d",flag); inH5ui=flag; } @@ -408,7 +469,7 @@ dark_though_rate[[dark_url_array[counter][4] intValue]-1]=@([dark_url_array[counter][3] intValue]); - + break; } } @@ -419,13 +480,13 @@ if( [light_url_array[counter][0] isEqualToString:myNSString]){ light_url_array[counter][2]=@(times); light_though_rate=[light_url_array[counter][3] intValue]; - // NSLog(@"[uuuuuuuuuuuuuuuuu: %s剩余的可刷新次数%u", weblink, times); + // NSLog(@"[uuuuuuuuuuuuuuuuu: %s剩余的可刷新次数%u", weblink, times); break; } } } - - + + } @@ -433,36 +494,63 @@ - (void)timerAction:(NSTimer *)timer { // 定时器触发时执行的操作 - web_1_through_time+=0.1; - web_2_through_time+=0.1; + // web_1_through_time+=0.1; + // web_2_through_time+=0.1; + for (NSUInteger i = 0; i < web_through_times.count; i++) { + web_through_times[i] = @([web_through_times[i] floatValue] + 0.1f); + // NSLog(@"[uuuuuuuuuuuuuuuuu未穿透时间: %f",[web_through_times[i] floatValue]); + } + + stopTouchTime+=0.1; - Dark_stopRefeshTime+=0.1; - Dark_stopRefeshTime_1+=0.1; - - + for (NSInteger i = 0; i < Dark_stopRefeshTimes.count; i++) { + Dark_stopRefeshTimes[i]=@([Dark_stopRefeshTimes[i ] floatValue ] +0.1f); + } + + // Dark_stopRefeshTime+=0.1; + // Dark_stopRefeshTime_1+=0.1; + + if(is_transparent){ + for(NSUInteger i=0;i0&&[Dark_stopRefeshTimes[i] floatValue]>[dark_webview_random_refresh_times[i]intValue]){ + dark_Dailyrefreshtimes[i]=@([dark_Dailyrefreshtimes[i] intValue]-1); + // UnitySendMessage("WebviewManager", "H5AutoRefresh","dark_Dailyrefreshtimes|"+i ); + NSString *msg = [NSString stringWithFormat:@"dark_Dailyrefreshtimes|%d", i]; + UnitySendMessage("WebviewManager", "H5AutoRefresh", [msg UTF8String]); + Dark_stopRefeshTimes[i]=@(0); + dark_webview_random_refresh_times[i]=@([dark_H5Refreshtime[i*2] intValue] + arc4random_uniform([dark_H5Refreshtime[i*2+1] intValue] - [dark_H5Refreshtime[i*2] intValue] + 1)); +// NSLog(@"hhhhhhhhhhhh3333333kkkk%d",[dark_webview_random_refresh_times[0] intValue]); +// - - if([dark_Dailyrefreshtimes[0] intValue]>0&&Dark_stopRefeshTime>dark_webview1_random_refresh_time){ - dark_Dailyrefreshtimes[0]=@([dark_Dailyrefreshtimes[0] intValue]-1); - UnitySendMessage("WebviewManager", "H5AutoRefresh","dark_Dailyrefreshtimes|0" ); - Dark_stopRefeshTime=0; - dark_webview1_random_refresh_time=[dark_H5Refreshtime[0] intValue] + arc4random_uniform([dark_H5Refreshtime[1] intValue] - [dark_H5Refreshtime[0] intValue] + 1); - NSLog(@"hhhhhhhhhhhh3333333kkkk%d",dark_webview1_random_refresh_time); - [self showDarkWebview:1]; - [self ChangeViewRect:false]; + [self showDarkWebview:i]; + [self ChangeViewRect:false]; + } } - if([dark_Dailyrefreshtimes[1] intValue]>0&&Dark_stopRefeshTime_1>dark_webview2_random_refresh_time){ - dark_Dailyrefreshtimes[1]=@([dark_Dailyrefreshtimes[1] intValue]-1); - UnitySendMessage("WebviewManager", "H5AutoRefresh","dark_Dailyrefreshtimes|1" ); - Dark_stopRefeshTime_1=0; - dark_webview2_random_refresh_time=[dark_H5Refreshtime[2] intValue] + arc4random_uniform([dark_H5Refreshtime[3] intValue] - [dark_H5Refreshtime[2] intValue] + 1); - NSLog(@"hhhhhhhhhhhh3333333kkkk%d",dark_webview2_random_refresh_time); - [self showDarkWebview:2]; - [self ChangeViewRect:false]; - } + // if([dark_Dailyrefreshtimes[0]intValue]>0&&Dark_stopRefeshTime>[dark_webview_random_refresh_times [0]intValue]){ + // dark_Dailyrefreshtimes[0]=@([dark_Dailyrefreshtimes[0] intValue]-1); + // UnitySendMessage("WebviewManager", "H5AutoRefresh","dark_Dailyrefreshtimes|0" ); + // Dark_stopRefeshTime=0; + // dark_webview_random_refresh_times[0]=@([dark_H5Refreshtime[0] intValue] + arc4random_uniform([dark_H5Refreshtime[1] intValue] - [dark_H5Refreshtime[0] intValue] + 1)); + // NSLog(@"hhhhhhhhhhhh3333333kkkk%d",[dark_webview_random_refresh_times[0] intValue]); + // + // [self showDarkWebview:0]; + // [self ChangeViewRect:false]; + // } + // + // if([dark_Dailyrefreshtimes[1] intValue]>0&&Dark_stopRefeshTime_1>[dark_webview_random_refresh_times [1]intValue]){ + // dark_Dailyrefreshtimes[1]=@([dark_Dailyrefreshtimes[1] intValue]-1); + // UnitySendMessage("WebviewManager", "H5AutoRefresh","dark_Dailyrefreshtimes|1" ); + // Dark_stopRefeshTime_1=0; + // dark_webview_random_refresh_times[1]=@([dark_H5Refreshtime[2] intValue] + arc4random_uniform([dark_H5Refreshtime[3] intValue] - [dark_H5Refreshtime[2] intValue] + 1)); + // NSLog(@"hhhhhhhhhhhh3333333kkkk%d",[dark_webview_random_refresh_times[1] intValue]); + // [self showDarkWebview:1]; + // [self ChangeViewRect:false]; + // } + + } else{ if(otherH5switch!=1 ) return; @@ -475,7 +563,7 @@ Dailyrefreshtimes--; } } - + } @@ -500,22 +588,22 @@ - (void)yourMethodToCall { if(!is_transparent) { - webview.hidden=NO; + webviews[0].hidden=NO; } - + } //显示webview -(void)showWebview:(NSString*)url{ if (is_transparent) return; //view在隐藏状态下不显示webview,因为目前只需要处理明webview 的显示。 - // NSLog(@"xianshimingchuantouuuuuuuuuuuuuu3----%d"); - [self initWebview:1]; + // NSLog(@"xianshimingchuantouuuuuuuuuuuuuu3----%d"); + [self initWebview:0]; float maxvalue=0; for (int counter = 0; counter < light_url_array.count; counter++) { if([light_url_array[counter][2] intValue]>0 ){ maxvalue+=[light_url_array[counter][1] floatValue]; } - + } float random3 ; float rate=0; @@ -545,17 +633,17 @@ } } } - // NSLog(@"xianshimingchuantouuuuuuuuuuuuuu3----%@",url); + // NSLog(@"xianshimingchuantouuuuuuuuuuuuuu3----%@",url); UnitySendMessage("WebviewManager", "SendH5Event", "test"); stopTouchTime=0; //@"https://tool.lu/timestamp/?ivk_sa=1023231z"@"https://fanyi.baidu.com/ if(url.length!=0) webview_url=url; else return; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] ]; - [webview loadRequest:request]; + [webviews[0] loadRequest:request]; webview_IsCLickAd=YES; - if (webview.superview == nil) - [self insertSubview:webview atIndex:0]; + if (webviews[0].superview == nil) + [self insertSubview:webviews[0] atIndex:0]; UnitySendMessage("WebviewManager", "H5AutoRefresh",[[url stringByAppendingString:@"|h5"] UTF8String]); } @@ -568,116 +656,167 @@ float maxvalue=0; float random3 ; float rate=0; - if(type==1){ - - for (int counter = 0; counter < dark_url_array.count; counter++) { - if([dark_url_array[counter][2] intValue]>0 ){ - if([dark_url_array[counter][4] intValue]!=1 ) continue; - maxvalue+=[dark_url_array[counter][1] floatValue]; - } - + + + + for (int counter = 0; counter < dark_url_array.count; counter++) { + if([dark_url_array[counter][2] intValue]>0 ){ + if([dark_url_array[counter][4] intValue]!=(type+1) ) continue; + maxvalue+=[dark_url_array[counter][1] floatValue]; } - - if(maxvalue>0){ - random3=arc4random_uniform(maxvalue); - for (int counter = 0; counter < dark_url_array.count; counter++) { - if([dark_url_array[counter][2] intValue]<=0) continue; - if([dark_url_array[counter][4] intValue]!=1 ) continue; - float myFloat = [dark_url_array[counter][1] floatValue]; - dark_though_rate[[dark_url_array[counter][4] intValue]-1]=@([dark_url_array[counter][3] intValue]); - rate+=myFloat; - if(random3<=rate){ - url=dark_url_array[counter][0]; - dark_url_array[counter][2]=@([dark_url_array[counter][2] floatValue]-1); - break; - } - } - } - else{ - random3=arc4random_uniform(100); - for (int counter = 0; counter < dark_url_array.count; counter++) { - if([dark_url_array[counter][4] intValue]!=1 ) continue; - float myFloat = [dark_url_array[counter][1] floatValue]; - dark_though_rate[[dark_url_array[counter][4] intValue]-1]=@([dark_url_array[counter][3] intValue]); - rate+=myFloat; - if(random3<=rate){ - url=dark_url_array[counter][0]; - break; - } - } - } - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]]; - if(url.length!=0) webview_url=url; - else return; - // NSLog(@"33333333333333333%@",url); - webview_IsCLickAd=NO; - [webview loadRequest:request]; - - } - else if(type==2){ - if(!isMultiView) return; + + if(maxvalue>0){ + random3=arc4random_uniform(maxvalue); for (int counter = 0; counter < dark_url_array.count; counter++) { - if([dark_url_array[counter][2] intValue]>0 ){ - if([dark_url_array[counter][4] intValue]!=2 ) continue; - maxvalue+=[dark_url_array[counter][1] floatValue]; - } - - } - - rate=0; - if(maxvalue>0){ - random3=arc4random_uniform(maxvalue); - for (int counter = 0; counter < dark_url_array.count; counter++) { - if([dark_url_array[counter][2] intValue]<=0) continue; - if([dark_url_array[counter][4] intValue]!=2 ) continue; - float myFloat = [dark_url_array[counter][1] floatValue]; -// dark_though_rate=[dark_url_array[counter][3] intValue]; - dark_though_rate[[dark_url_array[counter][4] intValue]-1]=@([dark_url_array[counter][3] intValue]); - rate+=myFloat; - if(random3<=rate){ - url=dark_url_array[counter][0]; - dark_url_array[counter][2]=@([dark_url_array[counter][2] floatValue]-1); - break; - } + if([dark_url_array[counter][2] intValue]<=0) continue; + if([dark_url_array[counter][4] intValue]!=(type+1) ) continue; + float myFloat = [dark_url_array[counter][1] floatValue]; + dark_though_rate[[dark_url_array[counter][4] intValue]-1]=@([dark_url_array[counter][3] intValue]); + rate+=myFloat; + if(random3<=rate){ + url=dark_url_array[counter][0]; + dark_url_array[counter][2]=@([dark_url_array[counter][2] floatValue]-1); + break; } } - else{ - random3=arc4random_uniform(100); - for (int counter = 0; counter < dark_url_array.count; counter++) { - if([dark_url_array[counter][4] intValue]!=2 ) continue; - float myFloat = [dark_url_array[counter][1] floatValue]; - dark_though_rate[[dark_url_array[counter][4] intValue]-1]=@([dark_url_array[counter][3] intValue]); - rate+=myFloat; - if(random3<=rate){ - url=dark_url_array[counter][0]; - break; - } - } - } - - - if(url.length!=0) webview_1_url=url; - else return; - NSMutableURLRequest *request_1 = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] ]; - webview_1_IsCLickAd=NO; - [webview_1 loadRequest:request_1]; - // NSLog(@"333333333333333331%@",url); } - + else{ + random3=arc4random_uniform(100); + for (int counter = 0; counter < dark_url_array.count; counter++) { + if([dark_url_array[counter][4] intValue]!=(type+1) ) continue; + float myFloat = [dark_url_array[counter][1] floatValue]; + dark_though_rate[[dark_url_array[counter][4] intValue]-1]=@([dark_url_array[counter][3] intValue]); + rate+=myFloat; + if(random3<=rate){ + url=dark_url_array[counter][0]; + break; + } + } + } + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]]; + if(url.length!=0) webview_url=url; + else return; + // NSLog(@"33333333333333333%@",url); + webview_IsCLickAd=NO; + [webviews[type] loadRequest:request]; + + + + + + // + // if(type==1){ + // + // for (int counter = 0; counter < dark_url_array.count; counter++) { + // if([dark_url_array[counter][2] intValue]>0 ){ + // if([dark_url_array[counter][4] intValue]!=1 ) continue; + // maxvalue+=[dark_url_array[counter][1] floatValue]; + // } + // + // } + // + // if(maxvalue>0){ + // random3=arc4random_uniform(maxvalue); + // for (int counter = 0; counter < dark_url_array.count; counter++) { + // if([dark_url_array[counter][2] intValue]<=0) continue; + // if([dark_url_array[counter][4] intValue]!=1 ) continue; + // float myFloat = [dark_url_array[counter][1] floatValue]; + // dark_though_rate[[dark_url_array[counter][4] intValue]-1]=@([dark_url_array[counter][3] intValue]); + // rate+=myFloat; + // if(random3<=rate){ + // url=dark_url_array[counter][0]; + // dark_url_array[counter][2]=@([dark_url_array[counter][2] floatValue]-1); + // break; + // } + // } + // } + // else{ + // random3=arc4random_uniform(100); + // for (int counter = 0; counter < dark_url_array.count; counter++) { + // if([dark_url_array[counter][4] intValue]!=1 ) continue; + // float myFloat = [dark_url_array[counter][1] floatValue]; + // dark_though_rate[[dark_url_array[counter][4] intValue]-1]=@([dark_url_array[counter][3] intValue]); + // rate+=myFloat; + // if(random3<=rate){ + // url=dark_url_array[counter][0]; + // break; + // } + // } + // } + // NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]]; + // if(url.length!=0) webview_url=url; + // else return; + // // NSLog(@"33333333333333333%@",url); + // webview_IsCLickAd=NO; + // [webview loadRequest:request]; + // + // + // + // } + // else if(type==2){ + // // if(!isMultiView) return; + // for (int counter = 0; counter < dark_url_array.count; counter++) { + // if([dark_url_array[counter][2] intValue]>0 ){ + // if([dark_url_array[counter][4] intValue]!=2 ) continue; + // maxvalue+=[dark_url_array[counter][1] floatValue]; + // } + // + // } + // + // rate=0; + // if(maxvalue>0){ + // random3=arc4random_uniform(maxvalue); + // for (int counter = 0; counter < dark_url_array.count; counter++) { + // if([dark_url_array[counter][2] intValue]<=0) continue; + // if([dark_url_array[counter][4] intValue]!=2 ) continue; + // float myFloat = [dark_url_array[counter][1] floatValue]; + // // dark_though_rate=[dark_url_array[counter][3] intValue]; + // dark_though_rate[[dark_url_array[counter][4] intValue]-1]=@([dark_url_array[counter][3] intValue]); + // rate+=myFloat; + // if(random3<=rate){ + // url=dark_url_array[counter][0]; + // dark_url_array[counter][2]=@([dark_url_array[counter][2] floatValue]-1); + // break; + // } + // } + // } + // else{ + // random3=arc4random_uniform(100); + // for (int counter = 0; counter < dark_url_array.count; counter++) { + // if([dark_url_array[counter][4] intValue]!=2 ) continue; + // float myFloat = [dark_url_array[counter][1] floatValue]; + // dark_though_rate[[dark_url_array[counter][4] intValue]-1]=@([dark_url_array[counter][3] intValue]); + // rate+=myFloat; + // if(random3<=rate){ + // url=dark_url_array[counter][0]; + // break; + // } + // } + // } + // + // + // if(url.length!=0) webview_1_url=url; + // else return; + // NSMutableURLRequest *request_1 = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] ]; + // webview_1_IsCLickAd=NO; + // [webview_1 loadRequest:request_1]; + // // NSLog(@"333333333333333331%@",url); + // } + UnitySendMessage("WebviewManager", "H5AutoRefresh",[[url stringByAppendingString:@"|h6"] UTF8String]); } //隐藏webview -(void)hideWebview{ - [webview removeFromSuperview]; + [webviews[0] removeFromSuperview]; } //设置飞行进度条进度 -(void)setIconProgress:(float)value{ [bar setProgress:value]; - // NSLog(@"bbbbbbbbbbbbbbbbbbbbb%f",value); + // NSLog(@"bbbbbbbbbbbbbbbbbbbbb%f",value); if(value>=1){ UnitySendMessage("WebviewManager", "TouchClickPoint", "finish"); } @@ -706,7 +845,7 @@ points[1] = CGPointMake(-20,sh * 0.25); points[2] = CGPointMake(sw - flyBtn.frame.size.width+20,sh * 0.5); points[3] = CGPointMake(-20,sh - 220); - + } //执行飞行按钮的动画 @@ -722,13 +861,13 @@ flyBtn.transform = CGAffineTransformMakeTranslation(points[0].x, points[0].y); pointIndex = 0; [self flyAnim]; -// float random3 = arc4random_uniform(100) ; -// if(random31) + { + + if(random3< [dark_though_rate[click_web] intValue]){ + // NSLog(@"触发点击:%f",web_1_through_time); + // NSLog(@"eeeeeeeeeeeeeeeeeee:%f",web_1_disable_time); + if ([web_through_times[click_web] floatValue] < 0) { + // NSLog(@"触发点击,时间小于0:%f",web_1_through_time); + return touchedView; } - else return nil; - } - else{ - if(random3< [dark_though_rate[1] intValue]){ - if(web_2_through_time<0){ - return touchedView; - } - if(web_2_through_time1){ + // webview.frame = CGRectMake(0, offset_y, self.frame.size.width, self.frame.size.height); + // webview_1.frame = CGRectMake(0,offset_y1, self.frame.size.width, self.frame.size.height); + // // webview.frame = CGRectMake(0, offset_y, self.frame.size.width-100, self.frame.size.height); + // // webview_1.frame = CGRectMake(100,offset_y1, self.frame.size.width-100, self.frame.size.height); + // } + // else{ + // webview.frame = CGRectMake(0,offset_y, self.frame.size.width, self.frame.size.height); + // webview_1.frame = CGRectMake(0, offset_y1,0, 0); + // } } } @@ -1231,7 +1458,7 @@ } -(void)setViewBtn:(CGRect)rect{ - + if(is_first_btn) return; rewardBtn = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"1"]]; @@ -1251,7 +1478,7 @@ bar.bounds = rewardBtn.bounds; //bar.backgroundColor = UIColor.greenColor; [bar updateUI]; - + [rewardBtn addSubview:bar]; //[self setBackgroundColor:UIColor.orangeColor]; @@ -1261,14 +1488,14 @@ [rewardBtn addSubview:icon]; is_first_btn=true; rewardBtn.hidden=YES; - + } //检测一个点是否在某个按钮里 -(void)checkPointInsideBtn:(CGPoint)point{ //点是否在飞行按钮里 //if(!self.isHidden) stopTouchTime=0; if (!flyBtn.isHidden && CGRectContainsPoint(flyBtn.frame, point)){ - // NSLog(@"Inside flyBtn"); + // NSLog(@"Inside flyBtn"); //避免手指按下立马出发点击事件 [self delayInvoke:0.2 cb:^(void){ NSLog(@"Inside flyBtn"); @@ -1278,7 +1505,7 @@ } if(flyBtn.userInteractionEnabled==true) { - + } else { //穿透了 @@ -1286,7 +1513,7 @@ UnitySendMessage("WebviewManager", "TouchClickPoint", "flyBtn"); } - // self->flyBtn.transform = CGAffineTransformMakeTranslation(-1000, -1000); + // self->flyBtn.transform = CGAffineTransformMakeTranslation(-1000, -1000); }]; isClickFly=YES; } @@ -1297,15 +1524,15 @@ [self delayInvoke:0.2 cb:^(void){ if (self->isShowRewardBtn) { - UnitySendMessage("WebviewManager", "ObjC_TouchClick", "rewardBtn"); + UnitySendMessage("WebviewManager", "ObjC_TouchClick", "rewardBtn"); } [self->bar setProgress:0]; }]; if(rewardBtn.userInteractionEnabled==true) { - + } else { - //穿透了 + //穿透了 UnitySendMessage("WebviewManager", "TouchClickPoint", "rewardBtn"); [bar setProgress:0]; } @@ -1319,7 +1546,7 @@ //设置可穿透字段 -(void)enableCT:(BOOL)flag{ - // NSLog(@"Native enableCT: %d",flag); + // NSLog(@"Native enableCT: %d",flag); canCT = flag; [rewardBtn setUserInteractionEnabled:!flag]; //[flyBtn setUserInteractionEnabled:!flag]; @@ -1327,15 +1554,15 @@ -(void)setClickView{ - + in_game=YES; } //延迟执行逻辑 -(void)delayInvoke:(float)delay cb:(dispatch_block_t)cb{ NSTimeInterval delayInSeconds = delay; - dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); - dispatch_after(popTime, dispatch_get_main_queue(), cb); + dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); + dispatch_after(popTime, dispatch_get_main_queue(), cb); } //飞行按钮隐/藏 @@ -1351,7 +1578,7 @@ -(void)setFlyBtnTag:(BOOL)isShow{ if(!is_gift) isShowFlyBtn = NO; - else isShowFlyBtn = isShow; + else isShowFlyBtn = isShow; } -(void)setRewardBtnTag:(BOOL)isShow{ @@ -1362,8 +1589,8 @@ -(void)SetOffset:(int)offsety offset_y1:(int)offsety1 { // NSLog(@"barry ChangeViewRect-==== %d, %d",offset_y,offset_y1); - offset_y = offsety; - offset_y1 = offsety1; + // offset_y = offsety; + // offset_y1 = offsety1; }