mirror of
https://projects.caleb-brown.dev/UDRI-XRT/UDRIGEEKCup2024.git
synced 2025-01-22 15:18:25 -05:00
65 lines
1.8 KiB
C#
65 lines
1.8 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityAtoms.BaseAtoms;
|
|
using UnityEngine;
|
|
|
|
namespace MAVRIC.GEEKCup
|
|
{
|
|
public class TriggerWinLoseScreens : MonoBehaviour
|
|
{
|
|
[SerializeField] private BoolVariable winState;
|
|
[SerializeField] private BoolVariable inGoal;
|
|
[SerializeField] private VoidEvent restart;
|
|
[SerializeField] private IntVariable courseParNumber;
|
|
[SerializeField] private IntVariable strokeCount;
|
|
|
|
[SerializeField] private GameObject winScreen;
|
|
[SerializeField] private GameObject loseScreen;
|
|
|
|
private void OnEnable()
|
|
{
|
|
inGoal.Changed.Register(CheckGoal);
|
|
restart.Register(Restart);
|
|
strokeCount.Changed.Register(CheckStroke);
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
inGoal.Changed.Unregister(CheckGoal);
|
|
restart.Unregister(Restart);
|
|
strokeCount.Changed.Unregister(CheckStroke);
|
|
}
|
|
|
|
private void CheckStroke()
|
|
{
|
|
if (strokeCount.Value > courseParNumber.Value)
|
|
{
|
|
loseScreen.SetActive(true);
|
|
winState.Value = false;
|
|
}
|
|
}
|
|
|
|
private void CheckGoal()
|
|
{
|
|
if (courseParNumber.Value > strokeCount.Value)
|
|
{
|
|
winScreen.SetActive(true);
|
|
winState.Value = true;//this will trigger the fireworks that is on the XRrig
|
|
}
|
|
else
|
|
{
|
|
loseScreen.SetActive(true);
|
|
winState.Value = false;
|
|
}
|
|
}
|
|
|
|
private void Restart()
|
|
{
|
|
winScreen.SetActive(false);
|
|
loseScreen.SetActive(false);
|
|
winState.Value = false;
|
|
}
|
|
}
|
|
}
|