51 lines
794 B
C#
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;
|
|
}
|
|
}
|
|
}
|