47 lines
1000 B
C#
47 lines
1000 B
C#
using Obvious.Soap;
|
|
using SoapCustomVariable;
|
|
using UnityEngine;
|
|
|
|
public class FlashLight : MonoBehaviour
|
|
{
|
|
public BoolVariable isFlashLightButtonPressed;
|
|
|
|
public FSMVariable playerState;
|
|
|
|
private Light flashLight;
|
|
|
|
private void Awake()
|
|
{
|
|
flashLight = GetComponent<Light>();
|
|
flashLight.enabled = false;
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
isFlashLightButtonPressed.OnValueChanged += IsFlashLightButtonPressedOnOnValueChanged;
|
|
playerState.OnValueChanged += PlayerStateOnOnValueChanged;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
isFlashLightButtonPressed.OnValueChanged -= IsFlashLightButtonPressedOnOnValueChanged;
|
|
playerState.OnValueChanged -= PlayerStateOnOnValueChanged;
|
|
}
|
|
|
|
private void PlayerStateOnOnValueChanged(State state)
|
|
{
|
|
if (state == State.vehicle)
|
|
{
|
|
flashLight.enabled = false;
|
|
}
|
|
}
|
|
|
|
private void IsFlashLightButtonPressedOnOnValueChanged(bool isPressed)
|
|
{
|
|
if (isPressed && playerState.Value != State.vehicle)
|
|
{
|
|
flashLight.enabled = !flashLight.enabled;
|
|
}
|
|
}
|
|
}
|