add project files
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user