using UnityEngine;
namespace KirbyAdventures
{
///
/// Ensures a single bootstrap exists and builds the Phase A greybox level.
///
public class GameBootstrap : MonoBehaviour
{
static bool _initialized;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
static void AutoBootstrap()
{
if (_initialized) return;
if (FindFirstObjectByType() != null)
{
_initialized = true;
return;
}
var go = new GameObject("GameBootstrap");
go.AddComponent();
_initialized = true;
}
void Awake()
{
DontDestroyOnLoad(gameObject);
if (GameFlow.Instance == null)
{
var flowGo = new GameObject("GameFlow");
flowGo.AddComponent();
DontDestroyOnLoad(flowGo);
}
if (FindFirstObjectByType() == null)
{
var cp = new GameObject("CheckpointSystem");
cp.AddComponent();
DontDestroyOnLoad(cp);
}
BuildUi();
Level01ForestBuilder.Build();
}
void BuildUi()
{
var dialogue = DialogueUI.EnsureExists();
var pause = CreateOverlay("PauseOverlay", "ПАУЗА\nEsc — продолжить", new Color(0f, 0f, 0f, 0.65f));
pause.SetActive(false);
var win = CreateOverlay("WinOverlay", "Ворота открыты!\nДеревня ждёт Кирби.\n\nПобеда среза Phase A", new Color(0.05f, 0.2f, 0.1f, 0.8f));
win.SetActive(false);
if (GameFlow.Instance != null)
{
GameFlow.Instance.SetPauseOverlay(pause);
GameFlow.Instance.SetWinOverlay(win);
}
// silence unused
_ = dialogue;
}
static GameObject CreateOverlay(string name, string text, Color bg)
{
var canvasGo = new GameObject(name);
var canvas = canvasGo.AddComponent