Files
blockout/BlockOutReplica/Assets/Scripts/Gameplay/BlockOutJourneyInteractions.cs
T
2026-10-20 13:21:04 +08:00

53 lines
2.7 KiB
C#

using UnityEngine;
namespace BlockOutReplica.Gameplay
{
public sealed partial class BlockOutGameController
{
private BlockOutJourney journey;
public bool JourneyTab { get; private set; }
public int JourneyRevision { get; private set; }
public BlockOutJourney Journey => journey ?? (journey = new BlockOutJourney(BlockOutJourneyConfig.Load()));
public string JourneyNotice { get; private set; } = "";
public int JourneyCelebrationLevel { get; private set; }
public float JourneyCelebrationStartedAt { get; private set; } = -100f;
public bool JourneyCelebrationActive => Time.unscaledTime - JourneyCelebrationStartedAt < 2.8f;
private void SettleJourneyOnHome()
{
// Only settle the persisted win queue: opening an existing save must
// not invent retroactive grants. Wallet receipts prevent double pay.
int settled = 0;
foreach (var node in Journey.RewardNodes)
{
if (!Journey.IsQueued(node.Level) || !Journey.CanClaim(node.Level, CompletedLevels)) continue;
if (!Player.GrantJourneyOnce(node.Level, node.Rewards))
{ JourneyNotice = "Reward pending: unsupported original currency."; continue; }
if (!Journey.TryClaim(node.Level, CompletedLevels, out var rewards)) continue;
JourneyCelebrationLevel = node.Level;
JourneyCelebrationStartedAt = Time.unscaledTime;
settled++; JourneyRevision++;
JourneyNotice = "Level " + node.Level + " reward received!";
}
if (settled > 0) PlayUiSound("win_screen");
}
public void OpenHomeTab(bool showJourney)
{
if (ScreenState != BlockOutScreenState.Home || Modal != GameModal.None) return;
JourneyTab = showJourney; JourneyNotice = "";
}
public void ClaimJourneyReward(int levelNumber)
{
// Compatibility/debug entry only. Rewards no longer require clicking.
if (ScreenState == BlockOutScreenState.Home && Modal == GameModal.None) SettleJourneyOnHome();
}
public void SelectJourneyPoster(string id)
{
if (ScreenState != BlockOutScreenState.Home || Modal != GameModal.None) return;
if (Resources.Load<Sprite>("OriginalRecovered/" + id) == null)
{ JourneyNotice = "Poster artwork is not available in the local original resources."; return; }
if (!Journey.TrySelectPoster(id,CompletedLevels)) { JourneyNotice = "Complete more levels to unlock this chapter."; return; }
JourneyNotice = "Background selected"; JourneyRevision++; PlayUiSound();
}
}
}