public void ShowCurrAd(string internal_id) { // Get Stuff about the ad by the internal_id AdIds ad_ids = GetAdIds(internal_id); // Auto-call balancer events on banner and interstitials if (internal_id.Contains("rd")) { CallBalancerEvent("rd shown"); } else if (internal_id.Contains("br")) { CallBalancerEvent("br shown"); } else if (internal_id.Contains("il")) { CallBalancerEvent("il shown"); } // If it is a resurrection ad // Debug.Log("Showing: " + " internal_id: " + internal_id + " rd_resurrect_name: " + rd_resurrect_name); if (internal_id.Contains(rd_resurrect_name)) { rd_resurrect_shown_count.v++; } // "br" is the abbreviation that is used for all banner ads if (internal_id.Contains("br")) { #if UNITY_IOS Advertisement.Banner.Show(value.ios_id); #elif UNITY_ANDROID || UNITY_EDITOR Advertisement.Banner.Show(ad_ids.android_id); #endif } else { #if UNITY_IOS Advertisement.Show(value.ios_id); #elif UNITY_ANDROID || UNITY_EDITOR // Debug.Log("Android ad will be shown"); Advertisement.Show(ad_ids.android_id); #endif } }
public bool CheckOpportunity(string internal_id) { // Get Stuff about the ad by the internal_id AdIds ad_ids = GetAdIds(internal_id); PlacementGroup placement_group = GetPlacementGroup(internal_id); // If No Ads is bought and placement_group is excluded by this purchase if (no_ads.v && no_ads_excluded.Contains(placement_group.id)) { return(false); } // If resurrection ad was already shown this level // Debug.Log("Check Opp: " + " internal_id: " + internal_id + " rd_resurrect_shown_count: " + rd_resurrect_shown_count.v + " rd_resurrect_name: " + rd_resurrect_name); if (internal_id.Contains(rd_resurrect_name) && rd_resurrect_shown_count.v >= 1) { return(false); } if (placement_group.balancer_type == balancer_type_enum.time_balancer) { // Get current time float curr_time = Time.time; TimeBalancer time_balancer = GetCurrTimeBalancer(placement_group, Time.time); float minutes_since_last_opportunity = (curr_time - placement_group.last_opportunity_timestamp.v) / 60; float ad_per_minutes = ((float)time_balancer.ads / (float)time_balancer.minutes); placement_group.balance.v += minutes_since_last_opportunity * ad_per_minutes; placement_group.last_opportunity_timestamp.v = curr_time; } else if (placement_group.balancer_type == balancer_type_enum.opportunity_balancer) { // This counts as an opportunity placement_group.opportunities.v++; OpportunityBalancer opportunity_balancer = GetCurrOpportunityBalancer(placement_group, placement_group.opportunities.v); float ad_per_opportunity = ((float)opportunity_balancer.ads / (float)opportunity_balancer.opportunities); // 1 symbolizes one opportunity that is provided with this method placement_group.balance.v += 1 * ad_per_opportunity; } else if (placement_group.balancer_type == balancer_type_enum.always_yes) { // Just set it to 1 placement_group.balance.v = 1.0f; } else if (placement_group.balancer_type == balancer_type_enum.always_no) { // Just set it to 0 placement_group.balance.v = 0.0f; } if (placement_group.balance.v < placement_group.balance_min) { placement_group.balance.v = placement_group.balance_min; } if (placement_group.balance.v > placement_group.balance_max) { placement_group.balance.v = placement_group.balance_max; } // Debug.Log("id: " + internal_id + " group: " + placement_group.id + " bal: " + placement_group.balance.v); if (placement_group.balance.v < 1) { return(false); } #if UNITY_IOS string platform_ad_id = ad_ids.ios_id; #elif UNITY_ANDROID || UNITY_EDITOR string platform_ad_id = ad_ids.android_id; #endif if (!Advertisement.IsReady(platform_ad_id)) { return(false); } return(true); }