Initial Unity 6 scaffold for Cat Kirby Adventures.
Add Phase A greybox vertical slice: third-person movement, forest path, checkpoints, story triggers, and light ability gate.
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace KirbyAdventures
|
||||
{
|
||||
/// <summary>
|
||||
/// Global game state: pause, win, light ability unlock.
|
||||
/// </summary>
|
||||
public class GameFlow : MonoBehaviour
|
||||
{
|
||||
public static GameFlow Instance { get; private set; }
|
||||
|
||||
public bool IsPaused { get; private set; }
|
||||
public bool HasWon { get; private set; }
|
||||
public bool LightAbilityUnlocked { get; private set; }
|
||||
|
||||
GameObject _pauseOverlay;
|
||||
GameObject _winOverlay;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (Instance != null && Instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
public void SetPauseOverlay(GameObject overlay) => _pauseOverlay = overlay;
|
||||
public void SetWinOverlay(GameObject overlay) => _winOverlay = overlay;
|
||||
|
||||
public void UnlockLightAbility()
|
||||
{
|
||||
LightAbilityUnlocked = true;
|
||||
Debug.Log("[GameFlow] Light ability unlocked.");
|
||||
}
|
||||
|
||||
public void TogglePause()
|
||||
{
|
||||
if (HasWon) return;
|
||||
SetPaused(!IsPaused);
|
||||
}
|
||||
|
||||
public void SetPaused(bool paused)
|
||||
{
|
||||
IsPaused = paused;
|
||||
Time.timeScale = paused ? 0f : 1f;
|
||||
if (_pauseOverlay != null)
|
||||
_pauseOverlay.SetActive(paused);
|
||||
|
||||
Cursor.lockState = paused ? CursorLockMode.None : CursorLockMode.Locked;
|
||||
Cursor.visible = paused;
|
||||
}
|
||||
|
||||
public void TriggerWin()
|
||||
{
|
||||
if (HasWon) return;
|
||||
HasWon = true;
|
||||
IsPaused = true;
|
||||
Time.timeScale = 0f;
|
||||
if (_winOverlay != null)
|
||||
_winOverlay.SetActive(true);
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Cursor.visible = true;
|
||||
Debug.Log("[GameFlow] Level complete — village gate opened.");
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
var kb = UnityEngine.InputSystem.Keyboard.current;
|
||||
if (kb != null && kb.escapeKey.wasPressedThisFrame)
|
||||
TogglePause();
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (Instance == this)
|
||||
{
|
||||
Time.timeScale = 1f;
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user