added tutorial

This commit is contained in:
Ellpeck 2020-06-02 23:58:46 +02:00
parent 595bcc514e
commit 2554d4c7cc
5 changed files with 82 additions and 2 deletions

View file

@ -4,7 +4,17 @@
"EarnStar": "Earn <i star>",
"ReallyEarnStar": "Are you sure that you want to earn a <i star>? This will remove all placed attractions and reset your <i ticket>!",
"Yes": "Yes",
"Okay": "Okay",
"RequiresTickets": "Requires {0}<i ticket>",
"Tutorial1": "Hi! Welcome to Touchy Tickets. To start the game, simply tap the ticket booth to sell a <i ticket>. Start by racking up 50<i ticket>!",
"Tutorial2": "Great! Now, you can buy your first attraction. Access the menu on the right by swiping and purchase a carousel.",
"Tutorial3": "This is your park map. The area inside the fence is what belongs to you. Place the carousel by dragging it to the perfect location and then pressing the button below.",
"Tutorial4": "Now that you've placed your carousel, you can see that you're automatically starting to rack up <i ticket> on the main screen!",
"Tutorial5": "You'll still be able to sell <i ticket> manually by tapping, but the longer you play, the more <i ticket> you'll be able to accumulate automatically.",
"Tutorial6": "While the game is closed or in the background, you'll sell <i ticket> at half the regular speed.",
"Tutorial7": "Looks like you finally sold enough <i ticket> to exchange them for a <i star>! Once you're ready, access the menu on the left by swiping and earn a <i star>.",
"Tutorial8": "Now that you have a <i star>, you also have to restart the game. But don't worry - <i star> give you the ability to purchase some great permanent upgrades for your attractions.",
"Tutorial9": "Now, you can rack up more <i ticket> even faster to earn more <i star> to rack up more <i ticket>... you get the point. Have fun!",
"Carousel": "Carousel",
"FoodCourt": "Food Court",
"FerrisWheel": "Ferris Wheel",

View file

@ -15,6 +15,7 @@ namespace TouchyTickets {
public static GameImpl Instance { get; private set; }
public readonly ISet<Upgrade> AppliedUpgrades = new HashSet<Upgrade>();
public readonly Tutorial Tutorial = new Tutorial();
public BigInteger Tickets;
public int TimesRestarted;
public int Stars;
@ -61,6 +62,7 @@ namespace TouchyTickets {
this.LastUpdate = now;
this.Ui.Update(gameTime);
this.Tutorial.Update(this);
// save every 3 seconds
this.saveCounter += gameTime.ElapsedGameTime.TotalSeconds;

View file

@ -25,7 +25,8 @@ namespace TouchyTickets {
Map = game.Map,
Stars = game.Stars,
TimesRestarted = game.TimesRestarted,
Upgrades = game.AppliedUpgrades.Select(u => u.Name).ToList()
Upgrades = game.AppliedUpgrades.Select(u => u.Name).ToList(),
TutorialStep = game.Tutorial.CurrentStep
};
Serializer.Serialize(stream, data);
}
@ -45,6 +46,7 @@ namespace TouchyTickets {
game.AppliedUpgrades.Clear();
foreach (var name in data.Upgrades)
game.AppliedUpgrades.Add(Upgrade.Upgrades[name]);
game.Tutorial.CurrentStep = data.TutorialStep;
}
return true;
}
@ -72,6 +74,7 @@ namespace TouchyTickets {
public int Stars;
public int TimesRestarted;
public List<string> Upgrades;
public int TutorialStep;
}
}

65
TouchyTickets/Tutorial.cs Normal file
View file

@ -0,0 +1,65 @@
using Microsoft.Xna.Framework;
using MLEM.Extensions;
using MLEM.Ui;
using MLEM.Ui.Elements;
using TouchyTickets.Attractions;
namespace TouchyTickets {
public class Tutorial {
private static readonly Step[] Steps = {
new Step(g => true, "Tutorial1"),
new Step(g => g.Tickets >= AttractionType.Carousel.InitialPrice, "Tutorial2"),
new Step(g => g.DrawMap && g.Map.PlacingAttraction?.Type == AttractionType.Carousel, "Tutorial3"),
new Step(g => g.Map.GetAttractionAmount(AttractionType.Carousel) > 0, "Tutorial4", "Tutorial5", "Tutorial6"),
new Step(g => g.Tickets >= g.GetStarPrice(), "Tutorial7"),
new Step(g => g.Stars > 0, "Tutorial8", "Tutorial9")
};
public int CurrentStep;
private int currentStepMessage;
public void Update(GameImpl game) {
// stop if the tutorial is finished
if (this.CurrentStep >= Steps.Length)
return;
// don't do anything while a tutorial box is already displaying
if (game.UiSystem.Get("TutorialBox") != null)
return;
var step = Steps[this.CurrentStep];
if (step.ShouldContinue(game)) {
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, Localization.Get(step.Content[this.currentStepMessage])));
panel.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 30), Localization.Get("Okay")) {
OnPressed = e2 => {
game.UiSystem.Remove(e2.Root.Name);
this.currentStepMessage++;
if (this.currentStepMessage >= step.Content.Length) {
this.currentStepMessage = 0;
this.CurrentStep++;
}
}
});
game.UiSystem.Add("TutorialBox", infoBox);
}
}
private class Step {
public readonly ContinueDelegate ShouldContinue;
public readonly string[] Content;
public Step(ContinueDelegate shouldContinue, params string[] content) {
this.ShouldContinue = shouldContinue;
this.Content = content;
}
public delegate bool ContinueDelegate(GameImpl game);
}
}
}

View file

@ -283,7 +283,7 @@ namespace TouchyTickets {
var center = splash.AddChild(new Group(Anchor.Center, new Vector2(0.5F, 0.5F), false) {DrawAlpha = 0});
center.AddChild(new Image(Anchor.AutoCenter, new Vector2(1, -1), Texture[4, 0]));
center.AddChild(new Paragraph(Anchor.AutoCenter, 10000, "A game by Ellpeck", true));
this.uiSystem.Add("Splash", splash);
this.uiSystem.Add("Splash", splash).Priority = 100000;
while (center.DrawAlpha < 1) {
center.DrawAlpha += 0.01F;
yield return new WaitEvent(CoroutineEvents.Update);