ported from perforce
This commit is contained in:
98
DonkeysAndDroids.Godot/TutorialScreen.cs
Normal file
98
DonkeysAndDroids.Godot/TutorialScreen.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Godot;
|
||||
using RobotAndDonkey.Game.Board;
|
||||
|
||||
public partial class TutorialScreen : Control
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
m_CounterLabel = GetNode<Label>("%CounterLabel");
|
||||
m_Text = GetNode<RichTextLabel>("%Text");
|
||||
m_Text.BbcodeEnabled = true;
|
||||
m_Text.AutowrapMode = TextServer.AutowrapMode.Word;
|
||||
m_Text.ScrollActive = true;
|
||||
m_NextButton = GetNode<Button>("%NextButton");
|
||||
m_NextButton.Pressed += OnNextButtonPressed;
|
||||
m_CloseButton = GetNode<Button>("%CloseButton");
|
||||
m_CloseButton.Pressed += OnCloseButtonPressed;
|
||||
|
||||
if (m_Text != null)
|
||||
{
|
||||
m_Text.Text = Text;
|
||||
Configure(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCloseButtonPressed()
|
||||
{
|
||||
Visible = false;
|
||||
}
|
||||
|
||||
private void OnNextButtonPressed()
|
||||
{
|
||||
var tween = GetTree().CreateTween();
|
||||
tween.TweenProperty(m_Text, "modulate", new Color(1, 1, 1, 0), 0.25f);
|
||||
tween.TweenCallback(Callable.From(() =>
|
||||
{
|
||||
m_CurrentHint += 1;
|
||||
Configure(m_CurrentHint);
|
||||
}));
|
||||
tween.TweenProperty(m_Text, "modulate", new Color(1, 1, 1), 0.25f);
|
||||
}
|
||||
|
||||
public void Restart()
|
||||
{
|
||||
m_Text.Modulate = new(1, 1, 1);
|
||||
m_CurrentHint = 0;
|
||||
Configure(m_CurrentHint);
|
||||
}
|
||||
|
||||
public void Configure(int hint)
|
||||
{
|
||||
if (hint >= s_Hints.Length)
|
||||
return;
|
||||
|
||||
if (hint == s_Hints.Length - 1)
|
||||
{
|
||||
m_NextButton.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_NextButton.Visible = true;
|
||||
}
|
||||
|
||||
Text = s_Hints[hint];
|
||||
|
||||
if (m_Text != null)
|
||||
m_Text.Text = Text;
|
||||
|
||||
if (m_CounterLabel != null)
|
||||
m_CounterLabel.Text = $"{hint + 1}/{s_Hints.Length}";
|
||||
}
|
||||
|
||||
public string Text { get; private set; }
|
||||
|
||||
private static readonly string[] s_Hints =
|
||||
[
|
||||
$"Your robot does not take direct orders – it runs {c_On}programs{c_Off}.\nFor each assignment, your goal is to {c_On}deliver enough cargo{c_Off} to meet the target before you run out of {c_Energy}Energy{c_Off}.\nMove around the hex map, use {c_On}Interact{c_Off} to work with sheds, crates and towers, and try to do it in {c_On}as few instructions{c_Off} as possible. Efficient routes and short programs are rewarded in the final score.",
|
||||
$"The board consists of hexagonal shapes.\n\n - You can move the camera around with the {c_On}WASD{c_Off} keys.\n - You can rotate the view by 60 degrees using the {c_On}Q{c_Off} and {c_On}E{c_Off} keys.\n - Zoom in and out using the {c_On}R{c_Off} and {c_On}F{c_Off} keys or the {c_On}mouse wheel{c_Off}\n - Interact with the board and the cards with a {c_On}left mouse button click{c_Off}",
|
||||
$"Each program is a single pass through your {c_On}command tape{c_Off}.\n\n - Draw cards into your {c_On}hand{c_Off}.\n - Drag cards onto the tape up to its maximum {c_On}length{c_Off}.\n - Reorder, remove, or discard cards as needed (discarding costs {c_Energy}Energy{c_Off}).",
|
||||
$"When you press {c_On}Run{c_Off}, the tape executes left to right:\n\n - Most instructions spend {c_Energy}Energy{c_Off} to move, turn or interact.\n - Some cards are marked {c_On}Persistent{c_Off} and return to your deck after use. Others are discarded.\n - Zone and glitch effects may change how the remaining instructions behave.\n\nAfter execution, you return to planning the next program with whatever {c_Energy}Energy{c_Off} and map state you have left. Every program is a chance to refine your route.",
|
||||
$"Different hexes change how your robot behaves:\n\n{string.Join("\n", Enum.GetValues<ECellType>().Select(c => $" - {c_On}{c}{c_Off}: {Tooltip.GetCellDescription(c)}"))}\nPlan your path so you rest on helpful tiles and cross bad terrain only when it’s worth the cost.",
|
||||
$"Points of interest are where the real work happens:\n\n - {c_On}Sheds{c_Off}: load and deliver cargo using {c_On}Interact{c_Off}.\n - {c_On}Crates{c_Off}: adjust your {c_On}Carry{c_Off} by picking up or dropping off contents.\n - {c_On}Donkeys{c_Off}: increase your {c_On}Max Carry{c_Off} so each trip is more productive.\n - {c_On}Interference towers{c_Off}: entering them applies special glitches to the {c_On}remaining{c_Off} tape.\n\nShort, high-value delivery loops between these points are usually better than wandering everywhere.",
|
||||
$"At the end of an assignment you’re judged on more than just success or failure. The game tracks:\n\n - Instructions and programs used (fewer is better).\n - Path length and tiles visited.\n - {c_Energy}Energy{c_Off} wasted by moving while carrying nothing.\n - Overspill from delivering more than requested..",
|
||||
$"In the {c_On}Improve{c_Off} step you upgrade your deck using {c_Energy}Energy{c_Off} as currency.\n\n - Buy {c_On}patch cards{c_Off} to add new instructions or upgrades.\n - {c_On}Reroll{c_Off} to see a new set of patches, at an increasing {c_Energy}Energy{c_Off} cost.\n - Use {c_On}Cosmic Rays{c_Off} to add a fancy new random card to your deck.\n - Use {c_On}Buffer Overflow{c_Off} to permanently destroy a card.\n\nStronger cards are great, but a bloated deck is harder to program with. Trimming bad cards can be as powerful as buying new ones.",
|
||||
$"At the end of every round you draw a {c_On}Glitch{c_Off} card.\nYou must decide:\n\n - {c_On}Accept{c_Off}: apply the effect immediately (it may change the map or your instructions).\n - {c_On}Defer{c_Off}: put it back on the stack. The next time you defer a glitch in this run, it costs more {c_Energy}Energy{c_Off}.\n\nGlitches can be temporary map-wide storms or permanent defects on a single instruction. Sometimes taking a small hit now is better than paying {c_Energy}Energy{c_Off} to delay it."
|
||||
];
|
||||
|
||||
private const string c_Energy = "[color=#a5d6a7]";
|
||||
private const string c_On = "[color=#ffcc80]";
|
||||
private const string c_Off = "[/color]";
|
||||
|
||||
private int m_CurrentHint;
|
||||
private Button m_NextButton;
|
||||
private Button m_CloseButton;
|
||||
private RichTextLabel m_Text;
|
||||
private Label m_CounterLabel;
|
||||
}
|
||||
Reference in New Issue
Block a user