From fae272bc77b1c523a8af7a52bb220b684a2a6c1b Mon Sep 17 00:00:00 2001 From: aldrikboy Date: Fri, 26 Jan 2018 14:22:18 +0100 Subject: map pack --- Penguloon/BillingManager.cs | 94 +++++++++++++++++++++ Penguloon/Content/Content.mgcb | 12 +++ Penguloon/Content/UI/star.png | Bin 0 -> 3939 bytes Penguloon/ContentManager.cs | 15 +++- Penguloon/ContentPathManager.cs | 1 + Penguloon/Controls/LevelSelector.cs | 80 +++++++++++++++++- Penguloon/Enums.cs | 3 +- Penguloon/Levels/SandLevel2.cs | 2 +- Penguloon/Levels/SandLevel3.cs | 2 +- Penguloon/Levels/SpaceLevel1.cs | 2 +- Penguloon/Levels/SpaceLevel2.cs | 2 +- Penguloon/MainApplication.cs | 39 +++++++++ Penguloon/Penguloon.csproj | 16 ++-- Penguloon/Properties/AndroidManifest.xml | 2 +- Penguloon/Resources/Resource.Designer.cs | 141 ++++++++++++++++--------------- Penguloon/Resources/Values/Strings.xml | 1 + Penguloon/SceneManager.cs | 6 ++ Penguloon/Scenes/MenuScene.cs | 17 +++- Penguloon/Scenes/ShopScene.cs | 86 +++++++++++++++++++ Penguloon/packages.config | 2 +- 20 files changed, 432 insertions(+), 91 deletions(-) create mode 100644 Penguloon/BillingManager.cs create mode 100644 Penguloon/Content/UI/star.png create mode 100644 Penguloon/Scenes/ShopScene.cs diff --git a/Penguloon/BillingManager.cs b/Penguloon/BillingManager.cs new file mode 100644 index 0000000..2611414 --- /dev/null +++ b/Penguloon/BillingManager.cs @@ -0,0 +1,94 @@ +using Plugin.InAppBilling; +using Plugin.InAppBilling.Abstractions; +using System; +using Penguloon.Controls; + +namespace Penguloon.Scenes +{ + public static class BillingManager + { + public static bool MapPackPurchased { get; set; } = false; + + public static async System.Threading.Tasks.Task PurchaseMapPackAsync(SceneBase sceneBase) + { + try + { + var productId = "map_pack"; + + //CrossInAppBilling.Current.InTestingMode = true; + + + var connected = await CrossInAppBilling.Current.ConnectAsync(); + + if (!connected) + { + Alert.Show("Not connected", 3000, sceneBase); + return; + } + + //try to purchase item + var purchase = await CrossInAppBilling.Current.PurchaseAsync(productId, ItemType.InAppPurchase, "apppayload"); + if (purchase == null) + { + Alert.Show("Purchase failed", 3000, sceneBase); + } + else + { + Alert.Show("Maps unlocked", 4000, sceneBase); + //Purchased, save this information + var id = purchase.Id; + var token = purchase.PurchaseToken; + var state = purchase.State; + + MapPackPurchased = true; + } + } + catch (Exception ex) + { + //Something bad has occurred, alert user + Alert.Show("An error occured", 3000, sceneBase); + } + + //Disconnect, it is okay if we never connected + await CrossInAppBilling.Current.DisconnectAsync(); + } + + public static async System.Threading.Tasks.Task CheckPurchasesAsync() + { + try + { + var connected = await CrossInAppBilling.Current.ConnectAsync(); + + if (!connected) + { + return; + } + + //try to purchase item + var purchase = await CrossInAppBilling.Current.GetPurchasesAsync(ItemType.InAppPurchase); + if (purchase == null) + { + return; + } + else + { + foreach(InAppBillingPurchase item in purchase) + { + if (item.ProductId == "map_pack") + MapPackPurchased = true; + + //if (item.ProductId == "android.test.purchased") + // MapPackPurchased = true; + } + } + } + catch (Exception ex) + { + //Something bad has occurred + } + + //Disconnect, it is okay if we never connected + await CrossInAppBilling.Current.DisconnectAsync(); + } + } +} \ No newline at end of file diff --git a/Penguloon/Content/Content.mgcb b/Penguloon/Content/Content.mgcb index 09b34a0..6b02fb4 100644 --- a/Penguloon/Content/Content.mgcb +++ b/Penguloon/Content/Content.mgcb @@ -1171,3 +1171,15 @@ /processorParam:TextureFormat=Color /build:SplashArt/7.png +#begin UI/star.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:UI/star.png + diff --git a/Penguloon/Content/UI/star.png b/Penguloon/Content/UI/star.png new file mode 100644 index 0000000..5e687f8 Binary files /dev/null and b/Penguloon/Content/UI/star.png differ diff --git a/Penguloon/ContentManager.cs b/Penguloon/ContentManager.cs index 50b3566..e4a2b61 100644 --- a/Penguloon/ContentManager.cs +++ b/Penguloon/ContentManager.cs @@ -2,6 +2,8 @@ using Microsoft.Xna.Framework.Graphics; using System.Threading; using Microsoft.Xna.Framework.Audio; +using System; +using Penguloon.Scenes; namespace Penguloon { @@ -21,7 +23,7 @@ namespace Penguloon { //AdManager.Load(main); - new Thread(() => + new Thread(async () => { Thread.CurrentThread.IsBackground = true; @@ -29,9 +31,18 @@ namespace Penguloon LoadContent_(main); + await LoadPlaystorePurchasesAsync(); + + DoneLoading = true; + }).Start(); } + private static async System.Threading.Tasks.Task LoadPlaystorePurchasesAsync() + { + await BillingManager.CheckPurchasesAsync(); + } + private static void LoadContent_(Main main) { float totalItemsToLoad = ContentPathManager.TexturePaths.Count + ContentPathManager.FontPaths.Count + ContentPathManager.SoundPaths.Count; @@ -63,8 +74,6 @@ namespace Penguloon LoadPercentage = (int)((itemsLoaded / totalItemsToLoad) * 100); LoadPercentageF = (itemsLoaded / totalItemsToLoad); } - - DoneLoading = true; } private static void PreLoadContent(Main main) diff --git a/Penguloon/ContentPathManager.cs b/Penguloon/ContentPathManager.cs index 915b93e..eaa0f64 100644 --- a/Penguloon/ContentPathManager.cs +++ b/Penguloon/ContentPathManager.cs @@ -86,6 +86,7 @@ namespace Penguloon "UI/heart", "UI/explosion", "UI/radar", + "UI/star", "SplashArt/locked", "SplashArt/1", diff --git a/Penguloon/Controls/LevelSelector.cs b/Penguloon/Controls/LevelSelector.cs index 885d6c1..6322b79 100644 --- a/Penguloon/Controls/LevelSelector.cs +++ b/Penguloon/Controls/LevelSelector.cs @@ -60,6 +60,8 @@ namespace Penguloon.Controls if (Panel2.Intersects(fingerRec) && Levels[selectedMap].MinimumLevel <= UserdataManager.Level) { + if (Levels[selectedMap].MinimumLevel == 0 && !BillingManager.MapPackPurchased) return; + SoundManager.PlayClickSound(); SceneManager.GameScene = new GameScene(ParentScene.Main, Levels[selectedMap]); SceneManager.SelectedScene = SelectedScene.Ingame; @@ -107,11 +109,15 @@ namespace Penguloon.Controls Levels.Add(new IceLevel3()); Levels.Add(new SandLevel1()); - Levels.Add(new SandLevel2()); - Levels.Add(new SandLevel3()); - Levels.Add(new SpaceLevel1()); - Levels.Add(new SpaceLevel2()); + //if (BillingManager.MapPackPurchased) + { + Levels.Add(new SandLevel2()); + Levels.Add(new SandLevel3()); + + Levels.Add(new SpaceLevel1()); + Levels.Add(new SpaceLevel2()); + } } public override void Draw(float deltaTime) @@ -139,6 +145,18 @@ namespace Penguloon.Controls //DrawLevel(new Vector2(Panel0.X + 25, Panel0.Y + Panel0.Height - 20), Levels[selectedMap - 2].MinimumLevel); } + else if (Levels[selectedMap - 2].MinimumLevel == 0) + { + if (!BillingManager.MapPackPurchased) + { + ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("SplashArt/locked"), + destinationRectangle: Panel0); + } + + // draw star here + ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/star"), + destinationRectangle: new Rectangle(Panel0.X + 25, Panel0.Y + 25, 100, 100)); + } } if (selectedMap - 1 >= 0) @@ -154,6 +172,19 @@ namespace Penguloon.Controls ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/lock"), destinationRectangle: new Rectangle(Panel1.X + 25, Panel1.Y + 25, 100, 100)); } + else if (Levels[selectedMap - 1].MinimumLevel == 0) + { + if (!BillingManager.MapPackPurchased) + { + ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("SplashArt/locked"), + destinationRectangle: Panel1); + } + + // draw star here + ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/star"), + destinationRectangle: new Rectangle(Panel1.X + 25, Panel1.Y + 25, 100, 100)); + } + DrawLevel(new Vector2(Panel1.X + 25, Panel1.Y + Panel1.Height - 10), Levels[selectedMap - 1].MinimumLevel); } @@ -170,6 +201,19 @@ namespace Penguloon.Controls ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/lock"), destinationRectangle: new Rectangle(Panel4.X + 25, Panel4.Y + 25, 100, 100)); } + else if (Levels[selectedMap + 2].MinimumLevel == 0) + { + if (!BillingManager.MapPackPurchased) + { + ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("SplashArt/locked"), + destinationRectangle: Panel4); + } + + // draw star here + ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/star"), + destinationRectangle: new Rectangle(Panel4.X + 25, Panel4.Y + 25, 100, 100)); + } + DrawLevel(new Vector2(Panel4.X + 25, Panel4.Y + Panel4.Height - 10), Levels[selectedMap + 2].MinimumLevel); } @@ -186,6 +230,19 @@ namespace Penguloon.Controls ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/lock"), destinationRectangle: new Rectangle(Panel3.X + 25, Panel3.Y + 25, 100, 100)); } + else if (Levels[selectedMap + 1].MinimumLevel == 0) + { + if (!BillingManager.MapPackPurchased) + { + ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("SplashArt/locked"), + destinationRectangle: Panel3); + } + + // draw star here + ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/star"), + destinationRectangle: new Rectangle(Panel3.X + 25, Panel3.Y + 25, 100, 100)); + } + DrawLevel(new Vector2(Panel3.X + 25, Panel3.Y + Panel3.Height - 10), Levels[selectedMap + 1].MinimumLevel); } @@ -197,15 +254,30 @@ namespace Penguloon.Controls ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("SplashArt/locked"), destinationRectangle: Panel2); + ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/lock"), destinationRectangle: new Rectangle(Panel2.X + 25, Panel2.Y + 25, 100, 100)); } + else if (Levels[selectedMap].MinimumLevel == 0) + { + if (!BillingManager.MapPackPurchased) + { + ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("SplashArt/locked"), + destinationRectangle: Panel2); + } + + // draw star here + ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/star"), + destinationRectangle: new Rectangle(Panel2.X + 25, Panel2.Y + 25, 100, 100)); + } DrawLevel(new Vector2(Panel2.X + 25, Panel2.Y + Panel2.Height - 10), Levels[selectedMap].MinimumLevel); } private void DrawLevel(Vector2 position, int minLevel) { + if (minLevel == 0) return; + ParentScene.DrawText(ContentManager.GetFont(StaticUIValues.StatsFont), minLevel.ToString(), new Vector2((int)position.X + ContentManager.GetFont(StaticUIValues.StatsFont).MeasureString(ParentScene.Main.Resources.GetString(Resource.String.StatsLevel) + " ").X, position.Y), diff --git a/Penguloon/Enums.cs b/Penguloon/Enums.cs index 0b800a6..5499bf5 100644 --- a/Penguloon/Enums.cs +++ b/Penguloon/Enums.cs @@ -23,7 +23,8 @@ namespace Penguloon LevelSelection, Stats, Credits, - Support + Support, + Shop } public enum ControlState diff --git a/Penguloon/Levels/SandLevel2.cs b/Penguloon/Levels/SandLevel2.cs index 006737a..89c437e 100644 --- a/Penguloon/Levels/SandLevel2.cs +++ b/Penguloon/Levels/SandLevel2.cs @@ -14,7 +14,7 @@ namespace Penguloon.Levels this.Money = 350; this.Health = 200; this.ID = 5; - this.MinimumLevel = 20; + this.MinimumLevel = 0; LevelType = LevelType.Sand; } diff --git a/Penguloon/Levels/SandLevel3.cs b/Penguloon/Levels/SandLevel3.cs index a158544..057167f 100644 --- a/Penguloon/Levels/SandLevel3.cs +++ b/Penguloon/Levels/SandLevel3.cs @@ -14,7 +14,7 @@ namespace Penguloon.Levels this.Money = 350; this.Health = 200; this.ID = 6; - this.MinimumLevel = 25; + this.MinimumLevel = 0; LevelType = LevelType.Sand; } diff --git a/Penguloon/Levels/SpaceLevel1.cs b/Penguloon/Levels/SpaceLevel1.cs index b07ad66..979873f 100644 --- a/Penguloon/Levels/SpaceLevel1.cs +++ b/Penguloon/Levels/SpaceLevel1.cs @@ -14,7 +14,7 @@ namespace Penguloon.Levels this.Money = 350; this.Health = 200; this.ID = 7; - this.MinimumLevel = 30; + this.MinimumLevel = 0; LevelType = LevelType.Space; } diff --git a/Penguloon/Levels/SpaceLevel2.cs b/Penguloon/Levels/SpaceLevel2.cs index 6de68ba..e31c63f 100644 --- a/Penguloon/Levels/SpaceLevel2.cs +++ b/Penguloon/Levels/SpaceLevel2.cs @@ -14,7 +14,7 @@ namespace Penguloon.Levels this.Money = 350; this.Health = 200; this.ID = 8; - this.MinimumLevel = 35; + this.MinimumLevel = 0; LevelType = LevelType.Space; } diff --git a/Penguloon/MainApplication.cs b/Penguloon/MainApplication.cs index 767d6f3..7737a1c 100644 --- a/Penguloon/MainApplication.cs +++ b/Penguloon/MainApplication.cs @@ -36,10 +36,12 @@ namespace Penguloon public void OnActivityDestroyed(Activity activity) { + CrossCurrentActivity.Current.Activity = activity; } public void OnActivityPaused(Activity activity) { + CrossCurrentActivity.Current.Activity = activity; } public void OnActivityResumed(Activity activity) @@ -49,6 +51,7 @@ namespace Penguloon public void OnActivitySaveInstanceState(Activity activity, Bundle outState) { + CrossCurrentActivity.Current.Activity = activity; } public void OnActivityStarted(Activity activity) @@ -58,6 +61,42 @@ namespace Penguloon public void OnActivityStopped(Activity activity) { + CrossCurrentActivity.Current.Activity = activity; + } + + public void OnActivityCreated(Android.App.Activity activity, Bundle savedInstanceState) + { + CrossCurrentActivity.Current.Activity = activity; + } + + public void OnActivityDestroyed(Android.App.Activity activity) + { + CrossCurrentActivity.Current.Activity = activity; + } + + public void OnActivityPaused(Android.App.Activity activity) + { + CrossCurrentActivity.Current.Activity = activity; + } + + public void OnActivityResumed(Android.App.Activity activity) + { + CrossCurrentActivity.Current.Activity = activity; + } + + public void OnActivitySaveInstanceState(Android.App.Activity activity, Bundle outState) + { + CrossCurrentActivity.Current.Activity = activity; + } + + public void OnActivityStarted(Android.App.Activity activity) + { + CrossCurrentActivity.Current.Activity = activity; + } + + public void OnActivityStopped(Android.App.Activity activity) + { + CrossCurrentActivity.Current.Activity = activity; } } } \ No newline at end of file diff --git a/Penguloon/Penguloon.csproj b/Penguloon/Penguloon.csproj index 837942b..3602286 100644 --- a/Penguloon/Penguloon.csproj +++ b/Penguloon/Penguloon.csproj @@ -19,7 +19,7 @@ armeabi-v7a%3bx86 .m4a - v4.4 + v7.1 Android Properties\AndroidManifest.xml false @@ -65,14 +65,14 @@ ..\packages\Plugin.CurrentActivity.1.0.1\lib\MonoAndroid10\Plugin.CurrentActivity.dll - - ..\packages\Plugin.InAppBilling.1.2.4\lib\MonoAndroid10\Plugin.InAppBilling.dll + + ..\packages\Plugin.InAppBilling.1.2.1\lib\MonoAndroid10\Plugin.InAppBilling.dll - - ..\packages\Plugin.InAppBilling.1.2.4\lib\MonoAndroid10\Plugin.InAppBilling.Abstractions.dll + + ..\packages\Plugin.InAppBilling.1.2.1\lib\MonoAndroid10\Plugin.InAppBilling.Abstractions.dll - - ..\packages\Plugin.InAppBilling.1.2.4\lib\MonoAndroid10\Plugin.InAppBilling.VendingLibrary.dll + + ..\packages\Plugin.InAppBilling.1.2.1\lib\MonoAndroid10\Plugin.InAppBilling.VendingLibrary.dll @@ -141,6 +141,7 @@ + @@ -153,6 +154,7 @@ + diff --git a/Penguloon/Properties/AndroidManifest.xml b/Penguloon/Properties/AndroidManifest.xml index 04d8e47..b4785aa 100644 --- a/Penguloon/Properties/AndroidManifest.xml +++ b/Penguloon/Properties/AndroidManifest.xml @@ -1,5 +1,5 @@  - + diff --git a/Penguloon/Resources/Resource.Designer.cs b/Penguloon/Resources/Resource.Designer.cs index fd8c221..adb5fa1 100644 --- a/Penguloon/Resources/Resource.Designer.cs +++ b/Penguloon/Resources/Resource.Designer.cs @@ -1531,59 +1531,59 @@ namespace Penguloon // aapt resource value: 0x7f05002d public const int ApplicationName = 2131034157; - // aapt resource value: 0x7f050033 - public const int EndScreenExit = 2131034163; - // aapt resource value: 0x7f050034 - public const int EndScreenGameOver = 2131034164; + public const int EndScreenExit = 2131034164; // aapt resource value: 0x7f050035 - public const int EndScreenKills = 2131034165; + public const int EndScreenGameOver = 2131034165; - // aapt resource value: 0x7f050037 - public const int EndScreenPR = 2131034167; + // aapt resource value: 0x7f050036 + public const int EndScreenKills = 2131034166; // aapt resource value: 0x7f050038 - public const int EndScreenRestart = 2131034168; + public const int EndScreenPR = 2131034168; - // aapt resource value: 0x7f050036 - public const int EndScreenWave = 2131034166; + // aapt resource value: 0x7f050039 + public const int EndScreenRestart = 2131034169; - // aapt resource value: 0x7f05003c - public const int IngameGold = 2131034172; + // aapt resource value: 0x7f050037 + public const int EndScreenWave = 2131034167; - // aapt resource value: 0x7f05003b - public const int IngameHealth = 2131034171; + // aapt resource value: 0x7f05003d + public const int IngameGold = 2131034173; - // aapt resource value: 0x7f05004b - public const int IngameNo = 2131034187; + // aapt resource value: 0x7f05003c + public const int IngameHealth = 2131034172; - // aapt resource value: 0x7f050039 - public const int IngameOptions = 2131034169; + // aapt resource value: 0x7f05004c + public const int IngameNo = 2131034188; - // aapt resource value: 0x7f050048 - public const int IngameOptionsAutoStart = 2131034184; + // aapt resource value: 0x7f05003a + public const int IngameOptions = 2131034170; - // aapt resource value: 0x7f050046 - public const int IngameOptionsContinue = 2131034182; + // aapt resource value: 0x7f050049 + public const int IngameOptionsAutoStart = 2131034185; // aapt resource value: 0x7f050047 - public const int IngameOptionsQuit = 2131034183; + public const int IngameOptionsContinue = 2131034183; - // aapt resource value: 0x7f050049 - public const int IngameOptionsQuitConfirmation = 2131034185; + // aapt resource value: 0x7f050048 + public const int IngameOptionsQuit = 2131034184; - // aapt resource value: 0x7f05003a - public const int IngameStart = 2131034170; + // aapt resource value: 0x7f05004a + public const int IngameOptionsQuitConfirmation = 2131034186; - // aapt resource value: 0x7f05003d - public const int IngameWave = 2131034173; + // aapt resource value: 0x7f05003b + public const int IngameStart = 2131034171; - // aapt resource value: 0x7f05004a - public const int IngameYes = 2131034186; + // aapt resource value: 0x7f05003e + public const int IngameWave = 2131034174; - // aapt resource value: 0x7f050032 - public const int LevelSelectionBack = 2131034162; + // aapt resource value: 0x7f05004b + public const int IngameYes = 2131034187; + + // aapt resource value: 0x7f050033 + public const int LevelSelectionBack = 2131034163; // aapt resource value: 0x7f050030 public const int MenuBtnCredits = 2131034160; @@ -1591,68 +1591,71 @@ namespace Penguloon // aapt resource value: 0x7f05002e public const int MenuBtnPlay = 2131034158; + // aapt resource value: 0x7f050032 + public const int MenuBtnShop = 2131034162; + // aapt resource value: 0x7f05002f public const int MenuBtnStats = 2131034159; // aapt resource value: 0x7f050031 public const int MenuBtnSupport = 2131034161; - // aapt resource value: 0x7f050042 - public const int ObjectCannon = 2131034178; - - // aapt resource value: 0x7f050041 - public const int ObjectGoldPenguin = 2131034177; - // aapt resource value: 0x7f050043 - public const int ObjectHospital = 2131034179; + public const int ObjectCannon = 2131034179; - // aapt resource value: 0x7f050045 - public const int ObjectKingPenguin = 2131034181; + // aapt resource value: 0x7f050042 + public const int ObjectGoldPenguin = 2131034178; // aapt resource value: 0x7f050044 - public const int ObjectMortar = 2131034180; + public const int ObjectHospital = 2131034180; - // aapt resource value: 0x7f050040 - public const int ObjectPenguin = 2131034176; + // aapt resource value: 0x7f050046 + public const int ObjectKingPenguin = 2131034182; - // aapt resource value: 0x7f050055 - public const int StatsBestKills = 2131034197; + // aapt resource value: 0x7f050045 + public const int ObjectMortar = 2131034181; + + // aapt resource value: 0x7f050041 + public const int ObjectPenguin = 2131034177; // aapt resource value: 0x7f050056 - public const int StatsBestRound = 2131034198; + public const int StatsBestKills = 2131034198; - // aapt resource value: 0x7f050054 - public const int StatsBestStatsTitle = 2131034196; + // aapt resource value: 0x7f050057 + public const int StatsBestRound = 2131034199; - // aapt resource value: 0x7f05004e - public const int StatsLevel = 2131034190; + // aapt resource value: 0x7f050055 + public const int StatsBestStatsTitle = 2131034197; // aapt resource value: 0x7f05004f - public const int StatsResetConfirmation = 2131034191; + public const int StatsLevel = 2131034191; - // aapt resource value: 0x7f050052 - public const int StatsTotalGames = 2131034194; - - // aapt resource value: 0x7f050051 - public const int StatsTotalKills = 2131034193; + // aapt resource value: 0x7f050050 + public const int StatsResetConfirmation = 2131034192; // aapt resource value: 0x7f050053 - public const int StatsTotalMoneySpent = 2131034195; + public const int StatsTotalGames = 2131034195; - // aapt resource value: 0x7f050050 - public const int StatsTotalStatsTitle = 2131034192; + // aapt resource value: 0x7f050052 + public const int StatsTotalKills = 2131034194; - // aapt resource value: 0x7f05004d - public const int SupportDonate = 2131034189; + // aapt resource value: 0x7f050054 + public const int StatsTotalMoneySpent = 2131034196; - // aapt resource value: 0x7f05004c - public const int SupportRate = 2131034188; + // aapt resource value: 0x7f050051 + public const int StatsTotalStatsTitle = 2131034193; - // aapt resource value: 0x7f05003e - public const int UpgradeMenuSell = 2131034174; + // aapt resource value: 0x7f05004e + public const int SupportDonate = 2131034190; + + // aapt resource value: 0x7f05004d + public const int SupportRate = 2131034189; // aapt resource value: 0x7f05003f - public const int UpgradeMenuSellConfirmation = 2131034175; + public const int UpgradeMenuSell = 2131034175; + + // aapt resource value: 0x7f050040 + public const int UpgradeMenuSellConfirmation = 2131034176; // aapt resource value: 0x7f050007 public const int abc_action_bar_home_description = 2131034119; @@ -2626,7 +2629,7 @@ namespace Penguloon 16843055, 16843056, 16843057, - 16843829}; + 18219096}; // aapt resource value: 4 public const int MenuView_android_headerBackground = 4; diff --git a/Penguloon/Resources/Values/Strings.xml b/Penguloon/Resources/Values/Strings.xml index 311e278..69a075e 100644 --- a/Penguloon/Resources/Values/Strings.xml +++ b/Penguloon/Resources/Values/Strings.xml @@ -7,6 +7,7 @@ Stats Credits Support + Shop Back diff --git a/Penguloon/SceneManager.cs b/Penguloon/SceneManager.cs index 3aaea41..15fd93d 100644 --- a/Penguloon/SceneManager.cs +++ b/Penguloon/SceneManager.cs @@ -22,6 +22,8 @@ namespace Penguloon public static SceneBase SupportScene { get; set; } + public static SceneBase ShopScene { get; set; } + /// /// Initialize scene manager. /// @@ -52,6 +54,8 @@ namespace Penguloon CreditsScene.Draw(deltaTime); break; case SelectedScene.Support: SupportScene.Draw(deltaTime); break; + case SelectedScene.Shop: + ShopScene.Draw(deltaTime); break; default: return; @@ -83,6 +87,8 @@ namespace Penguloon CreditsScene.Update(deltaTime, touchLocations); break; case SelectedScene.Support: SupportScene.Update(deltaTime, touchLocations); break; + case SelectedScene.Shop: + ShopScene.Update(deltaTime, touchLocations); break; default: return; diff --git a/Penguloon/Scenes/MenuScene.cs b/Penguloon/Scenes/MenuScene.cs index 986657b..2923e64 100644 --- a/Penguloon/Scenes/MenuScene.cs +++ b/Penguloon/Scenes/MenuScene.cs @@ -33,6 +33,11 @@ namespace Penguloon.Scenes new Vector2(StaticUIValues.ScreenViewport.X - 50 - StaticUIValues.MenuButtonSize.Y, StaticUIValues.ScreenViewport.Y - 50 - StaticUIValues.MenuButtonSize.Y), new Vector2(StaticUIValues.MenuButtonSize.Y, StaticUIValues.MenuButtonSize.Y)); + Button btnShop = new Button(this, + new Vector2((StaticUIValues.ScreenViewport.X - StaticUIValues.MenuButtonSize.X) / 2, 100 + (StaticUIValues.MenuButtonSize.Y * 3) + (25 *3)), + StaticUIValues.MenuButtonSize, Main.Resources.GetString(Resource.String.MenuBtnShop)); + + //Button btnSupport = new Button(this, // new Vector2((StaticUIValues.ScreenViewport.X - StaticUIValues.MenuButtonSize.X) / 2, 100 + (StaticUIValues.MenuButtonSize.Y * 3) + (25 * 3)), // StaticUIValues.MenuButtonSize, Main.Resources.GetString(Resource.String.MenuBtnSupport)); @@ -40,15 +45,25 @@ namespace Penguloon.Scenes btnStart.OnClick += BtnStart_OnClick; btnStats.OnClick += BtnStats_OnClick; btnCredits.OnClick += BtnCredits_OnClick; + btnShop.OnClick += BtnShop_OnClick; ; //btnSupport.OnClick += BtnSupport_OnClick; Controls.Add(btnStart); Controls.Add(btnStats); Controls.Add(btnCredits); Controls.Add(BtnMute); + Controls.Add(btnShop); //Controls.Add(btnSupport); - + + } + + private void BtnShop_OnClick(object sender, ClickArgs e) + { + if (SceneManager.ShopScene == null) + SceneManager.ShopScene = new ShopScene(Main); + + SceneManager.SelectedScene = SelectedScene.Shop; } private void BtnSupport_OnClick(object sender, ClickArgs e) diff --git a/Penguloon/Scenes/ShopScene.cs b/Penguloon/Scenes/ShopScene.cs new file mode 100644 index 0000000..ad272d7 --- /dev/null +++ b/Penguloon/Scenes/ShopScene.cs @@ -0,0 +1,86 @@ +using Android.Content; +using Android.Views; +using Android.Views.InputMethods; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Audio; +using Microsoft.Xna.Framework.Input.Touch; +using Penguloon.Controls; +using Penguloon.Scenes; +using System; +using System.Collections.Generic; + +namespace Penguloon.Scenes +{ + public class ShopScene : SceneBase + { + public ShopScene(Main main) : base(main) + { + + } + + public override void CreateControls() + { + Button btnBack = new Button(this, + new Vector2((StaticUIValues.ScreenViewport.X - StaticUIValues.MenuButtonSize.X) / 2, 100 + (StaticUIValues.MenuButtonSize.Y * 0) + (25 * 0)), + StaticUIValues.MenuButtonSize, Main.Resources.GetString(Resource.String.LevelSelectionBack)); + + Button btnRate = new Button(this, + new Vector2((StaticUIValues.ScreenViewport.X - StaticUIValues.MenuButtonSize.X) / 2, 100 + (StaticUIValues.MenuButtonSize.Y * 1) + (25 * 1)), + StaticUIValues.MenuButtonSize, Main.Resources.GetString(Resource.String.SupportRate)); + + Button btnMapPack = new Button(this, + new Vector2((StaticUIValues.ScreenViewport.X - StaticUIValues.MenuButtonSize.X) / 2, 100 + (StaticUIValues.MenuButtonSize.Y * 2) + (25 * 2)), + StaticUIValues.MenuButtonSize, "Map pack (5 Maps)"); + + btnBack.OnClick += BtnBack_OnClick; + btnRate.OnClick += BtnRate_OnClick; + btnMapPack.OnClick += BtnUpgrade_OnClickAsync; + + Controls.Add(btnBack); + Controls.Add(btnRate); + Controls.Add(btnMapPack); + } + + private async void BtnUpgrade_OnClickAsync(object sender, ClickArgs e) + { + await BillingManager.PurchaseMapPackAsync(this); + } + + private void BtnRate_OnClick(object sender, ClickArgs e) + { + try + { + Intent rateIntent = new Intent(Intent.ActionView, Android.Net.Uri.Parse("market://details?id=" + Main.Context.PackageName)); + + Main.Activity_.StartActivity(rateIntent); + } + catch (ActivityNotFoundException ex) + { + Intent rateIntent = new Intent(Intent.ActionView, Android.Net.Uri.Parse("https://play.google.com/store/apps/details?id=" + Main.Context.PackageName)); + Main.Activity_.StartActivity(rateIntent); + } + } + + private void BtnBack_OnClick(object sender, ClickArgs e) + { + SceneManager.SelectedScene = SelectedScene.Menu; + } + + public override void Draw(float deltaTime) + { + // background + Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/background"), + destinationRectangle: new Rectangle(0, 0, (int)StaticUIValues.ScreenViewport.X, (int)StaticUIValues.ScreenViewport.Y)); + + DrawSnowflakes(); + + base.Draw(deltaTime); + } + + + public override void Update(float deltaTime, TouchLocation[] touchLocations) + { + base.Update(deltaTime, touchLocations); + } + } +} \ No newline at end of file diff --git a/Penguloon/packages.config b/Penguloon/packages.config index 239ab89..96fc836 100644 --- a/Penguloon/packages.config +++ b/Penguloon/packages.config @@ -6,7 +6,7 @@ - + -- cgit v1.2.3-70-g09d2