Files
ifontosh 1c6c9b2a70 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.
2026-09-08 17:09:27 +08:00

51 lines
1.6 KiB
C#

using UnityEngine;
namespace KirbyAdventures
{
/// <summary>
/// Village gate that opens when hit by Light after the ability is unlocked.
/// </summary>
public class LightGate : MonoBehaviour, ILightReactive
{
public bool IsOpen { get; private set; }
public Transform GateVisual;
public float OpenHeight = 4f;
public float OpenSpeed = 2.5f;
Vector3 _closedPos;
Vector3 _openPos;
bool _opening;
void Awake()
{
if (GateVisual == null)
GateVisual = transform;
_closedPos = GateVisual.localPosition;
_openPos = _closedPos + Vector3.up * OpenHeight;
}
public void OnHitByLight(Vector3 hitPoint, Vector3 direction)
{
if (IsOpen) return;
if (GameFlow.Instance != null && !GameFlow.Instance.LightAbilityUnlocked)
{
DialogueUI.ShowTemporary("Свет ещё спит внутри... Найди источник на тропе.", 3f);
return;
}
IsOpen = true;
_opening = true;
DialogueUI.ShowTemporary("Свет коснулся ворот — путь в деревню открыт.", 3.5f);
if (GameFlow.Instance != null)
GameFlow.Instance.TriggerWin();
}
void Update()
{
if (!_opening || GateVisual == null) return;
GateVisual.localPosition = Vector3.MoveTowards(
GateVisual.localPosition, _openPos, OpenSpeed * Time.unscaledDeltaTime);
}
}
}