Files
butchers-games-test/Assets/Scripts/Game/Player/WinHandler.cs
T
Boris Nikolaev 5f1e94b653 add project files
2026-08-14 01:58:31 +03:00

51 lines
794 B
C#

using System;
using UnityEngine;
public class WinHandler : MonoBehaviour
{
public bool Won { get; private set; }
public bool isWinning { get; private set; }
public bool moveActive { get; private set; }
public WinZone LastWinZone { get; private set; }
public event Action<WinZone> onTryPassDoor;
private void OnTriggerEnter(Collider other)
{
if (Won)
{
return;
}
WinZone zone = other.GetComponentInParent<WinZone>();
if (zone != null)
{
isWinning = true;
moveActive = zone.moveActive;
LastWinZone = zone;
if (this.onTryPassDoor != null)
{
this.onTryPassDoor(zone);
}
}
}
public void PassZone()
{
if (LastWinZone != null)
{
LastWinZone.Pass();
}
}
public void WinZone()
{
if (LastWinZone != null)
{
Won = true;
}
}
}