1
0
mirror of https://projects.caleb-brown.dev/UDRI-XRT/UDRIGEEKCup2024.git synced 2025-01-22 15:18:25 -05:00
UDRIGEEKCup2024/Assets/GolfControls/StrokeCounter.cs
2024-04-16 10:31:20 -04:00

30 lines
620 B
C#

using System;
using UnityAtoms.BaseAtoms;
using UnityEngine;
namespace GolfControls
{
public class StrokeCounter : MonoBehaviour
{
public BoolVariable ballMovingVariable;
public IntVariable StrokeVariable;
public VoidEvent HitEvent;
private void OnEnable()
{
HitEvent.Register(OnHit);
}
private void OnDisable()
{
HitEvent.Unregister(OnHit);
}
private void OnHit()
{
if (ballMovingVariable.Value) return;
StrokeVariable.SetValue(StrokeVariable.Value+1);
}
}
}