better "while you were away" screen

This commit is contained in:
Ellpeck 2020-07-08 18:53:48 +02:00
parent 73631719ab
commit 5a51cea0ab
5 changed files with 19 additions and 12 deletions

View file

@ -15,7 +15,9 @@
"RainingTicketLimit": "Max. Fallende Tickets",
"SoundVolume": "Lautstärke",
"AGameByEllpeck": "Ein Spiel von Ellpeck",
"WhileYouWereAway": "Während du weg warst, hast du <i ticket> mit halber Geschwindigkeit verkauft. Du warst für <c Yellow>{0} Minuten</c> weg und hast währenddessen <c Yellow>{1} <i ticket></c> verkauft. Yay!",
"WhileYouWereAway": "Während du für <c Yellow>{0} Minuten</c> weg warst, hast du <i ticket> mit halber Geschwindigkeit verkauft.",
"WhileYouWereAwayTickets": "Du hast in dieser Zeit <c Yellow>{0} <i ticket></c> verkauft.",
"WhileYouWereAwayTps": "Durch automatische Käufe hat sich deine Verkaufs-Rate um <c Yellow>{0} <i ticket>/s</c> erhöht.",
"WhileYouWereAwayMessage": "Offline-Zusammenfassung",
"----- Tutorial -----": "",
"Tutorial1": "Hi! Willkommen zu Touchy Tickets. Um das Spiel zu starten, tippe einfach den Ticket-Laden an, um ein <i ticket> zu verkaufen. Verkaufe erstmal 50<i ticket>!",

View file

@ -15,7 +15,9 @@
"RainingTicketLimit": "Max Raining Tickets",
"SoundVolume": "Sound Volume",
"AGameByEllpeck": "A game by Ellpeck",
"WhileYouWereAway": "While you were away, you sold <i ticket> at half the regular speed. You were away for <c Yellow>{0} minutes</c> and sold <c Yellow>{1} <i ticket></c> during that time. Nice!",
"WhileYouWereAway": "While you were away for <c Yellow>{0} minutes</c>, you sold <i ticket> at half the regular speed.",
"WhileYouWereAwayTickets": "During that time, you sold <c Yellow>{0} <i ticket></c>.",
"WhileYouWereAwayTps": "Due to auto-buying, your sale rate increased by <c Yellow>{0} <i ticket>/s</c>.",
"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 <c Yellow>rate</c> the game, it really helps out! Thanks <3",

View file

@ -121,13 +121,14 @@ namespace TouchyTickets {
var now = DateTime.Now;
if (this.LastUpdate != default) {
var lastTickets = this.Tickets;
var lastTps = this.Map.TicketsPerSecond;
var passed = now - this.LastUpdate;
this.Map.Update(passed, passed.TotalSeconds >= 1);
var generated = this.Tickets - lastTickets;
// if 10 or more seconds passed, we display a message
if (Options.Instance.WhileYouWereAwayMessage && passed.TotalSeconds >= 10 && generated > 0)
Ui.DisplayWhileYouWereAway(passed, generated);
if (Options.Instance.WhileYouWereAwayMessage && passed.TotalSeconds >= 10)
Ui.DisplayWhileYouWereAway(passed, this.Tickets - lastTickets, this.Map.TicketsPerSecond - lastTps);
}
this.LastUpdate = now;
}

View file

@ -26,8 +26,8 @@ namespace TouchyTickets {
private readonly Dictionary<Point, int> fencePositions = new Dictionary<Point, int>();
private readonly Attraction[,] attractionGrid;
[DataMember]
public double TicketsPerSecond { get; private set; }
public readonly Dictionary<AttractionType, double> TicketsPerRide = new Dictionary<AttractionType, double>();
public Attraction PlacingAttraction;
public AttractionModifier PlacingModifier;
public Point PlacingPosition;
@ -80,13 +80,9 @@ namespace TouchyTickets {
}
// update tickets
this.TicketsPerRide.Clear();
this.TicketsPerSecond = 0;
foreach (var (pos, attraction) in this.attractions) {
var genPerSecond = attraction.Update(toSimulate, this, pos);
// store ride statistics
this.TicketsPerRide.TryGetValue(attraction.Type, out var curr);
this.TicketsPerRide[attraction.Type] = curr + genPerSecond;
this.TicketsPerSecond += genPerSecond;
// after each attraction has sold their tickets, try auto-buying again if we were away
@ -241,6 +237,7 @@ namespace TouchyTickets {
if (newMap.CanPlace(pos, attraction))
newMap.Place(pos, attraction);
}
newMap.TicketsPerSecond = this.TicketsPerSecond;
return newMap;
}

View file

@ -585,12 +585,17 @@ namespace TouchyTickets {
splash.System.Remove(splash.Root.Name);
}
public static void DisplayWhileYouWereAway(TimeSpan passed, BigInteger ticketsGenerated) {
public static void DisplayWhileYouWereAway(TimeSpan passed, BigInteger ticketGen, double ticketPerSecondGen) {
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("WhileYouWereAway"), passed.TotalMinutes.ToString("0.#"), PrettyPrintNumber(ticketsGenerated))));
var text = string.Format(Localization.Get("WhileYouWereAway"), passed.TotalMinutes.ToString("0.#"));
if (ticketGen > 0)
text += " " + string.Format(Localization.Get("WhileYouWereAwayTickets"), PrettyPrintNumber(ticketGen));
if (ticketPerSecondGen > 0)
text += " " + string.Format(Localization.Get("WhileYouWereAwayTps"), ticketPerSecondGen.ToString("#,0.##"));
panel.AddChild(new Paragraph(Anchor.AutoLeft, 1, text));
panel.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 30), Localization.Get("Okay")) {
OnPressed = e2 => e2.System.Remove(e2.Root.Name)
});