Implement more QoL features and rebalances
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
using System.Collections.Generic;
|
||||
using KernelPanic.Combat;
|
||||
using KernelPanic.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace KernelPanic.UI
|
||||
{
|
||||
/// <summary>Short synthesized terminal cues. Observes gameplay; never delays it or consumes RNG.</summary>
|
||||
[DisallowMultipleComponent]
|
||||
public sealed class CombatAudio : MonoBehaviour
|
||||
{
|
||||
private AudioSource _source;
|
||||
private readonly Dictionary<string, AudioClip> _clips = new();
|
||||
private readonly Dictionary<string, float> _lastPlayed = new();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_source = gameObject.AddComponent<AudioSource>();
|
||||
_source.playOnAwake = false;
|
||||
_source.spatialBlend = 0;
|
||||
if (FindFirstObjectByType<AudioListener>() == null) gameObject.AddComponent<AudioListener>();
|
||||
CreateCue("dispatch", 420, 700, .07f);
|
||||
CreateCue("resolve", 660, 920, .10f);
|
||||
CreateCue("shield", 240, 70, .13f);
|
||||
CreateCue("hit", 120, 55, .08f);
|
||||
CreateCue("revive", 160, 540, .24f);
|
||||
CreateCue("clear", 520, 1040, .26f);
|
||||
CreateCue("victory", 660, 1320, .48f);
|
||||
CreateCue("defeat", 220, 55, .35f);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
GameEvents.CardPlayed += OnPlayed;
|
||||
GameEvents.CardResolving += OnResolving;
|
||||
GameEvents.DamageDealt += OnDamage;
|
||||
GameEvents.EnemyRevived += OnRevived;
|
||||
GameEvents.WaveCleared += OnClear;
|
||||
GameEvents.RunEnded += OnEnded;
|
||||
UIPreferences.Changed += OnPreferences;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
GameEvents.CardPlayed -= OnPlayed;
|
||||
GameEvents.CardResolving -= OnResolving;
|
||||
GameEvents.DamageDealt -= OnDamage;
|
||||
GameEvents.EnemyRevived -= OnRevived;
|
||||
GameEvents.WaveCleared -= OnClear;
|
||||
GameEvents.RunEnded -= OnEnded;
|
||||
UIPreferences.Changed -= OnPreferences;
|
||||
if (_source != null) _source.Stop();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
foreach (var clip in _clips.Values) Destroy(clip);
|
||||
if (_source != null) Destroy(_source);
|
||||
}
|
||||
|
||||
private void OnPreferences() { if (UIPreferences.SoundVolume == 0) _source?.Stop(); }
|
||||
private void OnPlayed(CardPlayedEvent _) => Play("dispatch");
|
||||
private void OnResolving(CardResolvedEvent e) { if (e.Track != ResolutionTrack.Native) Play("resolve"); }
|
||||
private void OnDamage(DamageDealtEvent e)
|
||||
{
|
||||
if (e.ShieldDamage > 0 && e.Target != null && e.Target.Shield == 0) Play("shield");
|
||||
else if (e.UptimeDamage > 0) Play("hit");
|
||||
}
|
||||
private void OnRevived(EnemyInstance _) => Play("revive");
|
||||
private void OnClear(WaveClearedEvent _) => Play("clear");
|
||||
private void OnEnded(RunEndedEvent e) => Play(e.PlayerDied ? "defeat" : "victory");
|
||||
|
||||
private void Play(string cue)
|
||||
{
|
||||
if (_source == null || UIPreferences.SoundVolume <= 0) return;
|
||||
// Bound dense multi-hit sequences without dropping different kinds of feedback.
|
||||
if (_lastPlayed.TryGetValue(cue, out float last) && Time.unscaledTime - last < .075f) return;
|
||||
_lastPlayed[cue] = Time.unscaledTime;
|
||||
_source.PlayOneShot(_clips[cue], UIPreferences.SoundVolume / 100f);
|
||||
}
|
||||
|
||||
private void CreateCue(string name, float from, float to, float duration)
|
||||
{
|
||||
const int sampleRate = 22050;
|
||||
float[] samples = new float[Mathf.CeilToInt(sampleRate * duration)];
|
||||
double phase = 0;
|
||||
for (int i = 0; i < samples.Length; i++)
|
||||
{
|
||||
float t = i / (float)samples.Length;
|
||||
phase += 2 * System.Math.PI * Mathf.Lerp(from, to, t) / sampleRate;
|
||||
float envelope = Mathf.Min(1, t * 40) * (1 - t) * (1 - t);
|
||||
samples[i] = .16f * envelope * (float)(System.Math.Sin(phase) + .2 * System.Math.Sin(phase * 2));
|
||||
}
|
||||
var clip = AudioClip.Create("terminal-" + name, samples.Length, 1, sampleRate, false);
|
||||
clip.SetData(samples, 0);
|
||||
_clips.Add(name, clip);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a87b533a0cca59546ae15534fa85b80a
|
||||
@@ -61,6 +61,7 @@ namespace KernelPanic.UI
|
||||
private VisualElement _journalEntries;
|
||||
private Foldout _journal;
|
||||
private Button _endTurnButton;
|
||||
private Button _prefetchButton;
|
||||
private Label _targetHint;
|
||||
private Label _schedulerActivity;
|
||||
private ScrollView _handScroll;
|
||||
@@ -115,6 +116,9 @@ namespace KernelPanic.UI
|
||||
private SaveData _lastKnownSave;
|
||||
private string _saveError;
|
||||
private string _checkpointError;
|
||||
private bool _routeSelectionOpen;
|
||||
private DailyQuestTracker _dailyQuestTracker;
|
||||
private IVisualElementScheduledItem _dailyQuestSaveSchedule;
|
||||
private CombatRunTelemetry _runTelemetry;
|
||||
private RunHistoryEntry _runHistoryEntry;
|
||||
private bool _pileInspectorOpen;
|
||||
@@ -125,6 +129,7 @@ namespace KernelPanic.UI
|
||||
_document = GetComponent<UIDocument>();
|
||||
_runManager = GetComponent<RunManager>();
|
||||
_combatManager = GetComponent<CombatManager>();
|
||||
if (Application.isPlaying && GetComponent<CombatAudio>() == null) gameObject.AddComponent<CombatAudio>();
|
||||
_saveService = new SaveService();
|
||||
_root = _document.rootVisualElement;
|
||||
LoadStyles();
|
||||
@@ -191,6 +196,21 @@ namespace KernelPanic.UI
|
||||
_distroAccent = config.Distro == null ? Color.white : config.Distro.AccentColor;
|
||||
TerminalTheme.SetDistro(_root, config.Distro);
|
||||
_combatManager.SetGeneratedCardPool(BuildGeneratedCardPool());
|
||||
if (!config.IsTutorial)
|
||||
{
|
||||
_dailyQuestTracker = new DailyQuestTracker(_saveService,
|
||||
() => _runManager.CurrentConfig != null && !_runManager.IsSuspended,
|
||||
() => _combatManager.PlayerState);
|
||||
var notice = TerminalLayout.BodyText("", "DailyQuestSaveNotice");
|
||||
notice.style.display = DisplayStyle.None;
|
||||
_root.Insert(1, notice);
|
||||
_dailyQuestSaveSchedule = _root.schedule.Execute(() =>
|
||||
{
|
||||
bool saved = _dailyQuestTracker.Flush();
|
||||
notice.text = saved ? "" : "Daily quest progress could not be saved. Retrying...";
|
||||
notice.style.display = saved ? DisplayStyle.None : DisplayStyle.Flex;
|
||||
}).Every(2000);
|
||||
}
|
||||
if (config.IsTutorial)
|
||||
{
|
||||
_tutorial = new TutorialFlow(_overlay, _runManager, _combatManager, cardDatabase, languageDeckDatabase,
|
||||
@@ -240,6 +260,9 @@ namespace KernelPanic.UI
|
||||
private void OnDisable()
|
||||
{
|
||||
Time.timeScale = 1f;
|
||||
_dailyQuestSaveSchedule?.Pause();
|
||||
_dailyQuestTracker?.Dispose();
|
||||
_dailyQuestTracker = null;
|
||||
SettleRunRewardsIfNeeded();
|
||||
_tutorial?.Dispose();
|
||||
_combatManager.StateChanged -= Refresh;
|
||||
@@ -500,6 +523,14 @@ namespace KernelPanic.UI
|
||||
_turnResourceGrid.name = "TutorialPiles";
|
||||
_turnResourceGrid.AddToClassList("turn-resource-grid");
|
||||
commandPanel.Add(_turnResourceGrid);
|
||||
_prefetchButton = new Button(() => _combatManager.TryPrefetch())
|
||||
{
|
||||
name = "PrefetchButton", text = "draw 1 / 2 Cycles",
|
||||
tooltip = "Prefetch: draw 1 card once per turn. Requires 2 free RAM so any card fits. Draws from the deck, reshuffling discard if needed."
|
||||
};
|
||||
_prefetchButton.AddToClassList("prefetch-action");
|
||||
handPanel.Q<Label>(className: "panel-subtitle")?.RemoveFromHierarchy();
|
||||
handPanel.Q(className: "panel-header").Add(_prefetchButton);
|
||||
_endTurnButton = new(() => _combatManager.EndPlayerTurn()) { text = "[E] end turn" };
|
||||
_endTurnButton.name = "TutorialEndTurn";
|
||||
_endTurnButton.AddToClassList("primary-action");
|
||||
@@ -925,6 +956,8 @@ namespace KernelPanic.UI
|
||||
card.EnableInClassList("enemy-card-targeted", highlighted);
|
||||
card.Q<Label>(className: "enemy-name").text = enemy.Name;
|
||||
card.tooltip = enemy.Name + " / " + IntentText(enemy.DisplayIntent);
|
||||
if (enemy.HasBehavior(EnemyBehaviorFlags.ObfuscateIntent))
|
||||
card.tooltip += "\nSurge: 8-10 damage. Harden: 6-8 Shield. Bypass: 3-4 damage ignoring Shield.\nDamage reveals this round's action, including hits absorbed by Shield. Hides again next round.";
|
||||
if (enemy.HasBehavior(EnemyBehaviorFlags.LeavesOrphan))
|
||||
card.tooltip += $"\n{CombatTuning.OrphanSpawnChancePercent}% chance to leave an orphan on permanent death.";
|
||||
card.Q<Label>(className: "process-behavior").text = EnemyProcessPresentation.Behavior(enemy);
|
||||
@@ -1098,6 +1131,8 @@ namespace KernelPanic.UI
|
||||
_turnResourceGrid.Add(PileStat("discard", _combatManager.DeckController.DiscardPile));
|
||||
_turnResourceGrid.Add(PileStat("exhaust", _combatManager.DeckController.ExhaustPile));
|
||||
_endTurnButton.SetEnabled(_combatManager.CanSurrenderRun && _combatManager.TutorialGuide?.CanEndTurn != false);
|
||||
_prefetchButton.style.display = _combatManager.RunConfig?.IsTutorial == true ? DisplayStyle.None : DisplayStyle.Flex;
|
||||
_prefetchButton.SetEnabled(_combatManager.CanPrefetch);
|
||||
RefreshSurrenderCommand();
|
||||
}
|
||||
|
||||
@@ -1262,6 +1297,7 @@ namespace KernelPanic.UI
|
||||
_overlay.Clear();
|
||||
if (_combatManager.RunFinished)
|
||||
{
|
||||
_routeSelectionOpen = false;
|
||||
SettleRunRewardsIfNeeded();
|
||||
_overlay.style.display = DisplayStyle.Flex;
|
||||
_overlay.Add(BuildRunEndOverlay());
|
||||
@@ -1280,11 +1316,12 @@ namespace KernelPanic.UI
|
||||
}
|
||||
|
||||
_overlay.style.display = DisplayStyle.Flex;
|
||||
_overlay.Add(BuildRepositoryView());
|
||||
_overlay.Add(_routeSelectionOpen ? BuildRouteSelectionView() : BuildRepositoryView());
|
||||
if (!wasVisible) _overlay.Q<Button>()?.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
_routeSelectionOpen = false;
|
||||
_overlay.style.display = DisplayStyle.None;
|
||||
}
|
||||
|
||||
@@ -1428,7 +1465,6 @@ namespace KernelPanic.UI
|
||||
ScrollView body = new(ScrollViewMode.Vertical);
|
||||
body.AddToClassList("repository-body");
|
||||
body.AddToClassList("screen-frame-content");
|
||||
if (_runManager.Journey.campaign) body.Add(RunRouteView.Build(_runManager, _combatManager));
|
||||
|
||||
VisualElement offers = new();
|
||||
offers.AddToClassList("repository-offers");
|
||||
@@ -1462,11 +1498,14 @@ namespace KernelPanic.UI
|
||||
reroll.SetEnabled(_runManager.Bits >= _runManager.RerollCost);
|
||||
footer.Add(reroll);
|
||||
|
||||
Button leave = new(() => _combatManager.ContinueToNextWave()) { text = "> boot next-wave" };
|
||||
Button leave = new(() =>
|
||||
{
|
||||
if (_runManager.Journey.campaign) SetRouteSelectionOpen(true);
|
||||
else _combatManager.ContinueToNextWave();
|
||||
}) { name = "BootNextWaveButton", text = "> boot next-wave" };
|
||||
leave.AddToClassList("primary-action");
|
||||
leave.AddToClassList("repository-leave-action");
|
||||
leave.SetEnabled(!_runManager.CampaignChoicePending);
|
||||
if (_runManager.CampaignChoicePending) leave.text = "Choose finish or endless above";
|
||||
leave.SetEnabled(!_runManager.IsSuspended);
|
||||
VisualElement leaveBlock = new();
|
||||
leaveBlock.AddToClassList("repository-leave-block");
|
||||
leaveBlock.Add(leave);
|
||||
@@ -1486,11 +1525,70 @@ namespace KernelPanic.UI
|
||||
return repo;
|
||||
}
|
||||
|
||||
private void SetRouteSelectionOpen(bool open)
|
||||
{
|
||||
_routeSelectionOpen = open;
|
||||
RefreshOverlay();
|
||||
_overlay.Q<Button>(open ? "BackToRepositoryButton" : "BootNextWaveButton")?.Focus();
|
||||
}
|
||||
|
||||
private VisualElement BuildRouteSelectionView()
|
||||
{
|
||||
var screen = new VisualElement { name = "RouteSelectionScreen" };
|
||||
screen.AddToClassList("repository");
|
||||
screen.AddToClassList("screen-frame");
|
||||
var header = new VisualElement();
|
||||
header.AddToClassList("repository-header");
|
||||
header.AddToClassList("screen-frame-header");
|
||||
var copy = new VisualElement();
|
||||
copy.AddToClassList("repository-header-copy");
|
||||
var title = new Label(_runManager.CampaignChoicePending ? "campaign complete" : "choose your route");
|
||||
title.AddToClassList("screen-frame-title");
|
||||
copy.Add(title);
|
||||
var subtitle = new Label(_runManager.CampaignChoicePending
|
||||
? "bank your rewards or continue into endless"
|
||||
: $"preparing wave {_runManager.CurrentWaveNumber} / {_runManager.Bits} bits remaining");
|
||||
subtitle.AddToClassList("repository-subtitle");
|
||||
copy.Add(subtitle);
|
||||
header.Add(copy);
|
||||
screen.Add(header);
|
||||
|
||||
var body = new ScrollView(ScrollViewMode.Vertical);
|
||||
body.AddToClassList("repository-body");
|
||||
body.AddToClassList("screen-frame-content");
|
||||
body.Add(RunRouteView.Build(_runManager, _combatManager));
|
||||
screen.Add(body);
|
||||
|
||||
var footer = new VisualElement();
|
||||
footer.AddToClassList("screen-frame-footer");
|
||||
footer.style.flexDirection = FlexDirection.Column;
|
||||
footer.style.alignItems = Align.Stretch;
|
||||
var back = new Button(() => SetRouteSelectionOpen(false))
|
||||
{ name = "BackToRepositoryButton", text = "< back to repository" };
|
||||
back.AddToClassList("primary-action");
|
||||
footer.Add(back);
|
||||
if (!_runManager.CampaignChoicePending)
|
||||
{
|
||||
var confirm = new Button(() => _combatManager.ContinueToNextWave())
|
||||
{
|
||||
name = "ConfirmRouteButton",
|
||||
text = _runManager.BuildRewardPending ? "choose a build reward to continue" : "> depart / boot next-wave"
|
||||
};
|
||||
confirm.AddToClassList("primary-action");
|
||||
confirm.SetEnabled(!_runManager.BuildRewardPending && !_runManager.IsSuspended);
|
||||
footer.Add(confirm);
|
||||
}
|
||||
screen.Add(footer);
|
||||
return screen;
|
||||
}
|
||||
|
||||
private void SaveAndExitRun()
|
||||
{
|
||||
if (_runManager.IsSuspended || !_combatManager.AwaitingWaveContinue) return;
|
||||
try
|
||||
{
|
||||
if (_dailyQuestTracker?.Flush() == false)
|
||||
throw new IOException("Daily quest progress: " + _dailyQuestTracker.SaveError);
|
||||
RunCheckpointService.SaveAndSuspend(_saveService, _runManager, _combatManager);
|
||||
_checkpointError = null;
|
||||
_overlay.SetEnabled(false);
|
||||
@@ -3517,7 +3615,7 @@ namespace KernelPanic.UI
|
||||
{
|
||||
return intent.Kind switch
|
||||
{
|
||||
EnemyIntentKind.Attack => "attack",
|
||||
EnemyIntentKind.Attack => intent.TrueDamage ? "bypasses Shield" : "attack",
|
||||
EnemyIntentKind.StatusAttack => $"{intent.DisplayLabel} x{intent.StatusStacks}",
|
||||
EnemyIntentKind.Defend => "defend",
|
||||
EnemyIntentKind.Buff => "buff",
|
||||
|
||||
@@ -28,7 +28,9 @@ namespace KernelPanic.UI
|
||||
return $"Growing attack / {enemy.TurnsAlive} turns survived";
|
||||
if (enemy.HasBehavior(EnemyBehaviorFlags.Countdown)) return $"Countdown: {enemy.CountdownRemaining}";
|
||||
if (enemy.HasBehavior(EnemyBehaviorFlags.DefendAllies)) return "Shields self and adjacent processes";
|
||||
if (enemy.HasBehavior(EnemyBehaviorFlags.ObfuscateIntent)) return enemy.IntentRevealed ? "Intent exposed" : "Intent hidden until damaged";
|
||||
if (enemy.HasBehavior(EnemyBehaviorFlags.ObfuscateIntent)) return enemy.IntentRevealed
|
||||
? "Exposed this round / hides next round"
|
||||
: "Hit to reveal / surge, Shield or bypass";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace KernelPanic.UI
|
||||
private readonly Label _title = new();
|
||||
private readonly Label _instruction = new();
|
||||
private readonly Label _receipt = new();
|
||||
private readonly VisualElement _resources = new();
|
||||
private readonly Foldout _tracks = new() { text = "Resources & turn order", value = false };
|
||||
private readonly Button _action;
|
||||
private readonly Button _skip;
|
||||
private RunConfig _config;
|
||||
@@ -36,12 +38,18 @@ namespace KernelPanic.UI
|
||||
header.AddToClassList("guide-header");
|
||||
header.Add(_title);
|
||||
Element.Add(header);
|
||||
_resources.AddToClassList("guide-resources");
|
||||
foreach (string text in new[] { "Uptime\nHealth", "Shield\nProtection", "Cycles\nCard budget", "RAM\nHand space" })
|
||||
{
|
||||
var chip = new Label(text); chip.AddToClassList("guide-resource"); _resources.Add(chip);
|
||||
}
|
||||
Element.Add(_instruction);
|
||||
Element.Add(_receipt);
|
||||
Element.Add(_tracks);
|
||||
var actions = new VisualElement();
|
||||
actions.AddToClassList("guide-actions");
|
||||
_action = new Button(Advance) { text = "Ready: play a card" };
|
||||
_skip = new Button(Dismiss) { text = "Skip guide" };
|
||||
_action = new Button(Advance) { text = "Try a card" };
|
||||
_skip = new Button(Dismiss) { text = "Close guide" };
|
||||
actions.Add(_action);
|
||||
actions.Add(_skip);
|
||||
header.Add(actions);
|
||||
@@ -57,9 +65,18 @@ namespace KernelPanic.UI
|
||||
Element.style.display = DisplayStyle.Flex;
|
||||
_action.style.display = DisplayStyle.Flex;
|
||||
_skip.style.display = DisplayStyle.Flex;
|
||||
_action.text = "Ready: play a card";
|
||||
_title.text = "First battle / 1 of 4 / read the process table";
|
||||
_instruction.text = "Uptime = health; Cycles = card budget; RAM = hand capacity. Read enemy intents, then select a card and its target. " + TrackLesson(config);
|
||||
_action.text = "Try a card";
|
||||
_resources.style.display = DisplayStyle.Flex;
|
||||
_tracks.Clear(); _tracks.value = false;
|
||||
_tracks.Add(_resources);
|
||||
AddTrack("NOW / Native", "Executes when played.");
|
||||
if (config?.PrimaryLanguage == Language.Python || config?.SecondaryLanguage == Language.Python)
|
||||
AddTrack("1 / Python queue", "End turn: oldest first.");
|
||||
if (config?.PrimaryLanguage == Language.Haskell || config?.SecondaryLanguage == Language.Haskell)
|
||||
AddTrack("2 / Haskell stack", "After the queue: newest first. Entry multiplier scales damage and Shield.");
|
||||
AddTrack("LAST / Enemies", "Surviving enemies carry out their intents.");
|
||||
_title.text = "1 / Read the battlefield";
|
||||
_instruction.text = "Check enemy intents before you spend your Cycles.";
|
||||
}
|
||||
|
||||
public void Advance()
|
||||
@@ -68,8 +85,8 @@ namespace KernelPanic.UI
|
||||
if (_completed) { Dismiss(); return; }
|
||||
_started = true;
|
||||
_action.style.display = DisplayStyle.None;
|
||||
_title.text = "First battle / 2 of 4 / dispatch a card";
|
||||
_instruction.text = "Play any affordable card. Targeted cards need a living process selected. The preview explains its current effect. " + TrackLesson(_config);
|
||||
_title.text = "2 / Play a card";
|
||||
_instruction.text = "Select an affordable card, then its enemy target if needed. Check the preview before dispatching.";
|
||||
}
|
||||
|
||||
public void CardPlayed(ResolutionTrack track, string name)
|
||||
@@ -77,14 +94,14 @@ namespace KernelPanic.UI
|
||||
if (!Visible || _completed) return;
|
||||
_played = _started = true;
|
||||
_action.style.display = DisplayStyle.None;
|
||||
_title.text = "First battle / 3 of 4 / finish your turn";
|
||||
_title.text = "3 / End turn";
|
||||
_receipt.text = track switch
|
||||
{
|
||||
ResolutionTrack.InterpreterQueue => name + " entered the queue. It waits until end turn; the oldest queued card resolves first.",
|
||||
ResolutionTrack.LazyStack => name + " entered the stack. It waits until after the queue; the newest stacked card resolves first.",
|
||||
_ => name + " executes immediately on the Native track."
|
||||
ResolutionTrack.InterpreterQueue => name + " queued / oldest first.",
|
||||
ResolutionTrack.LazyStack => name + " stacked / newest first.",
|
||||
_ => name + " / executes now."
|
||||
};
|
||||
_instruction.text = "Play more cards if you have Cycles, then choose [E] end turn. Watch the scheduler: queue first, stack second, then enemies act. Shield helps absorb incoming damage.";
|
||||
_instruction.text = "Spend any remaining Cycles, then press [E] End turn. Shield absorbs incoming damage.";
|
||||
}
|
||||
|
||||
public void CardResolved(string name, ResolutionTrack track)
|
||||
@@ -99,7 +116,7 @@ namespace KernelPanic.UI
|
||||
if (phase == TurnPhase.Interpret)
|
||||
{
|
||||
_endedTurn = true;
|
||||
_instruction.text = "Resolving: queued cards execute oldest first, then stacked cards execute newest first. Enemy actions follow. You can inspect the journal for the result of each operation.";
|
||||
_instruction.text = "Queue: oldest first → Stack: newest first → Enemies.";
|
||||
}
|
||||
if (phase == TurnPhase.Execute && _endedTurn) Complete(false);
|
||||
}
|
||||
@@ -113,11 +130,13 @@ namespace KernelPanic.UI
|
||||
private void Complete(bool waveCleared)
|
||||
{
|
||||
_completed = true;
|
||||
_title.text = "First battle / 4 of 4 / plan the next round";
|
||||
_title.text = waveCleared ? "4 / Wave cleared" : "4 / Reassess";
|
||||
_instruction.text = waveCleared
|
||||
? "Wave cleared! Spend Bits in the repository on cards, upgrades or healing, then continue. Cleared waves earn rewards that are banked when the run ends."
|
||||
: "Check Uptime, Shield and the next enemy intents before your next move. Each completed round refreshes your turn resources. " + (_config?.Distro?.Id == "gentoo" ? "Gentoo's Compilation advances after a completed round, improving damage (and Shield at higher versions), and resets each wave. " : "") + "You can reopen this with '? guide' in dispatch.";
|
||||
if (!_played && _started) _receipt.text = "You can also end a turn without playing a card; the same execution order applies.";
|
||||
? "Spend Bits in the repository on cards, upgrades or healing. Then continue your run."
|
||||
: "Check your Uptime, Shield and next enemy intents. Your turn resources have refreshed.";
|
||||
_receipt.text = _config?.Distro?.Id == "gentoo" && !waveCleared
|
||||
? "Compilation grew this round; it resets each wave."
|
||||
: !_played && _started ? "Ending a turn without playing a card is allowed." : "Reopen anytime with ? guide.";
|
||||
_action.text = "Got it";
|
||||
_action.style.display = DisplayStyle.Flex;
|
||||
_skip.style.display = DisplayStyle.None;
|
||||
@@ -129,6 +148,14 @@ namespace KernelPanic.UI
|
||||
_remember();
|
||||
}
|
||||
|
||||
private void AddTrack(string title, string copy)
|
||||
{
|
||||
var row = new VisualElement(); row.AddToClassList("guide-track");
|
||||
var heading = new Label(title); heading.AddToClassList("guide-title"); row.Add(heading);
|
||||
var detail = new Label(copy); detail.AddToClassList("guide-copy"); row.Add(detail);
|
||||
_tracks.Add(row);
|
||||
}
|
||||
|
||||
public static string TrackLesson(RunConfig config)
|
||||
{
|
||||
string lesson = "Native cards execute now.";
|
||||
|
||||
@@ -158,6 +158,10 @@ namespace KernelPanic.UI
|
||||
private bool _loadingMetaState;
|
||||
private VisualElement _saveRecoveryOverlay;
|
||||
private VisualElement _runHistoryOverlay;
|
||||
private VisualElement _dailyQuestOverlay;
|
||||
private bool _dailyQuestReturnToPrompt;
|
||||
private VisualElement _dailyQuestPreviousFocus;
|
||||
private bool _dailyQuestOpenedWithPointer;
|
||||
private EntropyWallet _wallet;
|
||||
private GachaService _gachaService;
|
||||
private PlayerCollection _playerCollection;
|
||||
@@ -185,6 +189,7 @@ namespace KernelPanic.UI
|
||||
private Action _rootCreditExchangePlusHundredClicked;
|
||||
private IVisualElementScheduledItem _blinkSchedule;
|
||||
private IVisualElementScheduledItem _bootIntroSchedule;
|
||||
private IVisualElementScheduledItem _dailyQuestSchedule;
|
||||
private TerminalCommandLine _commandLine;
|
||||
private MenuScreen _activeScreen = MenuScreen.Main;
|
||||
|
||||
@@ -202,7 +207,7 @@ namespace KernelPanic.UI
|
||||
LoadSharedStyles();
|
||||
BindCommandEntries();
|
||||
TerminalTheme.Attach(_root);
|
||||
_commandLine = new TerminalCommandLine(_root, ActivateCommand, () => _activeScreen == MenuScreen.Main && !starterSelection.IsActive && !_rootCreditExchangeOpen && _runHistoryOverlay == null && !CheckpointModalOpen && !_runLaunchPending && !PersistenceBlocked);
|
||||
_commandLine = new TerminalCommandLine(_root, ActivateCommand, () => _activeScreen == MenuScreen.Main && !starterSelection.IsActive && !_rootCreditExchangeOpen && _runHistoryOverlay == null && _dailyQuestOverlay == null && !CheckpointModalOpen && !_runLaunchPending && !PersistenceBlocked);
|
||||
BindPreferences();
|
||||
RegisterCommandEntryCallbacks();
|
||||
BindScreenFrames();
|
||||
@@ -235,6 +240,12 @@ namespace KernelPanic.UI
|
||||
});
|
||||
Button textSize = _root.Q<Button>("TextSizeButton");
|
||||
Button density = _root.Q<Button>("DensityButton");
|
||||
_root.Q<Button>("SoundVolumeButton").clicked += () =>
|
||||
{
|
||||
UIPreferences.SoundVolume = (UIPreferences.SoundVolume / 25 + 1) % 5 * 25;
|
||||
UIPreferences.Save();
|
||||
RefreshPreferenceControls();
|
||||
};
|
||||
textSize.clicked += () =>
|
||||
{
|
||||
UIPreferences.TextSize = UIPreferences.TextSize == UITextSize.Standard ? UITextSize.Large : UITextSize.Standard;
|
||||
@@ -257,6 +268,7 @@ namespace KernelPanic.UI
|
||||
motion.text = UIPreferences.ReducedMotion ? "[ true ]" : "[ false ]";
|
||||
_root.Q<Button>("TextSizeButton").text = UIPreferences.TextSize == UITextSize.Large ? "[ large ]" : "[ standard ]";
|
||||
_root.Q<Button>("DensityButton").text = UIPreferences.Density == UILayoutDensity.Comfortable ? "[ comfortable ]" : "[ compact ]";
|
||||
_root.Q<Button>("SoundVolumeButton").text = UIPreferences.SoundVolume == 0 ? "[ muted ]" : $"[ {UIPreferences.SoundVolume}% ]";
|
||||
}
|
||||
|
||||
private void ComposeMetaServices()
|
||||
@@ -294,6 +306,8 @@ namespace KernelPanic.UI
|
||||
|
||||
StartAmbientSchedules();
|
||||
PlayBootIntroIfNeeded();
|
||||
RefreshDailyQuestPanel();
|
||||
_dailyQuestSchedule = _root.schedule.Execute(TickDailyQuests).Every(1000);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
@@ -302,6 +316,7 @@ namespace KernelPanic.UI
|
||||
_blinkSchedule?.Pause();
|
||||
_backgroundLog?.Stop();
|
||||
_bootIntroSchedule?.Pause();
|
||||
_dailyQuestSchedule?.Pause();
|
||||
starterSelection.PauseSchedules();
|
||||
}
|
||||
|
||||
@@ -797,8 +812,109 @@ namespace KernelPanic.UI
|
||||
_loadingMetaState = false;
|
||||
}
|
||||
|
||||
DailyQuests.Refresh(_saveData.dailyQuests, DateTime.UtcNow);
|
||||
SaveCurrentState();
|
||||
RefreshRunActions();
|
||||
RefreshDailyQuestPanel();
|
||||
}
|
||||
|
||||
private void RefreshDailyQuestPanel()
|
||||
{
|
||||
var host = _root?.Q("DailyQuestsHost");
|
||||
if (host == null || _saveData == null) return;
|
||||
TerminalTheme.PreserveFocus(host);
|
||||
host.Clear();
|
||||
var widget = DailyQuestView.BuildWidget(_saveData.dailyQuests, DateTime.UtcNow, () => OpenDailyQuestDetails());
|
||||
// Mouse focus is incidental; only keyboard activation should restore the widget's focus ring.
|
||||
widget.RegisterCallback<PointerDownEvent>(_ => _dailyQuestOpenedWithPointer = true, TrickleDown.TrickleDown);
|
||||
widget.RegisterCallback<KeyDownEvent>(_ => _dailyQuestOpenedWithPointer = false, TrickleDown.TrickleDown);
|
||||
widget.RegisterCallback<NavigationSubmitEvent>(_ => _dailyQuestOpenedWithPointer = false, TrickleDown.TrickleDown);
|
||||
host.Add(widget);
|
||||
if (_dailyQuestOverlay != null)
|
||||
{
|
||||
var scroll = _dailyQuestOverlay.Q<ScrollView>("DailyQuestDetailScroll");
|
||||
var offset = scroll.scrollOffset;
|
||||
var focused = _root.focusController?.focusedElement as VisualElement;
|
||||
bool restoreFocus = focused != null && _dailyQuestOverlay.Contains(focused);
|
||||
string name = focused?.name;
|
||||
scroll.Clear();
|
||||
scroll.Add(DailyQuestView.Build(_saveData.dailyQuests, DateTime.UtcNow, ClaimDailyQuest));
|
||||
DailyQuestView.RefreshHeader(_dailyQuestOverlay, _saveData.dailyQuests, DateTime.UtcNow);
|
||||
scroll.scrollOffset = offset;
|
||||
if (restoreFocus)
|
||||
{
|
||||
var replacement = string.IsNullOrEmpty(name) ? null : _dailyQuestOverlay.Q<Button>(name);
|
||||
if (replacement?.enabledInHierarchy != true)
|
||||
replacement = _dailyQuestOverlay.Q<Button>("CloseDailyQuests");
|
||||
replacement?.Focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenDailyQuestDetails()
|
||||
{
|
||||
if (PersistenceBlocked || _runLaunchPending || _dailyQuestOverlay != null || _activeScreen != MenuScreen.Main
|
||||
|| starterSelection.IsActive || _rootCreditExchangeOpen || _runHistoryOverlay != null || CheckpointModalOpen) return;
|
||||
_dailyQuestPreviousFocus = _root.focusController?.focusedElement as VisualElement;
|
||||
TickDailyQuests();
|
||||
if (PersistenceBlocked) return;
|
||||
_dailyQuestReturnToPrompt = false;
|
||||
_dailyQuestOverlay = DailyQuestView.BuildOverlay(_saveData.dailyQuests, DateTime.UtcNow, ClaimDailyQuest, CloseDailyQuestDetails);
|
||||
_root.Add(_dailyQuestOverlay);
|
||||
_shellRoot?.SetEnabled(false);
|
||||
_dailyQuestOverlay.Query<Button>().Where(button => button.enabledInHierarchy).First()?.Focus();
|
||||
}
|
||||
|
||||
private void CloseDailyQuestDetails()
|
||||
{
|
||||
_dailyQuestOverlay?.RemoveFromHierarchy();
|
||||
_dailyQuestOverlay = null;
|
||||
_shellRoot?.SetEnabled(!PersistenceBlocked);
|
||||
if (_dailyQuestReturnToPrompt) _commandLine?.Focus();
|
||||
else if (_dailyQuestOpenedWithPointer) (_root?.Q("Root") ?? _root)?.Focus();
|
||||
else if (_dailyQuestPreviousFocus?.panel != null && _dailyQuestPreviousFocus.enabledInHierarchy)
|
||||
_dailyQuestPreviousFocus.Focus();
|
||||
else _root?.Q<Button>("DailyQuestWidget")?.Focus();
|
||||
_dailyQuestPreviousFocus = null;
|
||||
_dailyQuestOpenedWithPointer = false;
|
||||
}
|
||||
|
||||
private void TickDailyQuests()
|
||||
{
|
||||
if (_saveData == null || PersistenceBlocked || _runLaunchPending) return;
|
||||
var now = DateTime.UtcNow;
|
||||
if (DailyQuests.Refresh(_saveData.dailyQuests, now))
|
||||
{
|
||||
var feedback = _dailyQuestOverlay?.Q<Label>("DailyQuestFeedback");
|
||||
if (feedback != null) feedback.style.display = DisplayStyle.None;
|
||||
SaveCurrentState();
|
||||
RefreshDailyQuestPanel();
|
||||
}
|
||||
var countdown = _root?.Q<Label>("DailyQuestCountdown");
|
||||
if (countdown != null) countdown.text = DailyQuests.Countdown(_saveData.dailyQuests, now);
|
||||
if (_dailyQuestOverlay != null) DailyQuestView.RefreshHeader(_dailyQuestOverlay, _saveData.dailyQuests, now);
|
||||
}
|
||||
|
||||
private void ClaimDailyQuest(DailyQuestKind kind, long period)
|
||||
{
|
||||
if (PersistenceBlocked || _runLaunchPending) return;
|
||||
bool claimed = DailyQuests.Claim(_saveData, kind, period, DateTime.UtcNow);
|
||||
if (claimed)
|
||||
_wallet.SetBalance(_saveData.entropyBalance);
|
||||
// Balances and the claim bit are committed in the same atomic save.
|
||||
// On failure the existing recovery dialog blocks spending until retry succeeds.
|
||||
SaveCurrentState();
|
||||
RefreshDailyQuestPanel();
|
||||
RefreshCurrencyReadouts();
|
||||
gachaScreen.Refresh();
|
||||
var feedback = _dailyQuestOverlay?.Q<Label>("DailyQuestFeedback");
|
||||
if (feedback != null && claimed && !PersistenceBlocked)
|
||||
{
|
||||
var reward = DailyQuests.Reward(kind);
|
||||
feedback.text = $"[ OK ] Daily task completed.\n[ OK ] +{reward.Bandwidth} Bandwidth, +{reward.Entropy} Entropy deposited.";
|
||||
feedback.style.display = DisplayStyle.Flex;
|
||||
}
|
||||
else if (feedback != null && PersistenceBlocked) feedback.style.display = DisplayStyle.None;
|
||||
}
|
||||
|
||||
private bool PersistenceBlocked => _saveLoadFailed || _saveWriteFailed;
|
||||
@@ -850,7 +966,7 @@ namespace KernelPanic.UI
|
||||
{
|
||||
_saveRecoveryOverlay?.RemoveFromHierarchy();
|
||||
_saveRecoveryOverlay = null;
|
||||
_shellRoot?.SetEnabled(true);
|
||||
_shellRoot?.SetEnabled(_dailyQuestOverlay == null);
|
||||
_root.Q("StarterModal")?.SetEnabled(true);
|
||||
_rootCreditExchangeModal?.SetEnabled(true);
|
||||
}
|
||||
@@ -970,12 +1086,13 @@ namespace KernelPanic.UI
|
||||
if (_saveData.tutorialCheckpoint != null)
|
||||
{
|
||||
var checkpoint = _saveData.tutorialCheckpoint;
|
||||
RunCheckpoint.Require(checkpoint.wave == 2 && checkpoint.wavesCleared == 1
|
||||
RunCheckpoint.Require(checkpoint.wave >= 2 && checkpoint.wave <= TutorialCampaign.LessonCount
|
||||
&& checkpoint.wavesCleared == checkpoint.wave - 1
|
||||
&& checkpoint.journey?.campaign == false && checkpoint.packages?.Count == 0
|
||||
&& checkpoint.offers?.Exists(offer => offer != null && offer.sold) == true,
|
||||
"Training checkpoint is not a purchased first-wave shop.");
|
||||
&& (checkpoint.wave > 2 || checkpoint.offers?.Exists(offer => offer != null && offer.sold) == true),
|
||||
"Training checkpoint is not a completed lesson boundary.");
|
||||
var resume = _saveData.tutorialCheckpoint.Resolve(distroDatabase, cardDatabase, languageDeckDatabase, packageDatabase);
|
||||
resume.Config.TutorialLesson = 2;
|
||||
resume.Config.TutorialLesson = TutorialCampaign.Lesson(_saveData);
|
||||
RunContext.SetResume(resume);
|
||||
}
|
||||
else RunContext.SetTutorial(TutorialCampaign.CreateConfig(distro, cardDatabase, 1));
|
||||
@@ -1365,7 +1482,16 @@ namespace KernelPanic.UI
|
||||
int index = i;
|
||||
_commandEntries[i].Row.focusable = true;
|
||||
_commandEntries[i].Row.RegisterCallback<FocusInEvent>(_ => SelectCommand(index));
|
||||
_commandEntries[i].Row.RegisterCallback<PointerEnterEvent>(_ => SelectCommand(index));
|
||||
_commandEntries[i].Row.RegisterCallback<PointerEnterEvent>(_ =>
|
||||
{
|
||||
SelectCommand(index);
|
||||
// Hover selects a primary command; Enter must no longer target the side widget.
|
||||
if (_dailyQuestOverlay == null && _root.focusController?.focusedElement == _root.Q<Button>("DailyQuestWidget"))
|
||||
{
|
||||
_root.Q<Button>("DailyQuestWidget").Blur();
|
||||
(_root.Q("Root") ?? _root).Focus();
|
||||
}
|
||||
});
|
||||
_commandEntries[i].Row.RegisterCallback<ClickEvent>(_ => HandleCommandClicked(index));
|
||||
}
|
||||
}
|
||||
@@ -1515,6 +1641,12 @@ namespace KernelPanic.UI
|
||||
return;
|
||||
}
|
||||
if (PersistenceBlocked) return;
|
||||
if (_dailyQuestOverlay != null)
|
||||
{
|
||||
if (evt.keyCode == KeyCode.Escape) CloseDailyQuestDetails();
|
||||
evt.StopPropagation();
|
||||
return;
|
||||
}
|
||||
if (_runHistoryOverlay != null)
|
||||
{
|
||||
if (evt.keyCode == KeyCode.Escape) CloseRunHistory();
|
||||
@@ -1670,6 +1802,8 @@ namespace KernelPanic.UI
|
||||
if (evt.keyCode == KeyCode.UpArrow)
|
||||
{
|
||||
SelectCommand(_selectedCommandIndex - 1);
|
||||
_commandEntries[_selectedCommandIndex].Row.Focus();
|
||||
_root.panel?.focusController.IgnoreEvent(evt);
|
||||
evt.StopPropagation();
|
||||
return;
|
||||
}
|
||||
@@ -1677,6 +1811,8 @@ namespace KernelPanic.UI
|
||||
if (evt.keyCode == KeyCode.DownArrow)
|
||||
{
|
||||
SelectCommand(_selectedCommandIndex + 1);
|
||||
_commandEntries[_selectedCommandIndex].Row.Focus();
|
||||
_root.panel?.focusController.IgnoreEvent(evt);
|
||||
evt.StopPropagation();
|
||||
return;
|
||||
}
|
||||
@@ -2355,6 +2491,14 @@ namespace KernelPanic.UI
|
||||
{
|
||||
if (PersistenceBlocked) return;
|
||||
_commandLine.Echo(index);
|
||||
// Prompt-only alias; the six primary navigation commands retain their indices.
|
||||
if (index == 6)
|
||||
{
|
||||
_dailyQuestOpenedWithPointer = false;
|
||||
OpenDailyQuestDetails();
|
||||
_dailyQuestReturnToPrompt = true;
|
||||
return;
|
||||
}
|
||||
_commandEntries[index].Activate();
|
||||
_root.Focus();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using KernelPanic.Combat;
|
||||
using KernelPanic.Run;
|
||||
using UnityEngine.UIElements;
|
||||
@@ -10,9 +11,40 @@ namespace KernelPanic.UI
|
||||
{
|
||||
public static VisualElement Build(RunManager run, CombatManager combat)
|
||||
{
|
||||
var section = TerminalLayout.Section(run.CampaignChoicePending ? "KERNEL SECURED" : "Next route", "RunRouteChoices");
|
||||
var section = TerminalLayout.Section(run.CampaignChoicePending ? "KERNEL SECURED" : "Route", "RunRouteChoices");
|
||||
section.AddToClassList("run-route-section");
|
||||
if (!string.IsNullOrEmpty(run.Journey.lastReward)) section.Add(TerminalLayout.BodyText(run.Journey.lastReward));
|
||||
if (run.BuildRewardPending)
|
||||
{
|
||||
section.Add(TerminalLayout.BodyText("Build reward / choose one before departure. Upgrade a card for this run, or take Bits to spend freely."));
|
||||
var cards = run.RunDeck.Where(card => card.Definition != null && !card.Definition.IsToken && !card.Definition.IsJunk).ToList();
|
||||
if (cards.Count > 0)
|
||||
{
|
||||
int selected = 0;
|
||||
var target = TerminalLayout.BodyText("", "BuildRewardTarget");
|
||||
section.Add(target);
|
||||
var navigation = new VisualElement();
|
||||
navigation.AddToClassList("reward-target-navigation");
|
||||
section.Add(navigation);
|
||||
section.Add(Action($"Upgrade effect +{CombatTuning.UpgradeMagnitudeBonus}", "RewardMagnitude",
|
||||
() => run.ClaimBuildReward(cards[selected], CardUpgradeKind.MagnitudeUp)));
|
||||
var draw = Action("Add draw 1 on resolution", "RewardDraw",
|
||||
() => run.ClaimBuildReward(cards[selected], CardUpgradeKind.DrawRider));
|
||||
void Select(int offset)
|
||||
{
|
||||
selected = (selected + offset + cards.Count) % cards.Count;
|
||||
var card = cards[selected];
|
||||
target.text = $"Target {selected + 1}/{cards.Count}: {card.Definition.DisplayName}\n+{card.MagnitudeBonus} effect / +{card.DrawRider} draw";
|
||||
draw.SetEnabled(card.DrawRider == 0);
|
||||
}
|
||||
navigation.Add(Action("Previous card", "RewardPrevious", () => Select(-1)));
|
||||
navigation.Add(Action("Next card", "RewardNext", () => Select(1)));
|
||||
Select(0);
|
||||
section.Add(draw);
|
||||
}
|
||||
section.Add(Action($"Take {RunManager.BuildRewardBits} Bits", "RewardBits",
|
||||
() => run.ClaimBuildReward(null, CardUpgradeKind.MagnitudeUp, true)));
|
||||
}
|
||||
if (run.CampaignChoicePending)
|
||||
{
|
||||
section.Add(TerminalLayout.BodyText("Five waves cleared. Finish this campaign and bank your rewards, or keep this build running in endless mode. Rewards are saved when the run ends."));
|
||||
@@ -20,17 +52,17 @@ namespace KernelPanic.UI
|
||||
section.Add(Action("Continue into endless", "ContinueEndlessButton", () => combat.ContinueEndless()));
|
||||
return section;
|
||||
}
|
||||
var plan = EncounterDirector.Plan(run.CurrentWaveNumber, run.Journey.selectedRoute);
|
||||
section.Add(TerminalLayout.BodyText($"Wave {run.CurrentWaveNumber}: {plan.Title}"));
|
||||
section.Add(TerminalLayout.BodyText(plan.Advice));
|
||||
var plan = EncounterDirector.Plan(run.CurrentWaveNumber, run.Journey.selectedRoute,
|
||||
run.CurrentConfig.RunSeed, run.Journey.encounterRevision);
|
||||
var choices = new VisualElement();
|
||||
choices.AddToClassList("route-choices");
|
||||
AddChoice(choices, run, WaveRoute.Repair, "Repair stop",
|
||||
$"Restore up to {RunJourney.RepairUptime} Uptime on departure. Fight the standard encounter.");
|
||||
AddChoice(choices, run, WaveRoute.Challenge, "Elite detour",
|
||||
$"An extra elite Daemon joins the encounter. On clear: +{RunJourney.ChallengeBits} Bits and +1 draw on the first eligible deck card without a draw rider; +{RunJourney.ChallengeBits} extra Bits if none qualify.");
|
||||
$"Extra Daemon. On clear: +{RunJourney.ChallengeBits} Bits and +1 draw on the first card without a draw rider (or +{RunJourney.ChallengeBits} Bits if none)."
|
||||
+ (run.Journey.selectedRoute == WaveRoute.Challenge
|
||||
? $"\nElite: {(plan.EscortShield > 0 ? $"+{plan.EscortShield} Shield" : plan.EscortUptime > 0 ? $"+{plan.EscortUptime} Uptime" : "hidden intent")}." : ""));
|
||||
section.Add(choices);
|
||||
section.Add(TerminalLayout.BodyText("Choose freely before booting. Repairs and difficulty apply only when you leave; the elite reward requires clearing the wave."));
|
||||
return section;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@ namespace KernelPanic.UI
|
||||
{
|
||||
internal static readonly string[] Commands =
|
||||
{
|
||||
"./start_run", "ls ~/collection", "curl gacha.sh | sh", "dpkg-reconfigure", "history --runs", "shutdown -h now"
|
||||
"./start_run", "ls ~/collection", "curl gacha.sh | sh", "dpkg-reconfigure", "history --runs", "shutdown -h now",
|
||||
"cat /etc/cron.daily/quests"
|
||||
};
|
||||
private readonly List<string> _history = new();
|
||||
private readonly TextField _input;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace KernelPanic.UI
|
||||
{
|
||||
_overlay = overlay; _run = run; _combat = combat; _cards = cards; _languages = languages;
|
||||
_save = save; _lesson = config.TutorialLesson; _returnToMenu = returnToMenu;
|
||||
_resuming = _lesson == 2;
|
||||
_resuming = _lesson > 1;
|
||||
SetGuide(_lesson);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace KernelPanic.UI
|
||||
{
|
||||
if (!_resuming) return;
|
||||
_resuming = false;
|
||||
if (!_combat.ContinueTutorialWave()) throw new InvalidDataException("Training checkpoint is not a purchased first-wave shop.");
|
||||
if (!_combat.ContinueTutorialWave()) throw new InvalidDataException("Training checkpoint is not a completed lesson boundary.");
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
@@ -78,14 +78,15 @@ namespace KernelPanic.UI
|
||||
_overlay.Clear(); _overlay.style.display = DisplayStyle.None; _renderKey = null;
|
||||
return;
|
||||
}
|
||||
if (cleared && _lesson == 1 && !_run.RepositoryVisitActive)
|
||||
if (cleared && _lesson < TutorialCampaign.LessonCount && !_run.RepositoryVisitActive)
|
||||
_run.GenerateRepositoryOffers(_cards, _languages);
|
||||
bool purchased = _run.RepositoryOffers.Any(offer => offer.Sold);
|
||||
string key = $"{_lesson}:{cleared}:{lost}:{_shopStep}:{purchased}:{_error}";
|
||||
if (_renderKey == key) return;
|
||||
_renderKey = key;
|
||||
_overlay.Clear(); _overlay.AddToClassList("tutorial-overlay"); _overlay.style.display = DisplayStyle.Flex;
|
||||
var panel = TerminalLayout.Section(lost ? "Practice ended" : _lesson == 1 ? "Wave one cleared / repository" : "Training complete", "TutorialDialog");
|
||||
var panel = TerminalLayout.Section(lost ? "Practice ended" : _lesson == 1 ? "Wave one cleared / repository"
|
||||
: _lesson < TutorialCampaign.LessonCount ? "Wave two cleared" : "Training complete", "TutorialDialog");
|
||||
panel.AddToClassList("tutorial-dialog");
|
||||
var scroll = new ScrollView(ScrollViewMode.Vertical) { name = "TutorialCopy" };
|
||||
scroll.style.flexShrink = 1; scroll.style.minHeight = 0;
|
||||
@@ -93,7 +94,7 @@ namespace KernelPanic.UI
|
||||
Button action;
|
||||
if (lost)
|
||||
{
|
||||
scroll.Add(TerminalLayout.BodyText("Try again. Wave two restarts from your saved shop purchase; wave one restarts with full Uptime. Your collection is safe."));
|
||||
scroll.Add(TerminalLayout.BodyText("Retry this wave from its start. Your purchased upgrade is saved; your collection is safe."));
|
||||
action = new Button(RestartLesson) { text = "Retry training", name = "TutorialRetry" };
|
||||
}
|
||||
else if (_lesson == 1)
|
||||
@@ -102,7 +103,7 @@ namespace KernelPanic.UI
|
||||
if (_shopStep == 0)
|
||||
{
|
||||
bits.AddToClassList("tutorial-shop-highlight");
|
||||
scroll.Add(TerminalLayout.BodyText("Every enemy is gone. Between waves, the repository is your shop. Spend Bits earned in combat to improve this run; Bits are separate from your permanent currencies."));
|
||||
scroll.Add(TerminalLayout.BodyText("Spend combat Bits here to improve this run. Your permanent currencies are separate."));
|
||||
action = new Button(() => { _shopStep = 1; Redraw(); }) { text = "Show an upgrade", name = "TutorialShopNext" };
|
||||
}
|
||||
else
|
||||
@@ -118,15 +119,21 @@ namespace KernelPanic.UI
|
||||
{ text = purchased ? "Purchased" : $"Buy / {offer.Price} Bits", name = "TutorialBuy" };
|
||||
buy.SetEnabled(!purchased && _run.Bits >= offer.Price); item.Add(buy);
|
||||
scroll.Add(TerminalLayout.BodyText(purchased
|
||||
? "Upgrade installed. Your remaining Uptime, deck and purchase carry into wave two. Normal shops also sell new cards and stat upgrades."
|
||||
? "Upgrade installed. Your Uptime, deck and patch carry into wave two."
|
||||
: "Buy this upgrade to practice spending Bits. Then start the next wave."));
|
||||
action = new Button(Continue) { text = "Start wave two", name = "TutorialContinue" };
|
||||
action.SetEnabled(purchased);
|
||||
}
|
||||
}
|
||||
else if (_lesson < TutorialCampaign.LessonCount)
|
||||
{
|
||||
scroll.Add(TerminalLayout.BodyText("Queue and stack mastered. One last practice: Cron Job's countdown and a Daemon miniboss."));
|
||||
scroll.Add(TerminalLayout.BodyText("Continue to save your progress and restore full Uptime for the final practice."));
|
||||
action = new Button(Continue) { text = "Start wave three", name = "TutorialContinue" };
|
||||
}
|
||||
else
|
||||
{
|
||||
scroll.Add(TerminalLayout.BodyText("Both waves are clear. You have completed the combat → shop → combat loop."));
|
||||
scroll.Add(TerminalLayout.BodyText("All three waves cleared. You're ready for a campaign."));
|
||||
scroll.Add(TerminalLayout.Heading($"+{TutorialCampaign.BandwidthReward:N0} Bandwidth"));
|
||||
scroll.Add(TerminalLayout.Heading($"+{TutorialCampaign.EntropyReward:N0} Entropy"));
|
||||
scroll.Add(TerminalLayout.BodyText("Enough Entropy for one standard 10-pull. This training reward is granted once per profile."));
|
||||
@@ -143,22 +150,22 @@ namespace KernelPanic.UI
|
||||
{
|
||||
if (_leaving || Guide.Active || !_combat.AwaitingWaveContinue || _combat.RunFinished) return;
|
||||
if (_lesson == 1 && !_run.RepositoryOffers.Any(offer => offer.Sold)) return;
|
||||
if (_lesson == 2 && _run.WavesCleared < 2) return;
|
||||
if (_run.WavesCleared < _lesson) return;
|
||||
try
|
||||
{
|
||||
var data = _save.Load();
|
||||
if (!TutorialCampaign.Required(data)) throw new InvalidOperationException("Training is not active.");
|
||||
if (_lesson == 1)
|
||||
if (_lesson < TutorialCampaign.LessonCount)
|
||||
{
|
||||
data.tutorialCheckpoint = _run.CaptureCheckpoint(_combat);
|
||||
data.tutorialLesson = 2;
|
||||
data.tutorialLesson = _lesson + 1;
|
||||
}
|
||||
else TutorialCampaign.Complete(data);
|
||||
_save.Save(data);
|
||||
_error = null;
|
||||
if (_lesson == 2) { _leaving = true; _returnToMenu(); return; }
|
||||
_lesson = 2; SetGuide(2);
|
||||
if (!_combat.ContinueTutorialWave()) throw new InvalidOperationException("Wave two could not start. Restart to resume the saved shop.");
|
||||
if (_lesson == TutorialCampaign.LessonCount) { _leaving = true; _returnToMenu(); return; }
|
||||
_lesson++; SetGuide(_lesson);
|
||||
if (!_combat.ContinueTutorialWave()) throw new InvalidOperationException("Training could not continue. Restart to resume the saved wave.");
|
||||
Redraw();
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException || ex is UnauthorizedAccessException || ex is InvalidOperationException || ex is OverflowException)
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace KernelPanic.UI
|
||||
_guide = guide; _overlay.style.display = DisplayStyle.Flex;
|
||||
_root.EnableInClassList("tutorial-card-focus", guide.Step.Anchor == "card");
|
||||
_anchor = ResolveAnchor();
|
||||
_progress.text = $"Wave {combat.RunConfig.TutorialLesson}/2 / step {guide.Index + 1} of {guide.Count}";
|
||||
_progress.text = $"Wave {combat.RunConfig.TutorialLesson}/{TutorialCampaign.LessonCount} / step {guide.Index + 1} of {guide.Count}";
|
||||
_title.text = guide.Step.Title; _copy.text = guide.Step.Copy;
|
||||
_next.style.display = guide.Reading ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
_next.SetEnabled(combat.TutorialInputReady);
|
||||
|
||||
@@ -13,6 +13,18 @@ namespace KernelPanic.UI
|
||||
private static bool _reducedMotion;
|
||||
private static UITextSize _textSize;
|
||||
private static UILayoutDensity _density;
|
||||
private static int _soundVolume = 75;
|
||||
public static int SoundVolume
|
||||
{
|
||||
get => _soundVolume;
|
||||
set
|
||||
{
|
||||
value = Mathf.Clamp(value, 0, 100);
|
||||
if (_soundVolume == value) return;
|
||||
_soundVolume = value;
|
||||
Changed?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public static event Action Changed;
|
||||
|
||||
@@ -73,7 +85,9 @@ namespace KernelPanic.UI
|
||||
bool motion = stored.reducedMotion;
|
||||
var size = stored.textSize == (int)UITextSize.Large ? UITextSize.Large : UITextSize.Standard;
|
||||
var density = stored.density == (int)UILayoutDensity.Comfortable ? UILayoutDensity.Comfortable : UILayoutDensity.Compact;
|
||||
bool changed = motion != _reducedMotion || size != _textSize || density != _density;
|
||||
int volume = Mathf.Clamp(stored.soundVolume, 0, 100);
|
||||
bool changed = motion != _reducedMotion || size != _textSize || density != _density || volume != _soundVolume;
|
||||
_soundVolume = volume;
|
||||
_reducedMotion = motion;
|
||||
_textSize = size;
|
||||
_density = density;
|
||||
@@ -86,7 +100,8 @@ namespace KernelPanic.UI
|
||||
{
|
||||
reducedMotion = _reducedMotion,
|
||||
textSize = (int)_textSize,
|
||||
density = (int)_density
|
||||
density = (int)_density,
|
||||
soundVolume = _soundVolume
|
||||
}));
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
@@ -98,6 +113,7 @@ namespace KernelPanic.UI
|
||||
public bool reducedMotion;
|
||||
public int textSize;
|
||||
public int density;
|
||||
public int soundVolume = 75;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user