diff options
| author | aldrikboy <aldrikboy@gmail.com> | 2018-01-24 18:19:47 +0100 |
|---|---|---|
| committer | aldrikboy <aldrikboy@gmail.com> | 2018-01-24 18:19:47 +0100 |
| commit | 99c4ae188b672718af274db915b314358c0862af (patch) | |
| tree | 0bbc1434b3d4bc584572b90514275b916a853b50 | |
| parent | 60c98112386f41cfd16e842546b1b23a1194dae0 (diff) | |
ads
| -rw-r--r-- | Penguloon/Activity.cs | 4 | ||||
| -rw-r--r-- | Penguloon/AdManager.cs | 34 | ||||
| -rw-r--r-- | Penguloon/ContentManager.cs | 2 | ||||
| -rw-r--r-- | Penguloon/Controls/ObjectSelector.cs | 1 | ||||
| -rw-r--r-- | Penguloon/Levels/LevelBase.cs | 10 | ||||
| -rw-r--r-- | Penguloon/Properties/AndroidManifest.xml | 4 | ||||
| -rw-r--r-- | Penguloon/Resources/Drawable/Icon.png | bin | 6107 -> 110520 bytes |
7 files changed, 44 insertions, 11 deletions
diff --git a/Penguloon/Activity.cs b/Penguloon/Activity.cs index 356ad91..0b36d33 100644 --- a/Penguloon/Activity.cs +++ b/Penguloon/Activity.cs @@ -1,5 +1,6 @@ using Android.App; using Android.Content.PM; +using Android.Gms.Ads; using Android.OS; using Android.Views; @@ -8,7 +9,7 @@ namespace Penguloon [Activity(Label = "Penguloon" , MainLauncher = true , Icon = "@drawable/icon" - , Theme = "@style/Theme.Splash" + , Theme = "@android:style/Theme.Holo.Light.NoActionBar" , AlwaysRetainTaskState = true , LaunchMode = Android.Content.PM.LaunchMode.SingleInstance , ScreenOrientation = ScreenOrientation.UserLandscape @@ -20,7 +21,6 @@ namespace Penguloon base.OnCreate(bundle); var g = new Main(Resources, this); Window.AddFlags(WindowManagerFlags.Fullscreen); - SetContentView((View)g.Services.GetService(typeof(View))); g.Run(); diff --git a/Penguloon/AdManager.cs b/Penguloon/AdManager.cs index 2537a9d..65f464c 100644 --- a/Penguloon/AdManager.cs +++ b/Penguloon/AdManager.cs @@ -22,22 +22,46 @@ namespace Penguloon public static class AdManager { public static InterstitialAd GameOverAd { get; set; } + public static bool GameOverAdLoaded { get; set; } = false; public static void Load(Main main) { - return; + LoadGameOverAd(main); + } + + private static void LoadGameOverAd(Main main) + { + if (GameOverAdLoaded) return; GameOverAd = new InterstitialAd(main.Context); GameOverAd.AdUnitId = "ca-app-pub-5292616698166001/6013632836"; - GameOverAd.LoadAd(new AdRequest.Builder().Build()); + var adRequest = new AdRequest.Builder().Build(); + GameOverAd.AdListener = new AdListener(main.Activity__); + GameOverAd.LoadAd(adRequest); } public static void ShowGameOverAd() { - return; - - if (GameOverAd.IsLoaded) + if (GameOverAdLoaded) GameOverAd.Show(); + + GameOverAdLoaded = false; + } + + class AdListener : Android.Gms.Ads.AdListener + { + Activity activity; + + public AdListener(Activity activity) + { + this.activity = activity; + } + + public override void OnAdLoaded() + { + base.OnAdLoaded(); + GameOverAdLoaded = true; + } } } }
\ No newline at end of file diff --git a/Penguloon/ContentManager.cs b/Penguloon/ContentManager.cs index 70e5805..50b3566 100644 --- a/Penguloon/ContentManager.cs +++ b/Penguloon/ContentManager.cs @@ -19,7 +19,7 @@ namespace Penguloon public static void LoadContent(Main main) { - AdManager.Load(main); + //AdManager.Load(main); new Thread(() => { diff --git a/Penguloon/Controls/ObjectSelector.cs b/Penguloon/Controls/ObjectSelector.cs index b2ae221..41c3ddb 100644 --- a/Penguloon/Controls/ObjectSelector.cs +++ b/Penguloon/Controls/ObjectSelector.cs @@ -70,7 +70,6 @@ namespace Penguloon.Controls if (fingerRec.Intersects(rec)) { TouchedObjectIndex = i; - return; } } diff --git a/Penguloon/Levels/LevelBase.cs b/Penguloon/Levels/LevelBase.cs index 96a1cb6..c23e72b 100644 --- a/Penguloon/Levels/LevelBase.cs +++ b/Penguloon/Levels/LevelBase.cs @@ -48,13 +48,16 @@ namespace Penguloon.Levels public LevelBase() { - + } public abstract void CreateMap(); public virtual void Initialize(GameScene sceneBase) { + // load ad + AdManager.Load(sceneBase.Main); + MoneyBase = Money; HealthBase = Health; StartDate = DateTime.Now; @@ -90,6 +93,9 @@ namespace Penguloon.Levels public void Restart() { + // load a new ad + AdManager.Load(ParentScene.Main); + NewPR = false; CreateMap(); Map.WaveManager.CurrentWave = 1; @@ -167,6 +173,8 @@ namespace Penguloon.Levels { if (ParentScene.UpgradeMenu.SellConfirmationBox.State == IngameOptionsState.Show) return; + if (ParentScene.OptionsMenu.State == IngameOptionsState.Show) return; + bool found = false; for (int i = 0; i < touchLocations.Length; i++) { diff --git a/Penguloon/Properties/AndroidManifest.xml b/Penguloon/Properties/AndroidManifest.xml index b4de7f4..370e54c 100644 --- a/Penguloon/Properties/AndroidManifest.xml +++ b/Penguloon/Properties/AndroidManifest.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.release.penguloon" android:versionCode="6" android:versionName="1.3.2" android:installLocation="auto"> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.release.penguloon" android:versionCode="8" android:versionName="1.4" android:installLocation="preferExternal"> <uses-sdk android:targetSdkVersion="19" android:minSdkVersion="19" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> + <uses-permission android:name="android.permission.INTERNET" /> <application android:label="Penguloon" android:icon="@drawable/Splash"> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" /> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> diff --git a/Penguloon/Resources/Drawable/Icon.png b/Penguloon/Resources/Drawable/Icon.png Binary files differindex 466f5a7..c7933f4 100644 --- a/Penguloon/Resources/Drawable/Icon.png +++ b/Penguloon/Resources/Drawable/Icon.png |
