diff --git a/Android/AndroidPlatform.cs b/Android/AndroidPlatform.cs index b059843..65c63c6 100644 --- a/Android/AndroidPlatform.cs +++ b/Android/AndroidPlatform.cs @@ -1,7 +1,9 @@ using System.Collections; using System.Collections.Generic; using Android.App; +using Android.Content; using Android.Gms.Ads; +using Android.Net; using Android.Views; using Android.Widget; using GameAnalyticsSDK; @@ -47,5 +49,9 @@ namespace Android { } } + public override void OpenRateLink() { + this.activity.StartActivity(new Intent(Intent.ActionView, Uri.Parse("https://play.google.com/store/apps/details?id=de.ellpeck.touchytickets"))); + } + } } \ No newline at end of file diff --git a/TouchyTickets/Content/Localization/Localization.json b/TouchyTickets/Content/Localization/Localization.json index 9ee5dfa..48052de 100644 --- a/TouchyTickets/Content/Localization/Localization.json +++ b/TouchyTickets/Content/Localization/Localization.json @@ -17,6 +17,8 @@ "WhileYouWereAway": "While you were away, you sold at half the regular speed. You were away for {0} minutes and sold {1} during that time. Nice!", "WhileYouWereAwayMessage": "Display Offline Summary", "KeepScreenOn": "Keep Screen On", + "RateInfo": "You've been playing the game for a while now, which probably means you're enjoying it.\nPlease rate the game, it really helps out! Thanks <3", + "Rate": "Rate", "----- Tutorial -----": "", "Tutorial1": "Hi! Welcome to Touchy Tickets. To start the game, simply tap the ticket booth to sell a . Start by racking up 50!", "Tutorial2": "Great! Now, you can buy your first attraction. Access the menu on the right by swiping and purchase a carousel.", diff --git a/TouchyTickets/GameImpl.cs b/TouchyTickets/GameImpl.cs index db43d7c..416ee53 100644 --- a/TouchyTickets/GameImpl.cs +++ b/TouchyTickets/GameImpl.cs @@ -22,6 +22,7 @@ namespace TouchyTickets { public Ui Ui { get; private set; } public bool DrawMap; public DateTime LastUpdate; + public TimeSpan PlayTime; private double saveCounter; public GameImpl(Platform platform) { @@ -97,6 +98,12 @@ namespace TouchyTickets { } } + // play time stuff + var lastTime = this.PlayTime; + this.PlayTime += gameTime.ElapsedGameTime; + if (lastTime.TotalHours >= 1 != this.PlayTime.TotalHours >= 1) + Ui.DisplayRatePlease(); + this.Ui?.Update(gameTime); this.Tutorial?.Update(this); } diff --git a/TouchyTickets/Platform.cs b/TouchyTickets/Platform.cs index 9b6552f..a2934eb 100644 --- a/TouchyTickets/Platform.cs +++ b/TouchyTickets/Platform.cs @@ -11,5 +11,7 @@ namespace TouchyTickets { public abstract void SetKeepScreenOn(bool keep); + public abstract void OpenRateLink(); + } } \ No newline at end of file diff --git a/TouchyTickets/SaveHandler.cs b/TouchyTickets/SaveHandler.cs index 5effb8a..4330a66 100644 --- a/TouchyTickets/SaveHandler.cs +++ b/TouchyTickets/SaveHandler.cs @@ -25,7 +25,8 @@ namespace TouchyTickets { Stars = game.Stars, TimesRestarted = game.TimesRestarted, Upgrades = game.AppliedUpgrades.Select(u => u.Name).ToList(), - TutorialStep = game.Tutorial.CurrentStep + TutorialStep = game.Tutorial.CurrentStep, + PlayTime = game.PlayTime }; Serializer.Serialize(stream, data); } @@ -48,6 +49,7 @@ namespace TouchyTickets { foreach (var name in data.Upgrades) game.AppliedUpgrades.Add(Upgrade.Upgrades[name]); game.Tutorial.CurrentStep = data.TutorialStep; + game.PlayTime = data.PlayTime; // version 1 had smaller maps if (data.SaveVersion <= 1) { @@ -88,6 +90,7 @@ namespace TouchyTickets { public int TimesRestarted; public List Upgrades; public int TutorialStep; + public TimeSpan PlayTime; } } \ No newline at end of file diff --git a/TouchyTickets/Ui.cs b/TouchyTickets/Ui.cs index 6b13869..f405073 100644 --- a/TouchyTickets/Ui.cs +++ b/TouchyTickets/Ui.cs @@ -560,6 +560,24 @@ namespace TouchyTickets { GameImpl.Instance.UiSystem.Add("WhileYouWereAway", infoBox); } + public static void DisplayRatePlease() { + var infoBox = new Group(Anchor.TopLeft, Vector2.One, false) { + OnDrawn = (e2, time, batch, alpha) => batch.Draw(batch.GetBlankTexture(), e2.DisplayArea, Color.Black * 0.35F) + }; + var panel = infoBox.AddChild(new Panel(Anchor.Center, new Vector2(0.8F), Vector2.Zero, true)); + panel.AddChild(new Paragraph(Anchor.AutoLeft, 1, string.Format(Localization.Get("RateInfo")))); + panel.AddChild(new Button(Anchor.AutoLeft, new Vector2(0.5F, 30), Localization.Get("Back")) { + OnPressed = e2 => e2.System.Remove(e2.Root.Name) + }); + panel.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 30), Localization.Get("Rate")) { + OnPressed = e2 => { + GameImpl.Instance.Platform.OpenRateLink(); + e2.System.Remove(e2.Root.Name); + } + }); + GameImpl.Instance.UiSystem.Add("RatePlease", infoBox); + } + private void FadeUi(bool fadeOut, Action after = null) { IEnumerator Impl() { // disable input handling during fade diff --git a/iOS/IosPlatform.cs b/iOS/IosPlatform.cs index 306fbe1..0ea4c54 100644 --- a/iOS/IosPlatform.cs +++ b/iOS/IosPlatform.cs @@ -24,5 +24,9 @@ namespace iOS { throw new System.NotImplementedException(); } + public override void OpenRateLink() { + throw new System.NotImplementedException(); + } + } } \ No newline at end of file